I am getting an “exception in thread ”main“ java.lang.NoClassDefFoundError: org/openqa/selenium/WebDriver”

Deadly 提交于 2019-12-07 21:41:51

问题


I have added selenium-standalone.jar & selenium-java.jar but still I am getting the following exception when running the basic program,

Exception in thread "main" java.lang.NoClassDefFoundError: org/openqa/selenium/WebDriver (wrong name: org/openqa/selenium/Webdriver) at java.lang.ClassLoader.defineClass1(Native Method) at java.lang.ClassLoader.defineClass(ClassLoader.java:791) at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:142) at java.net.URLClassLoader.defineClass(URLClassLoader.java:449) at java.net.URLClassLoader.access$100(URLClassLoader.java:71) at java.net.URLClassLoader$1.run(URLClassLoader.java:361) at java.net.URLClassLoader$1.run(URLClassLoader.java:355) at java.security.AccessController.doPrivileged(Native Method) at java.net.URLClassLoader.findClass(URLClassLoader.java:354) at java.lang.ClassLoader.loadClass(ClassLoader.java:423) at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:308) at java.lang.ClassLoader.loadClass(ClassLoader.java:356) at java.lang.Class.getDeclaredMethods0(Native Method) at java.lang.Class.privateGetDeclaredMethods(Class.java:2442) at java.lang.Class.getMethod0(Class.java:2685) at java.lang.Class.getMethod(Class.java:1620) at sun.launcher.LauncherHelper.getMainMethod(LauncherHelper.java:488) at sun.launcher.LauncherHelper.checkAndLoadMain(LauncherHelper.java:480)

Please provide the solution with proper steps to resolve this


回答1:


This is where a dependency manager (like Maven) can help you, versus manual copying of libs.

org.openqa.selenium.WebDriver can be found in selenium-api-<version>.jar

You will likely also need: selenium-remote-driver-<version>.jar and probably also selenium-support-<version>.jar, in addition to the selenium-java-<version>.jar you already have.




回答2:


I am expecting good to use only one either standalone or java specific jars. Please give try by using only selenium-server-standalone-2.xx.0.jar i hope its works fine.

If you are trying to use java specific jars please provide all jars in downloaded zip file instead only that selenium-java.jar file. If you add all jar files in downloaded zip i hope this issue will resolved.

Thank You, Murali



来源:https://stackoverflow.com/questions/36111011/i-am-getting-an-exception-in-thread-main-java-lang-noclassdeffounderror-org

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!