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 is XPath? How does it work?
Tell me could cookies be deleted in selenium?
How to debug the tests in selenium ide?
Tell us what are the two modes of views in selenium ide?
What are the different types of wait statements in selenium webdriver?
How to use frame elements in Selenium on a page?
What are the advantages of pom (page object model)?
How you can handle colors in web driver?
Which files can be used as data source for different frameworks?
How is a statement different from verification?
Can we use selenium rc for tests driving on two different browsers on one operating system without selenium grid?
What is testng assert and list out some common assertions supported by testng?
How you will switch from one frame to another?
Mention what are the capabilities of selenium webdriver or selenium 2.0?
Hi can anyone suggest me what type of non technical questions asked in interview for experienced people, I am trying to get job with fake experience can anyone help me please