WebElement user = driver1.findElement(By.id("usrname"));
user.sendKeys("username");
System.out.println("Username entered");
WebElement password = driver1.findElement(By.id("usrpwd"));
password.sendKeys("password");
System.out.println("password entered");
WebElement submit = driver1.findElement(By.xpath(".//*[@id='ibm-pcon']/form/table[2]/tbody/tr/td/input[1]"));
submit.click();
System.out.println("submit button entered");
Thread.sleep(7000);
WebElement role = driver1.findElement(By.xpath("//input[@id='userRole'][@value='ARCOL '][@type='radio'][@name='role']"));
role.click();
System.out.println("role entered");
It is not able to find the element in web page by.xpath. Till thread.sleep() method code is running fine, but after that it is throwing error. Error: Exception in thread "main" org.openqa.selenium.NoSuchWindowException: Unable to find element on closed window (WARNING: The server did not provide any stacktrace information)为什么这个硒脚本(在IE11上)不能在Thread.sleep(7000)之后工作;
在这里,我们没有使用任何iframe,并为记录和回放它工作正常。但是通过这个手册代码,它无法在网页中找到元素 –