2

这是最小的复制

我正在使用 Eclipse Version: 2019-03 M1 (4.11.0 M1)Build id: 20190117-2133

有问题的 jar 是 Selenium,但它们是主项目中唯一的多版本 jar,所以我认为这可能是问题的一部分

基本上,Eclipse 在构建时出错

selenium.firefox.driver cannot be resolved to a module

并且该模块下的所有类的导入都会给出错误

The import org.openqa.selenium cannot be resolved

或者它的一些变体。有时是org它声称无法解决

重要的是,这确实在 Maven 下成功编译

4

1 回答 1

1

您可以将 Selenium 与 Java 11 一起使用。只需从 module_info.java 中删除 Selenium 并将其用作附加的 jar 文件即可。

如果要将 Selenium 用作 Java 模块,则必须编辑项目设置并将 Selenium 添加到 Modulepath 中,如下所示:

Eclipse 模块路径设置

不幸的是,Maven 插件似乎在 Eclipse 项目更新期间忽略了这一点(不仅仅是 Selenium)。

为了解决这个问题,我还必须修改 module-info.java:

module browserAutomation{

  requires org.openqa.selenium.core;
  requires org.openqa.selenium.firefox;

}

这对应于https://github.com/SeleniumHQ/selenium/tree/master/java/client/src/org/openqa/selenium的源代码

于 2019-02-03T10:27:28.860 回答