Checkout our demo site to practice selenium https://magento.softwaretestingboard.com/

0 like 0 dislike
1.5k views
by The go-to Tester (222 points)
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 like 0 dislike
by The go-to Tester (222 points)

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);

 

by The go-to Tester (222 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


This site is for software testing professionals, where you can ask all your questions and get answers from 1300+ masters of the profession. Click here to submit yours now!

1.4k questions

1.6k answers

866 comments

1.9k users

...