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
How to debug the tests in selenium ide?
Mention what are the challenges in handling ajax call in selenium webdriver?
What is webdriverbackedselenium?
Do you know a way to refresh browser by using selenium?
What are the types of waits available in selenium webdriver?
Explain how you can find broken images in a page using selenium web driver?
What is the difference between “/” and “XPath //”?
What are the different keyboard operations that can be performed in selenium?
How to check if an element is visible on the web page?
How can we check if an element is enabled for interaction on a web page?
What are the advantages of using selenium as a test tool?
Can we enter text without using sendkeys()?
How would you test your element locator?
How does testng allow you to state dependencies?
What are the capabilities of selenium webdriver or selenium 2.0?