How to Handle Multiple Windows in Selenium Webdriver using Java

.

              Multiple Windows Handling in Selenium  

How to Handle Multiple Windows in Selenium?
How to handle Child window in selenium?

Selenium Code - 
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.WebElement;
import org.openqa.selenium.chrome.ChromeDriver;
import java.util.Iterator;
import java.util.Set;
import org.openqa.selenium.By;
 
public class MultipleWindow 
{
 
public static void main(String[] args
{
// TODO Auto-generated method stub
System.setProperty("webdriver.chrome.driver", "C:\\Software\\ChromeDriver\\chromedriver.exe");
WebDriver driver=new ChromeDriver();
 driver.get("https://demoqa.com/browser-windows");
 
        // This statement will Open new window 
         driver.findElement(By.id("windowButton")).click();
 
       //Get handles of the windows
         String mainWindowHandle = driver.getWindowHandle();
         Set<String> allWindowHandles = driver.getWindowHandles();
         Iterator<String> iterator = allWindowHandles.iterator();
 
         // This Statement will check if child window has other child windows and will fetch the heading of the child window
         while (iterator.hasNext()) 
{
             String ChildWindow = iterator.next();
                 if (!mainWindowHandle.equalsIgnoreCase(ChildWindow)) 
{
                 driver.switchTo().window(ChildWindow);
                 WebElement text = driver.findElement(By.id("sampleHeading"));
                 System.out.println("Handling Child Window " + text.getText());
             }
         }
     }
 
}

 

 

 

 


How 


Hope!!! Above Tutorial of how to handle multiple windows in selenium helpful for you ...

Team,
QA acharya

Tags: Multiple window handling in selenium , Window handling in selenium Webdriver , Windows Handling in Selenium , How to switch window 

How to handle multiple windows in selenium 


.

Post a Comment

1 Comments

  1. Residents of North Korea, unfortunately, inhabit what is often described as some of the repressed international locations on earth. This primarily signifies that the vast majority of the population do not have the luxury of even considering playing in} gambling online or offline. This is to the extent where a pill was introduced to the nation’s individuals in 2014, named the Ullim. This device was found to be full of invasive software and hardware that screens the consumer and may even save browser historical past and take screen-shots of opened apps by itself. This by itself must be sufficient to dissuade most from even considering accessing websites that are not authorities permitted. The online on line casino big Paddy 카지노사이트 Power did have a short cameo within the deliberate meetups of North Korean leader Kim Jong-un and former basketball participant Dennis Rodman back in 2014.

    ReplyDelete