java.lang.NoClassDefFoundError: org/openqa/selenium/remote/SessionNotFoundException
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/36698363/
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
java.lang.NoClassDefFoundError: org/openqa/selenium/remote/SessionNotFoundException
提问by rich
I am using Firefox 45.0 and Dependency added in pom.xml
is
selenium-firefox-driver 2.53.0
.
我正在使用 Firefox 45.0 并且添加了依赖项pom.xml
是
selenium-firefox-driver 2.53.0
.
java.lang.NoClassDefFoundError: org/openqa/selenium/remote/SessionNotFoundException
at TestFIles_MDM.Test_Authn.setup(Test_Authn.java:27)
Error is coming for both Firefox and Chrome.
Firefox 和 Chrome 都会出错。
How can I resolve it, it was working last week.
我该如何解决它,它上周工作。
回答by Kiril S.
I think you are missing this dependency in pom.xml:
我认为您在 pom.xml 中缺少此依赖项:
<dependency>
<groupId>org.seleniumhq.selenium</groupId>
<artifactId>selenium-java</artifactId>
<version>2.53.0</version>
</dependency>
回答by Shivam
Voila, It's worked for me.Just updated the selenium-java dependency in pom.xml
瞧,它对我有用。刚刚更新了 pom.xml 中的 selenium-java 依赖项
<!-- Selenium java-jar dependency -->
<dependency>
<groupId>org.seleniumhq.selenium</groupId>
<artifactId>selenium-java</artifactId>
<version>2.53.1</version>
</dependency>
Or here is the link to get the updated version- https://mvnrepository.com/artifact/org.seleniumhq.selenium/selenium-java
或者这里是获取更新版本的链接 - https://mvnrepository.com/artifact/org.seleniumhq.selenium/selenium-java
回答by BS_CC
This happened with me while trying to update to remote driver to 3.0.1 from 2.53.1. I just reverted it back to 2.53.1 and it went away
这发生在我尝试从 2.53.1 更新到 3.0.1 的远程驱动程序时。我只是将它恢复到 2.53.1 并且它消失了
<dependency>
<groupId>org.seleniumhq.selenium</groupId>
<artifactId>selenium-remote-driver</artifactId>
<version>2.53.1</version>
</dependency>
回答by Chris
Run mvn dependency:tree
in your project, and check what is transitively depending on selenium-remote-driver
.
mvn dependency:tree
在您的项目中运行,并检查依赖于selenium-remote-driver
.
In my project, I was correctly depending on selenium-java
at 2.53.1
, but another test dependency was depending on an older version (2.40.0); that meant my tests were using the 2.40.0
version of selenium-remote-driver
at runtime, which causes the java.lang.NoClassDefFoundError: org/openqa/selenium/remote/SessionNotFoundException
error.
在我的项目中,我正确地依赖于selenium-java
at 2.53.1
,但另一个测试依赖依赖于旧版本(2.40.0);这意味着我的测试使用的2.40.0
是selenium-remote-driver
运行时的版本,这会导致java.lang.NoClassDefFoundError: org/openqa/selenium/remote/SessionNotFoundException
错误。
If you have transitive dependencies on selenium-remote-driver
, you have two options for "fixing" them:
如果您对 有传递依赖关系selenium-remote-driver
,则有两个选项可以“修复”它们:
- Update the artifact that's depending on the older version to either
- Not depend on the artifact at all, or
- Use the latest version.
Add an entry in your
pom.xml
's<dependencyManagement>
section forselenium-java
to peg the artifact at version2.53.1
.This will affect the version of
selenium-java
both in your project and all your nested maven dependencies, too; be aware that those nested artifacts may not work well with the latest version!
- 将依赖于旧版本的工件更新为
- 完全不依赖于工件,或者
- 使用最新版本。
在您
pom.xml
的<dependencyManagement>
部分中添加一个条目,selenium-java
以便将工件固定在 version 上2.53.1
。这也会影响
selenium-java
项目和所有嵌套 Maven 依赖项中的版本;请注意,这些嵌套工件可能不适用于最新版本!
It's also worth mentioning that selenium-java
version 2.53.0
had a Firefox incompatibility problem; version 2.53.1
allegedly fixes that. See http://seleniumsimplified.com/2016/06/use_selenium_webdriver_jar_locally/for more details.
还值得一提的是,该selenium-java
版本2.53.0
存在 Firefox 不兼容问题;2.53.1
据称版本修复了这个问题。有关更多详细信息,请参阅http://seleniumsimplified.com/2016/06/use_selenium_webdriver_jar_locally/。
Hope this helps :)
希望这可以帮助 :)
回答by Hyman west
I ran into this too. I changed to the following and it went away.
我也遇到了这个。我更改为以下内容,它消失了。
<dependency>
<groupId>org.seleniumhq.selenium</groupId>
<artifactId>selenium-server</artifactId>
<version>4.0.0-alpha-2</version>
</dependency>
<dependency>
<groupId>io.appium</groupId>
<artifactId>java-client</artifactId>
<version>6.1.0</version>
<scope>provided</scope>
</dependency>