driver.findElement(By.xpath("//input[@type="+"checkbox"+"]/following-sibling:://td[contains(text(),"+"template"+"]"))
我的 HTML 是这样的
<tr>
<td class="tablecontent">
<input type="checkbox" value="59781" name="templateIds">
</td>`enter code here`
<td class="tablecontent"> test11 </td>
</tr>
org.openqa.selenium.InvalidSelectorException:给定的选择器 //input[@type=checkbox]/following-sibling:://td[contains(text(),template] 无效或不会生成 WebElement。发生以下错误:InvalidSelectorError: Unable to locate an element with the xpath expression //input[@type=checkbox]/following-sibling:://td[contains(text(),template] 因为以下错误:[异常...“表达式不是合法表达式。”代码:“12”nsresult:“0x805b0033(SyntaxError)”位置:“file:///C:/Users/sanjdash/AppData/Local/Temp/anonymous3529970525380845680webdriver-profile /extensions/fxdriver@googlecode.com/components/driver_component.js 行:5956"] 命令持续时间或超时:72 毫秒有关此错误的文档,请访问: http://seleniumhq.org/exceptions/invalid_selector_exception.html构建信息:版本:'2.37.0',修订:'a7c61cbd68657e133ae96672cf995890bad2ee42',时间:'2013-10-18 09:51:02'