我正在尝试将变量添加到xpath但无效
这适用于java assertTrue(“失败”,verifyElementPresent(“// * [@ class ='StdLJText'并包含(。,'2 Employees selected')]”));
但是当我添加变量时,如下所示
String CountEmp1 =“2”; assertTrue(“失败”,verifyElementPresent(“// * [@ class ='StdLJText'并包含(。,CountEmp1 +'Employees selected')]”));
答案 0 :(得分:0)
你需要在主verifyElePresent函数中添加CountEmp1作为字符串添加,即verifyElementPresent("//*[@class='StdLJText' and contains(.,"+CountEmp1+"Employees selected')]"));
注意在contains(。,CountEmp1 +'
中替换“+ CountEmp1 +”使用xpath,verifyElementPresent方法基本上查找// * [@ class ='StdLJText'并包含(。,CountEmp1 +'Employees selected')]其中countEmp1被视为字符串值,而不是需要连接的东西。