如何在True Client脚本中参数化xpath

时间:2019-02-06 05:42:37

标签: xpath loadrunner

这是我的情况-我的应用程序中有一个网格。网格包含带复选框的过滤器。选中复选框后,过滤器将应用于应用程序。 我已经编写了xpath来选择一个复选框(例如:// div [text()='FirstFilter'] / div),这将选择FirstFilter复选框。

我想对Xpath进行参数化,以便如果指定了任何过滤器名称,则应选中过滤器复选框。 我找不到在trueclient中对xpath进行paarmae​​terize的选项。

请提出任何建议。

1 个答案:

答案 0 :(得分:0)

您可以使用String filterName,然后使用它,可以像下面这样对xpath进行参数设置:

String filterName = null;       
// Insert the value in the filterName according to your requirements
WebElement element = driver.findElement(By.xpath("//div[text()="+filterName+"']/div"));