I want to use Expected Condition interface and implement apply method as follows in WebDriver sampler. This script for loading multiple charts on single page but it give me error
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.”
Environment:
JMeter : version 5
Java : java version "1.8.0_181"
Can anyone please help? This is my code:
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();