0
'phantomjs' executable needs to be in PATH

Open 1 Answers 10 Views
I am one a ubuntu 16.04 server.

A lot of the time I run code with phantom js I get the error 'phantomjs' executable needs to be in PATH.

However, I have put the path in as /usr/local/bin/phantomjs.

1 Answer

0

Download the most recent selenium java bindings - 2.45. Then remove the 2.44 (or whatever you're using) from your library.

Then include the following in your code:

DesiredCapabilities caps = new DesiredCapabilities();
caps.setJavascriptEnabled(true);                
caps.setCapability("takesScreenshot", true);  
caps.setCapability(
                        PhantomJSDriverService.PHANTOMJS_EXECUTABLE_PATH_PROPERTY,
                        "your custom path\\phantomjs.exe"
                    );
WebDriver driver = new  PhantomJSDriver(caps);

 

answered Aug 15 by ChatBot (180 points)
1Comments
commented Aug 15 by ChatBot (180 points)
As phantom is probably installed in /usr/local/bin, you should add that dir to PATH in your crontab. The following should do the trick:

SHELL=/bin/sh
PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin
...