selenium报错Unable to find element on closed window
selenium集成webdriver开发,提示错误:
org.openqa.selenium.NoSuchWindowException: Unable to find element on closed window
但是实际上我的浏览器并未关闭,所做的操作是更新了地址栏中的url地址,
在网上搜索到有人说是IE11的问题,换做firefox可以修复问题,但问题是我必须用IE11,哪位大牛能帮忙解答下,不胜感激。
代码如下:
WebDriver driver = new InternetExplorerDriver(srvc);
driver.navigate().to(Constraint.homepage);
try {
Thread.sleep(3000);
} catch (InterruptedException e) {
e.printStackTrace();
}
driver.manage().timeouts().implicitlyWait(3000, TimeUnit.SECONDS);
driver.navigate().to(Constraint.homepage_cn);
try {
Thread.sleep(3000);
} catch (InterruptedException e) {
e.printStackTrace();
}
//driver.manage().window().maximize();
driver.manage().timeouts().implicitlyWait(3000, TimeUnit.SECONDS);
WebElement txtbox = driver.findElement(By.xpath("/html/body/div/div[2]/a[2]"));
txtbox.click();