我在.bat文件中有这个:
java -jar untitled1.jar
pause
但运行时出现此错误:
Exception in thread "main" java.lang.NoClassDefFoundError: org/openqa/selenium/phantomjs/PhantomJSDriver
at a.main.main(main.java:18)
Caused by: java.lang.ClassNotFoundException: org.openqa.selenium.phantomjs.PhantomJSDriver
at java.net.URLClassLoader.findClass(URLClassLoader.java:381)
at java.lang.ClassLoader.loadClass(ClassLoader.java:424)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:331)
at java.lang.ClassLoader.loadClass(ClassLoader.java:357)
从IDE运行时,我没有收到此错误。
这是我认为错误来自的地方。
DesiredCapabilities DesireCaps = new DesiredCapabilities();
DesireCaps.setCapability(PhantomJSDriverService.PHANTOMJS_EXECUTABLE_PATH_PROPERTY, "C:\\Users\\Skid\\IdeaProjects\\untitled1\\out\\artifacts\\untitled1_jar\\phantomjs.exe");
WebDriver driver = new PhantomJSDriver(DesireCaps);