0

変数を xpath に追加しようとしていますが、役に立ちません

これは以下で java assertTrue("Failed", verifyElementPresent("//*[@class='StdLJText' and contains(.,'2 Employees selected')]")); に対して機能します。

しかし、変数を追加すると、以下のようになりません

文字列 CountEmp1="2"; assertTrue("Failed", verifyElementPresent("//*[@class='StdLJText' and contains(.,CountEmp1+'Employees selected')]"));

4

1 に答える 1

1

メインの verifyElePresent 関数に文字列追加として CountEmp1 を配置する必要があります。verifyElementPresent("//*[@class='StdLJText' and contains(.,"+CountEmp1+"Employees selected')]"));

contains(.,CountEmp1+' での「+CountEmp1+」の置き換えに注意してください。

xpath を使用すると、verifyElementPresent メソッドは基本的に //*[@class='StdLJText' and contains(.,CountEmp1+'Employees selected')] を探します。ここで、countEmp1 は文字列値として取得され、連結する必要があるものではありません。

于 2012-11-19T12:19:40.780 に答える