Hi,
Please find the code snippet.
for Issue1: Webdriver throws Exception after closing the pop window
wd.findElement(By.id("xx")).click();
Robot r=new Robot();
r.keyPress(KeyEvent.VK_TAB);
r.delay(1000);
// Press Enter
r.keyPress(KeyEvent.VK_ENTER);
Set<String> windows = wd.getWindowHandles();
loop1:
for (String window : windows) {
wd.switchTo().window(window);
if (wd.getTitle().contains("Welcome")) {
break loop1;
}
}
wd.switchTo().frame("Main");
wd.findElement(By.name("tab")).click();
for Issue2:
//clicking button1 opens a new window
String pw=wd.getWindowHandle();
wd.findElement(By.id("button1")).click();
Set<String> windows = wd.getWindowHandles();
loop2:
for (String window : windows) {
wd.switchTo().window(window);
if (wd.getTitle().contains("Welcome1")) {
break loop2;
}
}
wd.findElement(By.name("yy")).sendKeys("abc");
wd.findElement(By.name("checkbox")).click();
wd.findElement(By.name("Continue")).click();
wd.switchTo().window(pw);
//clicking button2 opens a new window , Webdriver throws "Unable to get browser Exception
wd.findElement(By.id("button2")).click();
Set<String> windows1 = wd.getWindowHandles();
loop2:
for (String window : windows1) {
wd.switchTo().window(window);
if (wd.getTitle().contains("Welcome2")) {
break loop2;
}
}
wd.findElement(By.name("yy")).sendKeys("abc");
wd.findElement(By.name("checkbox")).click();
wd.findElement(By.name("Continue")).click();
Using IE browser version 9 and Windows 64 bit OS.
Regards,
Gokul.