JMeter中的WebDriver采样器中的预期条件接口错误

时间:2018-12-13 11:58:49

标签: selenium jmeter webdriver jmeter-5.0 expected-condition

我想使用Expected Condition界面并在WebDriver采样器中实现以下应用方法。该脚本可在单个页面上加载多个图表,但会给我错误

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();

0 个答案:

没有答案