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 do perform drag and drop using webdriver?
what is your approach clicking all the links which are available on the page?
When to use autoit?
What are the main advantages of automation testing?
Tell us how many exceptions do you know in selenium webdriver?
What are the different ways of locating a web element in selenium?
How to type in a textbox using selenium?
What is fluent wait in selenium webdriver?
How to handle https website in selenium? Or how to accept the ssl untrusted connection?
List some scenarios which we cannot automate using selenium webdriver?
How can you handle network latency using selenium?
Why to use testng with selenium rc?
Explain what is framework and what are the frameworks available in rc?
How can you prepare customized html report using testng in hybrid framework?
How to highlight element using selenium webdriver?