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


Please Help Members By Posting Answers For Below Questions

What is XPath? How does it work?

518


Tell me could cookies be deleted in selenium?

476


How to debug the tests in selenium ide?

527


Tell us what are the two modes of views in selenium ide?

459


What are the different types of wait statements in selenium webdriver?

3207






How to use frame elements in Selenium on a page?

532


What are the advantages of pom (page object model)?

3012


How you can handle colors in web driver?

474


Which files can be used as data source for different frameworks?

1077


How is a statement different from verification?

483


Can we use selenium rc for tests driving on two different browsers on one operating system without selenium grid?

496


What is testng assert and list out some common assertions supported by testng?

488


How you will switch from one frame to another?

503


Mention what are the capabilities of selenium webdriver or selenium 2.0?

502


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

900