Reputation: 11
In order to login to the conference as 4 different roles, for each role I wrote
System.setProperty("webdriver.firefox.profile", "default");
FirefoxDriver driver = new FirefoxDriver();
driver.manage().timeouts().implicitlyWait(120, TimeUnit.SECONDS);
driver.get("link to the conference");
How can I switch between Firefox windows then? Windows titles are the same. Thanks
Upvotes: 1
Views: 3906
Reputation: 108
public TasksWindow OpenInWindow() {
WebDriverWait wait = new WebDriverWait(Driver.driver, TimeSpan.FromSeconds(10));
wait.IgnoreExceptionTypes(typeof(AssertionException));
String windowName = wait.Until<String>((d) => {
this.windowSwitcher.Click();
if (d.WindowHandles.Count != 2) // this means you are waiting till the number of windows equals 2 {
return null;
}
return d.WindowHandles[1]; // this means you are changing to the second window (from [0] to [1])
});
return new TasksWindow(windowName);
}
This works in c#
Upvotes: 1
Reputation: 699
You can use this code to navigate between your window if you want you can change it according to your needs
//All the window handles will be returned and u can use window handle to switch between the windows
Set<String> windows = getWebDriver().getWindowHandles();
Iterator<String> window = windows.iterator();
while( window.hasNext() ) {
getWebDriver().switchTo().window( window.next() );
}
Upvotes: 1