带有可变部分的Xpath

时间:2017-08-21 12:35:17

标签: selenium xpath

我有标识符“data-component = order-button_guid”

的组件

我想像

一样生成Xpath
"//*[@data-component='order-button']+applicationId"

以形式出现 order-button_xxxx-xxx-xxx-xxxxxxxx

1 个答案:

答案 0 :(得分:0)

在单引号(')之前将GUID与xpath连接,如下所示。

driver.findElement(By.Xpath("//*[@data-component='order-button+applicationId+']"))