eclipse org.openqa.selenium 包可以从多个模块访问

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/46834695/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-09 05:43:26  来源:igfitidea点击:

The package org.openqa.selenium is accessible from more than one module

eclipseseleniumselenium-webdriver

提问by Drew Resner

I'm using:

我正在使用:

  • Firefox 56.0.1
  • Selenium 3.6.0
  • Windows 10 home edition
  • Gecko Driver 0.19.0
  • 火狐 56.0.1
  • 硒 3.6.0
  • Windows 10 家庭版
  • 壁虎驱动程序 0.19.0

The error message is

错误信息是

The package org.openqa.selenium is accessible from more than one module: client.combined, net.bytebuddy"

org.openqa.selenium 包可以从多个模块访问:client.combined、net.bytebuddy”

Screenshot of error

错误截图

回答by Kev

This happens when you have added the external jars in the ModulePath.

当您在 ModulePath 中添加外部 jars 时会发生这种情况。

Solution:

解决方案

  1. Remove the external jars from the node "Modulepath".
  2. Select the node "Classpath" then add the external jars.
  3. Review that all the jars are under the node "Classpath".
  1. 从节点“Modulepath”中删除外部 jars。
  2. 选择节点“类路径”,然后添加外部 jar。
  3. 查看所有 jars 都在节点“Classpath”下。

回答by Sergey

I don't know anything about Selenium, but it looks like you have two modules that contain the exact same package name inside of them:

我对 Selenium 一无所知,但看起来您有两个模块,其中包含完全相同的包名称:

  • client.combined
  • net.bytebuddy
  • 客户端组合
  • 网络字节好友

So when you say e.g. import org.openqa.selenium.WebDriverEclipse doesn't know if you want to use that package from client.combinedor from net.bytebuddy.

因此,当您说例如import org.openqa.selenium.WebDriverEclipse 不知道您是否要使用该包 fromclient.combined或 from 时net.bytebuddy

You need to either add a prefix in that import statement that will specify whether you're importing package org.openqa.seleniumfrom client.combinedor from net.bytebuddy.

您需要在该 import 语句中添加一个前缀,该前缀将指定您是org.openqa.seleniumclient.combined还是从导入包net.bytebuddy

You can possibly do this by just doing:

您可以通过执行以下操作来做到这一点:

  • import client.combined.org.openqa.selenium.WebDriver
  • import client.combined.org.openqa.selenium.firefox.FirefoxDriver
  • import client.combined.org.openqa.selenium.WebDriver
  • import client.combined.org.openqa.selenium.firefox.FirefoxDriver

or

或者

  • import net.bytebuddy.org.openqa.selenium.WebDriver
  • import net.bytebuddy.org.openqa.selenium.firefox.FirefoxDriver
  • import net.bytebuddy.org.openqa.selenium.WebDriver
  • import net.bytebuddy.org.openqa.selenium.firefox.FirefoxDriver


You can also try removing either of the packages (client.combinedor net.bytebuddy) from your project

您还可以尝试从项目中删除任何一个包 (client.combinednet.bytebuddy)

回答by Sagar

Add required JAR in class path instead of module path. Also delete unnecessary JARs which might have reference to the mentioned package.

在类路径而不是模块路径中添加所需的 JAR。还要删除可能引用上述包的不必要的 JAR。

回答by user7420004

The problem is that you are adding Jar files to your Modulepath instead of Classpath. Go to Project->BuildPath->Config BuildPath->Remove Jars from Modulepath->then click on classpath->Add external selenium jar files.

问题是您将 Jar 文件添加到模块路径而不是类路径。转到 Project->BuildPath->Config BuildPath->Remove Jars from Modulepath->然后点击 classpath->Add external selenium jar files。

click on the screenshot for more clarity

单击屏幕截图更清晰

回答by BreakTheCode

Add all the required jar files inside classpath instead of module path. The same issue was also occurred with me but after adding the jars to classpath it got resolved.

在类路径而不是模块路径中添加所有必需的 jar 文件。我也发生了同样的问题,但是在将 jars 添加到类路径后它得到了解决。

回答by user8879130

I had the same error and removing the reference to one of the jar files solved the issue. Remove the reference to one of the jar files that you added in java build path.
From the screen shot that you added I see you have reference to both client-combined-3.6.0-sources.jar and client-combined-3.7.0.jar both the packages have the same classes implemented. Remove the reference to one and see if that help.

我遇到了同样的错误,删除对其中一个 jar 文件的引用解决了这个问题。删除对您在 java 构建路径中添加的 jar 文件之一的引用。
从您添加的屏幕截图中,我看到您同时引用了 client-combined-3.6.0-sources.jar 和 client-combined-3.7.0.jar,这两个包都实现了相同的类。删除对一个的引用,看看是否有帮助。

回答by Ertekes Zoltan

I had the same issue. I used JDK 9 and eclipse oxygen 64-bit version (Selenium 3.9.1). My first thought, it is the JDK 9, but I tested on IntelliJ IDEA JDK 9 and worked without any problem. So I installed the eclipse oxygen 32-bit version with JDK 8 (-no JDK 9 version on 32 bit) and the problem disappeared.

我遇到过同样的问题。我使用了 JDK 9 和 eclipse Oxy 64 位版本(Selenium 3.9.1)。我的第一个想法是,它是 JDK 9,但我在 IntelliJ IDEA JDK 9 上进行了测试,并且没有任何问题。所以我用JDK 8(-no JDK 9 version on 32 bit)安装了eclipse Oxygen 32位版本,问题就消失了。

回答by user1276325

this happens when same java package code (package name + class name) is available in more than one jar file; for default modules every jar is exposed as Module. Modules essentially can not have same package name exported. This is more of a code cleanup task.

当相同的 java 包代码(包名 + 类名)在多个 jar 文件中可用时,就会发生这种情况;对于默认模块,每个 jar 都作为模块公开。模块本质上不能导出相同的包名。这更像是一项代码清理任务。