Reputation: 125
Learning Java
& Selenium
. I researched dialog box and came up with this:
<Code to run some selenium test>
JOptionPane.showMessageDialog(frame,
"Completed Boundaries Test. Press Ok for next test.");
<Code to run some other selenium test>
Idea is to have such dialog statement between tests so that user can validate the run, instead of relying on sleep and visually looking at the result--which is prone to error.
I couldn't get it to work. I don't know what to pass for frame. Here is my chrome driver and first test:
System.setProperty("webdriver.chrome.driver", "C:\\ChromeDriver\\chromedriver.exe");
WebDriver driver = new ChromeDriver();
driver.get("http://preview.harriscountyfws.org/");
driver.manage().window().maximize();
JOptionPane.showMessageDialog(frame,
"Screen Maximize Completed. Press ok for next test.");
System.out.println("County Lines Checkbox Test, Default is checked, let's uncheck");
WebElement chkCounties = driver.findElement(By.id("chkCounties"));
chkCounties.click();
Upvotes: 2
Views: 1245
Reputation: 23805
You need to create the object of JFrame
and pass it as below :-
import javax.swing.JFrame;
System.setProperty("webdriver.chrome.driver", "C:\\ChromeDriver\\chromedriver.exe");
WebDriver driver = new ChromeDriver();
driver.get("http://preview.harriscountyfws.org/");
driver.manage().window().maximize();
// now create the JFrame object
JFrame frame = new JFrame();
frame.setAlwaysOnTop(true);
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
frame.setVisible(true);
frame.setVisible(false);
JOptionPane.showMessageDialog(frame,
"Screen Maximize Completed. Press ok for next test.");
System.out.println("County Lines Checkbox Test, Default is checked, let's uncheck");
WebElement chkCounties = driver.findElement(By.id("chkCounties"));
chkCounties.click();
Hope it helps..:)
Upvotes: 1