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 to debug the tests in selenium ide?

1236


Mention what are the challenges in handling ajax call in selenium webdriver?

973


What is webdriverbackedselenium?

1142


Do you know a way to refresh browser by using selenium?

1020


What are the types of waits available in selenium webdriver?

941


Explain how you can find broken images in a page using selenium web driver?

1076


What is the difference between “/” and “XPath //”?

1229


What are the different keyboard operations that can be performed in selenium?

932


How to check if an element is visible on the web page?

959


How can we check if an element is enabled for interaction on a web page?

875


What are the advantages of using selenium as a test tool?

1069


Can we enter text without using sendkeys()?

1040


How would you test your element locator?

1050


How does testng allow you to state dependencies?

1049


What are the capabilities of selenium webdriver or selenium 2.0?

961