使用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()
事实上,这也可能起作用:
*鼠标({}+用户名)。单击()