Java “HasInputDevices”位于“/org/openqa/selenium/interactions”但它仍在查看“/org/openqa/selenium/”
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/22763752/
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
"HasInputDevices" is located at "/org/openqa/selenium/interactions" but it is still looking at "/org/openqa/selenium/"
提问by paul
I want to run my WebDriver
test cases on Chrome
on remote Ubuntu
server. I have installed latest Chrome
on that server but I've been getting these errors,when I used this:
我想在远程服务器WebDriver
上运行我的测试用例。我已经在该服务器上安装了最新版本,但是当我使用它时出现了这些错误:Chrome
Ubuntu
Chrome
System.setProperty("webdriver.chrome.driver","/usr/bin/chromedriver");
driver = new ChromeDriver();
Error1:The driver is not executable: /usr/bin/chromedriver
to correct I made it executable using sudo 777 chromedriver
then I got
Error2:
The driver is not executable: /usr/bin/chromedriver
错误1 :为了更正,我使用它使其可执行,sudo 777 chromedriver
然后我得到了
错误2:
org.openqa.selenium.WebDriverException: unknown error: Chrome failed to start: exited abnormally
to fix this I updated selenium jar dependencies
to 2.40.0
and since then, I've been getting
Error3:java.lang.NoClassDefFoundError: org/openqa/selenium/HasInputDevices
Query:Now I know that HasInputDevices
has been moved to org/openqa/selenium/Interactions/
then why it is still looking in old directory path org/openqa/selenium/HasInputDevices
. How to let it find at its actual directory.
1. I have updated dependencies.
2. I have tried to use mvn install
so that it download what is written in pom.xml
but it's looking in old directory.
How to resolve this error, I don't want to downgrade selenium APIs, because then Chrome exits unexpectedly.
org.openqa.selenium.WebDriverException: unknown error: Chrome failed to start: exited abnormally
为了解决这个问题,我更新selenium jar dependencies
了2.40.0
,从那时起,我一直收到
Error3: java.lang.NoClassDefFoundError: org/openqa/selenium/HasInputDevices
Query:Now I know that HasInputDevices
has been move to org/openqa/selenium/Interactions/
then 为什么它仍在旧目录路径中查找org/openqa/selenium/HasInputDevices
。如何让它在其实际目录中找到。
1. 我更新了依赖项。
2.我尝试使用mvn install
它下载写入的内容,pom.xml
但它正在旧目录中查找。
如何解决此错误,我不想降级 selenium API,因为 Chrome 会意外退出。
回答by paul
I found the solution which worked for me. I was using a dependency which had a transitive dependency on selenium-remote-driver version 2.34.0, remove this dependency and it will work.This dependency was:
我找到了对我有用的解决方案。我使用的依赖项对 selenium-remote-driver 版本 2.34.0 具有传递依赖项,删除此依赖项即可正常工作。此依赖项是:
<dependency>
<groupId>com.github.detro.ghostdriver</groupId>
<artifactId>phantomjsdriver</artifactId>
<version>1.1.0</version>
</dependency>
OR
或者
<dependency>
<groupId>com.github.detro.ghostdriver</groupId>
<artifactId>phantomjsdriver</artifactId>
<version>1.0.4</version>
</dependency>
回答by straville
Had a similar problem, getting ClassCastException where HasInputDevices was incompatible with FirefoxDriver.
有一个类似的问题,在 HasInputDevices 与 FirefoxDriver 不兼容的情况下获得 ClassCastException。
Solved by changing the import to another package: From
通过将导入更改为另一个包来解决: 从
import org.openqa.selenium.Mouse;
导入 org.openqa.selenium.Mouse;
To
到
import org.openqa.selenium.interactions.Mouse;
导入 org.openqa.selenium.interactions.Mouse;
The exact error stack I encountered was:
我遇到的确切错误堆栈是:
java.lang.ClassCastException: org.openqa.selenium.firefox.FirefoxDriver cannot be cast to org.openqa.selenium.interactions.HasInputDevices.
java.lang.ClassCastException: org.openqa.selenium.firefox.FirefoxDriver 无法转换为 org.openqa.selenium.interactions.HasInputDevices。
回答by Shell Scott
I had same problem and way to resolve was next: remove all unused dependencies from POM.xml for example if u use only FirefoxDriver and in POM.xml there are anothers one (Chrome, Common, remote) delete them
我遇到了同样的问题,接下来要解决的方法是:从 POM.xml 中删除所有未使用的依赖项,例如,如果你只使用 FirefoxDriver 并且在 POM.xml 中有另一个(Chrome、Common、remote)删除它们