如何配置Phantomjs驱动程序使用java在linux机器上执行?

时间:2016-07-26 17:08:44

标签: java selenium-webdriver phantomjs

我正在尝试加载幻像js,如下所示。

File file = new File("src/test/resources/phantomjs-linux");             
System.setProperty("phantomjs.binary.path", file.getAbsolutePath());    

当我在linux机器上执行此操作时,获得以下异常:

java.lang.IllegalStateException: The driver is not executable: /home/tomcat-jenkins/workspace/pitchIT/pitchIT-services/src/test/resources/phantomjs-linux
    at com.google.common.base.Preconditions.checkState(Preconditions.java:199)
    at org.openqa.selenium.remote.service.DriverService.checkExecutable(DriverService.java:121)
    at org.openqa.selenium.phantomjs.PhantomJSDriverService.findPhantomJS(PhantomJSDriverService.java:246)
    at org.openqa.selenium.phantomjs.PhantomJSDriverService.createDefaultService(PhantomJSDriverService.java:182)
    at org.openqa.selenium.phantomjs.PhantomJSDriver.<init>(PhantomJSDriver.java:99)
    at org.openqa.selenium.phantomjs.PhantomJSDriver.<init>(PhantomJSDriver.java:89)
    at com.astrazeneca.als.pitchIT.util.BDDUtilities.doInit(BDDUtilities.java:69)
    at com.astrazeneca.als.pitchIT.util.BDDUtilities.getDriver(BDDUtilities.java:33)
    at com.astrazeneca.als.pitchIT.controller.PitchITHomepageSteps.an_browser_win

1 个答案:

答案 0 :(得分:0)

但是如果你想拥有绝对路径

文件phantomJSBinary =新文件(&#34;路径&#34; + File.separator +&#34;到&#34; + File.separator +&#34; phantomjs&#34;);         DesiredCapabilities caps = new DesiredCapabilities();         caps.setCapability(PhantomJSDriverService.PHANTOMJS_EXECUTABLE_PATH_PROPERTY,phantomJSBinary.getAbsolutePath());