【发布时间】:2020-09-05 12:56:17
【问题描述】:
我拥有的以下检查代码是单击我可以确认订单的按钮
<button type="submit" class="button btn btn-default button-medium">
<span>I confirm my order<i class="icon-chevron-right right"></i></span>
</button>
<span>I confirm my order<i class="icon-chevron-right right"></i></span>
我试过的那个:
driver.findElement(By.xpath("//button[contains(text(),'I confirm my order')]\"")).click();
使用 Eclipse 作为 Selenium 测试的 IDE 时出现以下错误:
org.openqa.selenium.InvalidSelectorException: invalid selector: Unable to locate an element with the xpath expression //button[contains(text(),'I confirm my order')]" because of the following error:
SyntaxError: Failed to execute 'evaluate' on 'Document': The string '//button[contains(text(),'I confirm my order')]"' is not a valid XPath expression.
【问题讨论】:
标签: java selenium xpath css-selectors webdriverwait