更新时间:2022-12-06 18:58:43
看起来像是把引号弄乱了.在XPath中使用单引号可以避免出现此类问题.
Looks like your messed up with quotes. Use single quotes in XPath to avoid issues like this.
// if template is the text within your XPath
driver.findElement(By.xpath("//input[@type='checkbox']/following-sibling:://td[contains(text(), 'template']"));
// if template is your variable, then it should be
driver.findElement(By.xpath("//input[@type='checkbox']/following-sibling:://td[contains(text(), " + template + "']"));
此外,请仔细阅读该错误,它会告诉您您已经需要足够的信息.如您所见,消息的选择器中没有引号.
Also, please read the error carefully, it tells enough information you need already. As you can see, there are no quotes in the selector in the message.
给定的选择器 //input [@ type = checkbox]/following-sibling :://td [contains(text(),template] 是无效的或不会导致WebElement.
The given selector //input[@type=checkbox]/following-sibling:://td[contains(text(),template] is either invalid or does not result in a WebElement.