При запуске Java приложения с двумя кнопками, стартует и браузер. А потом мне нужно, чтобы при нажатие на дну кнопку запускался один тест, при нажатие на вторую, другой тест. Нот так, как я написал, оно не работает.
package firstPackage;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.chrome.ChromeDriver;
import org.openqa.selenium.chrome.ChromeOptions;
public class FirstScript extends javax.swing.JFrame {
public FirstScript() {
initComponents();
}
@SuppressWarnings("unchecked")
// <editor-fold defaultstate="collapsed" desc="Generated Code">
private void initComponents() {
jButton1 = new javax.swing.JButton();
jButton2 = new javax.swing.JButton();
setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
jButton1.setText("Start");
jButton1.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
jButton1ActionPerformed(evt);
}
});
jButton2.setText("jButton2");
jButton2.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
jButton2ActionPerformed(evt);
}
});
javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
getContentPane().setLayout(layout);
layout.setHorizontalGroup(
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(layout.createSequentialGroup()
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addComponent(jButton1)
.addComponent(jButton2))
.addGap(0, 102, Short.MAX_VALUE))
);
layout.setVerticalGroup(
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(layout.createSequentialGroup()
.addComponent(jButton1)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(jButton2)
.addGap(0, 454, Short.MAX_VALUE))
);
pack();
}// </editor-fold>
private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) {
driver.get("https://vk.com/im");
}
private void jButton2ActionPerformed(java.awt.event.ActionEvent evt) {
driver.get("https://www.google.com.ua/");
}
public static void main(String args[]) {
ChromeOptions options = new ChromeOptions();
options.addArguments("user-data-dir=e:\\Duh\\Portable\\Browser\\centbrowser32\\User Data\\");
options.setBinary("E:\\Duh\\Portable\\Browser\\centbrowser32\\chrome.exe");
System.setProperty("webdriver.chrome.driver", "E:\\Duh\\Portable\\Browser\\centbrowser32\\chromedriver.exe");
WebDriver driver = new ChromeDriver(options);
java.awt.EventQueue.invokeLater(new Runnable() {
public void run() {
new FirstScript().setVisible(true);
}
});
}
// Variables declaration - do not modify
private javax.swing.JButton jButton1;
private javax.swing.JButton jButton2;
// End of variables declaration
}