且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

在系统中找到但在詹金斯中找不到的硒元素

更新时间:2023-11-20 10:38:16

尝试使用fluentwait而不是Thread.sleep().您的元素可能没有在10秒内加载完毕,您可以尝试

Try using fluentwait instead of Thread.sleep(). Your element might not have been loaded in 10 seconds you may try this

// Waiting 30 seconds for an element to be present on the page, checking
 // for its presence once every 5 seconds.
   Wait<WebDriver> wait = new FluentWait<WebDriver>(driver)
   .withTimeout(30, SECONDS)
   .pollingEvery(5, SECONDS)
   .ignoring(NoSuchElementException.class);

WebElement foo = wait.until(new Function<WebDriver, WebElement>() {
 public WebElement apply(WebDriver driver) {
   return driver.findElement(By.id("foo"));
 }
}); 

这里.