Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/java/354.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Java 为什么fluentWait()很慢?_Java_Selenium - Fatal编程技术网

Java 为什么fluentWait()很慢?

Java 为什么fluentWait()很慢?,java,selenium,Java,Selenium,我正在我的selenium代码上使用fluentWait()。但是我注意到,虽然元素needwaited已经加载到浏览器上,但它仍在等待一段时间。这浪费了很多时间,但我不知道原因。有人知道为什么吗?每个FluentWait实例定义等待条件的最长时间,以及检查条件的频率。此外,用户可以将等待配置为在等待时忽略特定类型的异常,例如在搜索页面上的元素时忽略NoTouchElementExceptions // Waiting 30 seconds for an element to be pres

我正在我的
selenium
代码上使用
fluentWait()。但是我注意到,虽然元素needwaited已经加载到浏览器上,但它仍在等待一段时间。这浪费了很多时间,但我不知道原因。有人知道为什么吗?

每个FluentWait实例定义等待条件的最长时间,以及检查条件的频率。此外,用户可以将等待配置为在等待时忽略特定类型的异常,例如在搜索页面上的元素时忽略NoTouchElementExceptions

  // Waiting 30 seconds for an element to be present on the page, checking
  // for its presence once every 5 seconds.

  Wait wait = new FluentWait(driver)
    .withTimeout(30, SECONDS)
    .pollingEvery(5, SECONDS)
    .ignoring(NoSuchElementException.class);
将变慢,因为:

  // Waiting 30 seconds for an element to be present on the page, checking
  // for its presence once every 1 second.

  Wait wait = new FluentWait(driver)
    .withTimeout(30, SECONDS)
    .pollingEvery(1, SECONDS)
    .ignoring(NoSuchElementException.class);

因此,这取决于您将使用什么。

每个FluentWait实例定义等待条件的最长时间,以及检查条件的频率。此外,用户可以将等待配置为在等待时忽略特定类型的异常,例如在搜索页面上的元素时忽略NoTouchElementExceptions

  // Waiting 30 seconds for an element to be present on the page, checking
  // for its presence once every 5 seconds.

  Wait wait = new FluentWait(driver)
    .withTimeout(30, SECONDS)
    .pollingEvery(5, SECONDS)
    .ignoring(NoSuchElementException.class);
将变慢,因为:

  // Waiting 30 seconds for an element to be present on the page, checking
  // for its presence once every 1 second.

  Wait wait = new FluentWait(driver)
    .withTimeout(30, SECONDS)
    .pollingEvery(1, SECONDS)
    .ignoring(NoSuchElementException.class);

所以,这取决于您将使用什么。

谢谢,我将5改为1,现在它更快速了。顺便说一句,出于某种原因,如果我只使用fluentWait(By.id(xxxx)),它将以其他元素为目标,所以我需要先以它的父元素为目标。我该怎么做呢?谢谢,我把5改成了1,现在它更快了。顺便说一句,出于某种原因,如果我只使用fluentWait(By.id(xxxx)),它将以其他元素为目标,所以我需要先以它的父元素为目标。我该怎么办?如果你不发布你正在使用的代码并描述场景,我们该如何判断。你不使用
WebDriverWait
有什么原因吗?为什么需要使用
FluentWait
?我们如何判断您是否没有发布正在使用的代码并描述场景。您不使用
WebDriverWait
有什么原因吗?为什么需要使用
FluentWait