2016-07-26 64 views
0

我想加載像下面的幻像js。如何配置Phantomjs驅動程序在linux機器上使用java執行?

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 

回答

0

但如果你想用絕對路徑有它

文件phantomJSBinary =新的文件(「路徑」 +文件.separator +「to」+ File.separator +「phantomjs」); DesiredCapabilities caps = new DesiredCapabilities(); caps.setCapability(PhantomJSDriverService.PHANTOMJS_EXECUTABLE_PATH_PROPERTY,phantomJSBinary.getAbsolutePath());

相關問題