Warning: file_get_contents(/data/phpspider/zhask/data//catemap/7/css/36.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
使用Karate中的变量通过XPath获取元素_Karate - Fatal编程技术网

使用Karate中的变量通过XPath获取元素

使用Karate中的变量通过XPath获取元素,karate,Karate,我想使用script()函数获取元素,但我想使用XPath中定义的变量。你知道这是怎么回事吗 我用的是空手道1.0.1 * def username = __arg.username * print 'username:', username * def listRowElement = script("//div[@aria-colindex='1' and text()='"+username+"']", '_.textContent')

我想使用
script()
函数获取元素,但我想使用XPath中定义的变量。你知道这是怎么回事吗

我用的是空手道1.0.1

  * def username = __arg.username
  * print 'username:', username
  * def listRowElement = script("//div[@aria-colindex='1' and text()='"+username+"']", '_.textContent')
  * mouse().move(listRowElement).click()
如果我只是把用户名放进去就可以了,但我希望它是可重用的


提前感谢您的输入。

您不需要
script()
来形成动态定位器

* def listRowElement = "//div[@aria-colindex='1' and text()='" + username + "']"
* mouse().move(listRowElement).click()

事实上,这也可能起作用:
*鼠标({}+用户名)。单击()