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 is assert command different from verify command?
What selenese command and argument can be used to transfer the value of a javascript variable into a side variable?
Why testers should opt for selenium and not qtp?
What are the annotations available in testng?
How to retrieve css properties of an element?
What is the use of javascriptexecutor?
Using selenium how can you handle network latency?
Please explain what are the different types of locators in selenium?
Can we use selenium rc to drive tests on two different browsers on one operating system without selenium grid?
What is the command to connect a node to the selenium grid?
List some advantages of test automation?
Tell us how you can use recovery scenario with selenium?
Mention what is selenium 3.0?
What do we mean selenium selenium 1 and 2?
How to pause a test execution for 5 seconds at a specific point?