我可以使用selenium在第一页进行验证。但是,当我转移到下一页而不是显示上述错误时。
代码是: -
WebDriver driver = new FirefoxDriver();
String baseUrl = "http://192.168.1.47";
Selenium selenium = new WebDriverBackedSelenium(driver, baseUrl);
driver.get(baseUrl);
selenium.open("http://192.168.1.47");
selenium.type("username","clnt123822");
selenium.type("birthday", "150347");
String name = driver.findElement(By.name("username")).getAttribute("value").toString();
String dob = driver.findElement(By.name("birthday")).getAttribute("value").toString();
System.out.println(name);
System.out.println(dob);
selenium.click("btnsubmit");
// After pressing this button it is going to next page where i am having select
html tag.At this point error is coming
线程“main”中的异常com.thoughtworks.selenium.SeleniumException:找不到元素select1
这是第二页检查,它抛出错误
selenium.type("select1","r");
String select1 = driver.findElement(By.id("sel1")).getAttribute("value").toString();
System.out.println(select1);
答案 0 :(得分:0)
我猜你需要等到第二页中的元素可见/可点击。在点击第一页的提交按钮后尝试使用此代码。
WebElement element = new WebDriverWait(Driver,30).until(ExpectedConditions.elementToBeClickable(By.id("sel1")));