driver.findElement(By.xpath("//input[@type="+"checkbox"+"]/following-sibling:://td[contains(text(),"+"template"+"]"))
我的HTML是這樣硒的webdriver拋出錯誤,而選擇的XPath
<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: The given selector //input[@type=checkbox]/following-sibling:://td[contains(text(),template] is either invalid or does not result in a WebElement. The following error occurred: InvalidSelectorError: Unable to locate an element with the xpath expression //input[@type=checkbox]/following-sibling:://td[contains(text(),template] because of the following error: [Exception... "The expression is not a legal expression." code: "12" nsresult: "0x805b0033 (SyntaxError)" location: "file:///C:/Users/sanjdash/AppData/Local/Temp/anonymous3529970525380845680webdriver-profile/extensions/[email protected]/components/driver_component.js Line: 5956"] Command duration or timeout: 72 milliseconds For documentation on this error, please visit: http://seleniumhq.org/exceptions/invalid_selector_exception.html Build info: version: '2.37.0', revision: 'a7c61cbd68657e133ae96672cf995890bad2ee42', time: '2013-10-18 09:51:02'
@ user2939258:看起來你以前從來沒有接受任何答案。只是讓你知道這個答案是否解決了你的問題,請考慮接受它。 (http://meta.stackexchange.com/a/5235/220697)否則請在這裏提供一些反饋。 –