java.lang.IllegalStateException:驱动程序可执行文件不存在

java.lang.IllegalStateException:驱动程序可执行文件不存在,java,selenium,phantomjs,openshift,openshift-client-tools,Java,Selenium,Phantomjs,Openshift,Openshift Client Tools,我正试图在Openshift服务器上运行一个phantomjs程序 但是我从一个月的中得到了这个错误:( 错误: java.lang.IllegalStateException: The driver executable does not exist: /var/lib/openshift/54eb79134382ecc76d00002b/app-root/data/Phantomjs-1.9.8-linux-x86_64/bin/phantomjs com.google.common

我正试图在
Openshift
服务器上运行一个phantomjs程序

但是我从一个月的
中得到了这个错误:(

错误:

java.lang.IllegalStateException: The driver executable does not exist: /var/lib/openshift/54eb79134382ecc76d00002b/app-root/data/Phantomjs-1.9.8-linux-x86_64/bin/phantomjs
    com.google.common.base.Preconditions.checkState(Preconditions.java:197)
    org.openqa.selenium.remote.service.DriverService.checkExecutable(DriverService.java:117)
    org.openqa.selenium.phantomjs.PhantomJSDriverService.findPhantomJS(PhantomJSDriverService.java:246)
    org.openqa.selenium.phantomjs.PhantomJSDriverService.createDefaultService(PhantomJSDriverService.java:182)
    org.openqa.selenium.phantomjs.PhantomJSDriver.<init>(PhantomJSDriver.java:99)
    org.apache.jsp.doThatTask_jsp._jspService(doThatTask_jsp.java:87)
    org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:70)
    javax.servlet.http.HttpServlet.service(HttpServlet.java:727)
    org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:432)
    org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:390)
    org.apache.jasper.servlet.JspServlet.service(JspServlet.java:334)
    javax.servlet.http.HttpServlet.service(HttpServlet.java:727)
    org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:52)

为什么每次在服务器上都会出现此错误?

在System.getenv()中传递参数时,似乎找不到您的驱动程序。请仔细检查该位置并确保驱动程序可执行文件在那里。

检查您是否有权读取/var/lib/openshift/54eb79134382ecc76d0002b/app root/data/Phantomjs-1.9.8-linux-x86_64/bin/Phantomjs目录

试试这段代码它对我有用:

DesiredCapabilities caps = new DesiredCapabilities();
    caps.setJavascriptEnabled(true);

    caps.setCapability(PhantomJSDriverService.PHANTOMJS_EXECUTABLE_PATH_PROPERTY, "D:\\phantomjs-2.0.0-windows\\bin\\phantomjs.exe");

    WebDriver driver = new PhantomJSDriver(caps);
    driver.manage().timeouts().pageLoadTimeout(2000, TimeUnit.SECONDS);


    driver.get("https://github.com/detro/ghostdriver");

    System.out.println(driver.getTitle());
DesiredCapabilities caps = new DesiredCapabilities();
    caps.setJavascriptEnabled(true);

    caps.setCapability(PhantomJSDriverService.PHANTOMJS_EXECUTABLE_PATH_PROPERTY, "D:\\phantomjs-2.0.0-windows\\bin\\phantomjs.exe");

    WebDriver driver = new PhantomJSDriver(caps);
    driver.manage().timeouts().pageLoadTimeout(2000, TimeUnit.SECONDS);


    driver.get("https://github.com/detro/ghostdriver");

    System.out.println(driver.getTitle());