Switch between two browser windows using Selenium WebDriver

0
0

I used Firefox Driver to open two URL’s. Whenever I invoke driver, new firefox window is opened. I have to switch between these two windows. How can I do this?

  • You must to post comments
0
0

you can use following code to switch between windows based on the window title

 private void handleMultipleWindows(String windowTitle) {
Set<String> windows = driver.getWindowHandles();
for (String window : windows) {
driver
.switchTo().window(window);
if (driver.getTitle().contains(windowTitle)) {
return;
}
}
}

Similary you could use URL or some other criteria to switch windows.

  • You must to post comments
Showing 1 result
Your Answer
Post as a guest by filling out the fields below or if you already have an account.
Name*
E-mail*
Website