How do you handle Multiple windows in your application?
Answer Posted / deepa
driver.findElement(By.id(“id of the link which opens new window”)).click();
//wait till two windows are not opened
waitForNumberofWindowsToEqual(2);//this method is for wait
Set handles = driver.getWindowHandles();
firstWinHandle = driver.getWindowHandle(); handles.remove(firstWinHandle);
String winHandle=handles.iterator().next();
if (winHandle!=firstWinHandle){
//To retrieve the handle of second window, extracting the handle which does not match to first window handle
secondWinHandle=winHandle; //Storing handle of second window handle
//Switch control to new window
driver.switchTo().window(secondWinHandle);
| Is This Answer Correct ? | 4 Yes | 0 No |
Post New Answer View All Answers
What are the advantages of the automation structure?
List some of the operating systems that are supported by selenium webdriver.
What is selenium 3.0?
What kinds of tests can Selenium support?
What are the different types of drivers available in webdriver?
How can we find the value of different attributes like name, class, value of an element?
What is the alternative to driver.get() method to open an url using selenium webdriver?
What’s selenese?
What is a relative xpath?
How many types of locators are there in selenium?
How to verify if the checkbox/radio is checked or not?
What are desiredcapabilities in selenium webdriver?
Does selenium support mobile internet testing?
What is Selenium IDE?
List the advantages of webdriver over selenium server?