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
Tell me what api is required for database testing in selenium webdriver?
What evaluation can selenium do?
Which automation tools can be used for post-launch validation with continuous integration?
What are the advantages and disadvantages of selenium ?
What are the challenges in handling ajax call in selenium webdriver?
What is the difference between “/” and “//” in xpath?
How to handle dropdowns in selenium?
What is intellij?
What happen if you mix both implicit wait and explicit wait in a selenium script?
What is the framework?
Explain what are the junits annotation linked with selenium?
Tell us can you write the code to double click an element in selenium?
How to run selenium webdriver test from the command line?
How to use regular expressions in selenium?
How selenium grid works?