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

Tell me what api is required for database testing in selenium webdriver?

917


What evaluation can selenium do?

970


Which automation tools can be used for post-launch validation with continuous integration?

935


What are the advantages and disadvantages of selenium ?

1096


What are the challenges in handling ajax call in selenium webdriver?

950


What is the difference between “/” and “//” in xpath?

1205


How to handle dropdowns in selenium?

1090


What is intellij?

955


What happen if you mix both implicit wait and explicit wait in a selenium script?

963


What is the framework?

867


Explain what are the junits annotation linked with selenium?

957


Tell us can you write the code to double click an element in selenium?

862


How to run selenium webdriver test from the command line?

1085


How to use regular expressions in selenium?

1017


How selenium grid works?

952