jmeter 无法使用Selinium webdriver和groovy脚本验证网页的加载程序

rnmwe5a2  于 2023-02-16  发布在  其他
关注(0)|答案(2)|浏览(168)

在Jmeter selinium webdriver中-尝试验证加载程序,加载程序完成后,将显示网页,以确认我需要将结果打印为"成功"
这是我的代码:

wait.until(ExpectedConditions.presenceOfElementLocated(org.openqa.selenium.By.xpath("//*[@class=\"spinner-border uxf-spinner-border-lg\"]")));

边界类为@class=\"spinner-border uxf-spinner-border-lg\获取错误为:

Response code:500
Response message:javax.script.ScriptException: groovy.lang.MissingPropertyException: No such property: wait for class:

任何建议都将是有益的

axr492tv

axr492tv1#

此错误消息...

Response message:javax.script.ScriptException: groovy.lang.MissingPropertyException: No such property: wait for class:

...意味着wait对象在使用前没有初始化。
溶液
WebDriverWait类已重新定义为:

WebDriverWait​(WebDriver driver, java.time.Duration timeout)

所以你的有效代码行是:

WebDriverWait wait = new WebDriverWait(driver, Duration.ofSeconds(10));
wait.until(ExpectedConditions.presenceOfElementLocated(By.xpath("//*[@class='spinner-border uxf-spinner-border-lg']")));
qcbq4gxm

qcbq4gxm2#

这是因为没有定义wait对象,需要事先显式声明它
比如:

def wait = new org.openqa.selenium.support.ui.WebDriverWait(WDS.browser, java.time.Duration.ofSeconds(5))

关于JMeter中Groovy脚本的更多信息:Apache Groovy: What Is Groovy Used For?

相关问题