【发布时间】:2021-12-09 05:23:09
【问题描述】:
我正在使用适用于 Chrome 的 Katalon 插件,效果很好。但我想用 Java 中的 Selenium 创建一个小应用程序来做类似的事情。我遇到了在 Chrome 上与 Katalon 一起使用的 xpath 的问题,但是当我在 Selenium 的 Java 应用程序中使用它时它不起作用。
这是来自 Katalon 的 xpath:
xpath=(.//*[normalize-space(text()) and normalize-space(.)='Incorrect: Type your incorrect message here'])[1]/following::label[1]
这就是我在 Java 中与 Selenium 一起使用的:
WebElement el = driver_1.findElement(By.xpath("(.//*[normalize-space(text()) and normalize-space(.)=\'Incorrect: Type your incorrect message here\'])[1]/following::label[1]"));
返回:
Exception in thread "AWT-EventQueue-0" org.openqa.selenium.NoSuchElementException: no such element: Unable to locate element:
【问题讨论】:
-
你能从浏览器复制xpath并粘贴到这里吗?