当我这样做时,在Intellij中我没有遇到任何问题
public class main {
public static void main(String[] args) throws IOException {
DesiredCapabilities DesireCaps = new DesiredCapabilities();
DesireCaps.setCapability("phantomjs.binary.path", "phantomjs.exe");
PhantomJSDriver driver = new PhantomJSDriver(DesireCaps);
driver.get("https://google.com");
}
}
但是当我构建它时会抛出此错误
Exception in thread "main" java.lang.NoClassDefFoundError: org/openqa/selenium/phantomjs/PhantomJSDriver
at a.main.main(main.java:34)
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)
... 1 more