XML 按钮上的 JMeter jp@gc-WebDriver 采样器元素动态名称

时间:2021-02-06 08:39:21

标签: groovy jmeter jmeter-plugins

我正在使用带有 Groovy 的 JMeter 来开发客户端脚本。我不确定如何为下面的动态元素变量命名。敬请指教。

findElement(By.xpath("(//button[@type='button'])[30]")).click();

我尝试了以下元素名称,但没有奏效。 [错误] 10000 毫秒后隐式等待超时 [error] 元素 //div[contains(@class,'el-button--')]/li/div not found

enter image description here

enter image description here

enter image description here

1 个答案:

答案 0 :(得分:0)

  1. 找到带有文本 OK<span> 元素
  2. 找到它的 parent - 这将是您正在寻找的 <button>

类似于:

findElement(By.xpath("//span[contains(text(), 'OK')]/parent::button")).click()

如果有多个带有文本 OK 的 span,您将必须找出唯一标识要单击的特定按钮的方法。

您可能会发现 Using the XPath Extractor in JMeter 文章很有用,它主要针对 JMeter 的 XPath Extractor,但在涉及 XPath 语言评估时,WebDriver Sampler 的语法将相同。

相关问题