我正在使用phantomjs 1.4.0版本,该版本抛出以下错误: ava.lang.IllegalAccessError:尝试从类org.openqa.selenium.phantomjs.PhantomJSDriverService访问类org.openqa.selenium.os.ExecutableFinder 在org.openqa.selenium.phantomjs.PhantomJSDriverService.findPhantomJS(PhantomJSDriverService.java:232)〜[phantomjsdriver-1.4.0.jar:1.4.0] 在org.openqa.selenium.phantomjs.PhantomJSDriverService.createDefaultService(PhantomJSDriverService.java:181)〜[phantomjsdriver-1.4.0.jar:1.4.0] 在org.openqa.selenium.phantomjs.PhantomJSDriver。(PhantomJSDriver.java:105)〜[phantomjsdriver-1.4.0.jar:1.4.0] 在com.techm.mots.service.ApplicationServiceImpl.getAppDetailsandInterfacesByMotsId(ApplicationServiceImpl.java:57)〜[classes /:na] 在com.techm.mots.controllers.ApplicationController.getAppDetailsandInterfacesByMotsId(ApplicationController.java:20)〜[classes /:na] 在sun.reflect.NativeMethodAccessorImpl.invoke0(本机方法)〜[na:1.8.0_151] 在sun.reflect.NativeMethodAccessorImpl.invoke(未知来源)〜[na:1.8.0_151] 在sun.reflect.DelegatingMethodAccessorImpl.invoke(未知来源)〜[na:1.8.0_151] 在java.lang.reflect.Method.invoke(未知来源)〜[na:1.8.0_151] 在org.springframework.web.method.support.InvocableHandlerMethod.doInvoke(InvocableHandlerMethod.java:205)〜[spring-web-4.3.24.RELEASE.jar:4.3.24.RELEASE] 在org.springframework.web.method.support.InvocableHandlerMethod.invokeForRequest(InvocableHandlerMethod.java:133)〜[spring-web-4.3.24.RELEASE.jar:4.3.24.RELEASE] 在org.springframework.web.servlet.mvc.method.annotation.ServletInvocableHandlerMethod.invokeAndHandle(ServletInvocableHandlerMethod.java:97)〜[spring-webmvc-4.3.24.RELEASE.jar:4.3.24.RELEASE] 在org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter.invokeHandlerMethod(RequestMappingHandlerAdapter.java:854)〜[spring-webmvc-4.3.24.RELEASE.jar:4.3.24.RELEASE] 在org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter.handleInternal(RequestMappingHandlerAdapter.java:765)〜[spring-webmvc-4.3.24.RELEASE.jar:4.3.24.RELEASE] 在org.springframework.web.servlet.mvc.method.AbstractHandlerMethodAdapter.handle(AbstractHandlerMethodAdapter.java:85)〜[spring-webmvc-4.3.24.RELEASE.jar:4.3.24.RELEASE] 在org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:967)〜[spring-webmvc-4.3.24.RELEASE.jar:4.3.24.RELEASE] 在org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:901)〜[spring-webmvc-4.3.24.RELEASE.jar:4.3.24.RELEASE] 在org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:970)〜[spring-webmvc-4.3.24.RELEASE.jar:4.3.24.RELEASE] 在org.springframework.web.servlet.FrameworkServlet.doPost(FrameworkServlet.java:872)〜[spring-webmvc-4.3.24.RELEASE.jar:4.3.24.RELEASE] 在javax.servlet.http.HttpServlet.service(HttpServlet.java:661)〜[tomcat-embed-core-8.5.40.jar:8.5.40]
///无头驱动程序的对象/变量的声明和实例化:PhantonJS
/*File file = new File("D:/rc00484303/ATT/Selenium Drivers/phantomExe/phantomjs.exe");*/
/*File file = new File("/home/m33914/Consolidator/apache-tomcat-8.0.36/bin/phantomjs.exe");*/
/*System.setProperty("phantomjs.binary.path", file.getAbsolutePath());*/
System.setProperty("phantomjs.binary.path", "phantomjs.exe");
String[] phantomArgs = new String[] { "--webdriver-loglevel=NONE" };
DesiredCapabilities capabilities = new DesiredCapabilities();
capabilities.setCapability(PhantomJSDriverService.PHANTOMJS_CLI_ARGS, phantomArgs);
capabilities.setJavascriptEnabled(true);
capabilities.setCapability("takesScreenshot", true);
PhantomJSDriver driver = new PhantomJSDriver(capabilities);
driver.manage().timeouts().implicitlyWait(180, TimeUnit.SECONDS);
错误:java.lang.IllegalAccessError:试图从类org.openqa.selenium.phantomjs.PhantomJSDriverService访问类org.openqa.selenium.os.ExecutableFinder 任何线索都将受到高度赞赏。