I am new to teaching Selena. WebDriver.getWindowHandle () the documentation is not very clear to me, and the example does not work, as indicated in the book, so I thought about the confirmation of the value returned by this method.
1) Let's say I'm on page PAGE1. Therefore, getWindowHandle () should return a handle to PAGE1. (Correctly)
2) Now from this page I will go to PAGE2 (hyperlink and opening a new window). My book says getWindowHandle () should return a handle to PAGE2. However, my program still returns the PAGE1 handle.
Selenium v2.43
Playable in Firefox and Chrome both.
Question: What is the exact value returned by getWindowHandle ()?
WebDriver wd = new ChromeDriver();
wd.get("file://D:/Projects/Selenium/Startup/web/ch3/switch_main.html");
String h1 = wd.getWindowHandle();
System.out.println("First handle = " + h1);
WebElement clickhere = wd.findElement(By.id("clickhere"));
clickhere.click();
String h2 = wd.getWindowHandle();
System.out.println("Second handle = " + h2);