Quantcast
Channel: Active questions tagged selenium - Stack Overflow
Viewing all articles
Browse latest Browse all 98827

How to open multiple windows using Selenium WebDriver

$
0
0

I was trying to learn about "switching between multiple windows" using Selenium WebDriver but for that I am unable to OPEN multiple windows using driver.get() or driver.navigate.to(), that opens the links in the SAME window. Can someone help me to open multiple windows using the same driver instance? I have provided my sample code. That value of n is coming as 1 and not 2 as its opening in the same window. Please help.

public class MultipleWindows {

    public static void main(String[] args) {
        // TODO Auto-generated method stub
        WebDriver driver = new FirefoxDriver();

        driver.manage().timeouts().implicitlyWait(10,TimeUnit.SECONDS);


        driver.get("http://www.google.com");

        driver.navigate().to("http://www.facebook.com");


        int n = driver.getWindowHandles().size();
        System.out.println(n);

    }

}

Viewing all articles
Browse latest Browse all 98827

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>