我想在 WebDriver 采样器中使用 Expected Condition 接口并实现如下应用方法。此脚本用于在单个页面上加载多个图表,但它给了我错误
javax.script.ScriptException: In file: inline evaluation of:
import java.io.File; import org.apache.commons.io.FileUtils;
import openqa.selen . . . '' Encountered "( new ExpectedCondition <"
at line 22, column 19.in inline evaluation of: ``
import java.io.File; import org.apache.commons.io.FileUtils;
import openqa.selen . . . '' at line number 22.”
环境:
JMeter : version 5
Java : java version "1.8.0_181"
有人可以帮忙吗?这是我的代码:
WDS.sampleResult.sampleStart();
List loading =WDS.browser.findElements(By.xpath("//img[@class='loading']"));
WDS.log.info("Total "+loading.size());
wait.until(new ExpectedCondition<Boolean>() {
public Boolean apply(WebDriver WDS.browser) {
Iterator eleIterator =WDS.browser.findElements(By.xpath("//img[@class='loading']")).iterator();
while (eleIterator.hasNext()) {
boolean displayed = false;
try {
displayed = eleIterator.next().isDisplayed();
// System.out.println("TEST = "+displayed);
}
catch (NoSuchElementException e)
{
displayed = false;
}
catch (StaleElementReferenceException e)
{
displayed = false;
}
if (displayed) {
// return false even if one of them is displayed.
return false;
}
}
//this means all are not displayed/invisible
return true;
}
});
WDS.sampleResult.sampleEnd();