无法使用 Selenium 和 Java 11 导入 org.openqa.selenium.WebDriver

Unable to import org.openqa.selenium.WebDriver using Selenium and Java 11

我是 selenium webdriver 和 java 编程的新手。尝试解决 eclipse 2018-12 "The import org.openqa.selenium.WebDriver cannot be resolved" Im 使用 java 11, selenium standalone server 3.141.59 中的错误。请帮忙。我无法导入 jar 文件下面是屏幕截图

根据 Can't compile Java9 module with selenium-java as dependency 看来 Selenium 包不能用 Java 9 编译,因为拆分包 直到 2018 年 5 月 15 日 Selenium 与 Java 9.

不完全兼容

但是根据这个 comment @Jarob22 提到的,Selenium 使用 Java 10 工作得很好。 Java 9 已经停产了,如果 10 有效,添加额外的东西来尝试和支持它没有多大意义。

但是随着e57914a Simon introduced us with basic JPMS support. With this availability (mhomnag/selenium-java10-reproducer@bc63889) now actually builds but you may have to Remove the WebDriverWaiter and just use a sleep for now的登陆。


Java11

当您使用 java.version: '11.0.1', selenium-server-standalone-3.141.59.jar 仍然与 Java 11 不兼容。但是一旦 Java 11 发布并且 Buck 支持它,工具链将被重新调整以支持 Java 11.


解决方案

战略解决方案是安装最新版本的 JDK 8u212 并执行 @Tests