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);
}
}