Golgappa.net | Golgappa.org | BagIndia.net | BodyIndia.Com | CabIndia.net | CarsBikes.net | CarsBikes.org | CashIndia.net | ConsumerIndia.net | CookingIndia.net | DataIndia.net | DealIndia.net | EmailIndia.net | FirstTablet.com | FirstTourist.com | ForsaleIndia.net | IndiaBody.Com | IndiaCab.net | IndiaCash.net | IndiaModel.net | KidForum.net | OfficeIndia.net | PaysIndia.com | RestaurantIndia.net | RestaurantsIndia.net | SaleForum.net | SellForum.net | SoldIndia.com | StarIndia.net | TomatoCab.com | TomatoCabs.com | TownIndia.com
Interested to Buy Any Domain ? << Click Here >> for more details...

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

How is assert command different from verify command?

1014


What selenese command and argument can be used to transfer the value of a javascript variable into a side variable?

4919


Why testers should opt for selenium and not qtp?

825


What are the annotations available in testng?

908


How to retrieve css properties of an element?

911


What is the use of javascriptexecutor?

3509


Using selenium how can you handle network latency?

991


Please explain what are the different types of locators in selenium?

847


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

877


What is the command to connect a node to the selenium grid?

910


List some advantages of test automation?

870


Tell us how you can use recovery scenario with selenium?

876


Mention what is selenium 3.0?

892


What do we mean selenium selenium 1 and 2?

861


How to pause a test execution for 5 seconds at a specific point?

946