This repository was archived by the owner on Nov 29, 2018. It is now read-only.
-
-
Notifications
You must be signed in to change notification settings - Fork 195
This repository was archived by the owner on Nov 29, 2018. It is now read-only.
Get Window Handle Hangs. #3615
Copy link
Copy link
Closed
Description
Originally reported on Google Code with ID 3615
What steps will reproduce the problem?
1.Unzip the Attached html folder.
2.In the Code Change the path to where you've unzipped the folder to Index.html
3.Run the code
What is the expected output? What do you see instead?
Get Window Handle Hangs.
Selenium version:2.17
OS:Windows 7Home Basic 64Bit
Browser:Firefox
Browser version:10.0.2
The Following is the code:
import java.util.Iterator;
import java.util.Set;
import org.openqa.selenium.By;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.firefox.FirefoxDriver;
public class AlertClass {
public static void main(String[] args) throws InterruptedException {
WebDriver driver = new FirefoxDriver();
driver.get("file:///D:/html/Index.html");
System.out.println("Before click");
driver.findElement(By.xpath("html/body/table/tbody/tr/td[2]/a"))
.click();
// Thread.sleep(30000L);
Set<String> windows = driver.getWindowHandles();
Iterator<String> iter = windows.iterator();
System.out.println(driver.getWindowHandles().size());
// Set Parent windowhandle
String parent = iter.next();
// Switch to new window
driver.switchTo().window(iter.next());
// get label text in the new window
System.out.println(driver.findElement(By.xpath("html/body")).getText());
// close the new window
driver.close();
// switch to parent
driver.switchTo().window(parent);
// close main window
driver.close();
}
}
Reported by hemanth716
on 2012-03-24 09:47:25
- _Attachment: [html.zip](https://storage.googleapis.com/google-code-attachments/selenium/issue-3615/comment-0/html.zip)_