How to handle multiple windows in Selenium Webdriver?

0 votes
How to handle multiple windows in Selenium Webdriver?
May 24, 2019 in Selenium by Ritika
142 views

1 answer to this question.

0 votes

Hey Ritika, you can handle multiple windows in Selenium Webdriver by using driver.getWindowHandles() method. Check this code snippet for understanding better:

    String currentWindow = driver.getWindowHandle(); //get parent(current) window name
    for(String popup :driver.getWindowHandles()) //iterating on child windows
    {
    	driver.switchTo().window(popup);
    	System.out.println("Popup values: "+popup);
    	// Perform any operations on child window
    }
    driver.switchTo().window(currentWindow); //switch back to main window & continue further execution
answered May 24, 2019 by Anvi
• 14,090 points

Related Questions In Selenium

0 votes
1 answer

How to handle drop downs using Selenium WebDriver in Java

First, find an XPath which will return ...READ MORE

answered Mar 27, 2018 in Selenium by nsv999
• 5,510 points
4,300 views
0 votes
1 answer

How to handle Pop-up in Selenium WebDriver using Java

Actually, its pretty simple. Use this code ...READ MORE

answered Apr 5, 2018 in Selenium by nsv999
• 5,510 points
7,376 views
0 votes
1 answer

How to handle the popup of file upload in Windows OS with WebDriver?

The value of name locator has probably ...READ MORE

answered Apr 25, 2018 in Selenium by king_kenny
• 3,710 points
8,602 views
+1 vote
1 answer

How to handle notifications in Python with Selenium (Chrome WebDriver)

Below will help you: You can disable the ...READ MORE

answered May 11, 2018 in Selenium by Samarpit
• 5,890 points
6,310 views
0 votes
2 answers

Finding WebDriver element with Class Name in java

The better way to handle this element ...READ MORE

answered Apr 10, 2018 in Selenium by nsv999
• 5,510 points
3,480 views
0 votes
2 answers

Problem while using InternetExplorerDriver in Selenium WebDriver

enable trusted connection  in internet explorer by ...READ MORE

answered Aug 31 in Selenium by Sri
• 2,970 points
4,489 views
0 votes
1 answer

Geo-location microphone camera pop up

To Allow or Block the notification, access using Selenium and you have to ...READ MORE

answered May 11, 2018 in Selenium by Samarpit
• 5,890 points
2,570 views
0 votes
2 answers

How to use such xpath to find web elements

xpath are two types. 1) Absolute XPath:    /html/b ...READ MORE

answered Sep 2 in Selenium by Sri
• 2,970 points
2,808 views
0 votes
1 answer

How to handle Bootstrap dropdown in Selenium Webdriver?

Hi Neeru, Bootstrap dropdown isn't like traditional ...READ MORE

answered Jul 18, 2019 in Selenium by Anvi
• 14,090 points
1,743 views
0 votes
1 answer

How to click on Image in Selenium Webdriver?

Hello Lalit, I guess you mean to ...READ MORE

answered May 9, 2019 in Selenium by Anvi
• 14,090 points
5,507 views