I am getting below error while executing tests on PhantomJS.


Traceback (most recent call last):
  File "C:\Python34\lib\site-packages\selenium\webdriver\common\service.py", lin
e 64, in start
    stdout=self.log_file, stderr=self.log_file)
  File "C:\Python34\lib\subprocess.py", line 848, in __init__
    restore_signals, start_new_session)
  File "C:\Python34\lib\subprocess.py", line 1104, in _execute_child
FileNotFoundError: [WinError 2] The system cannot find the file specified

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "barchart.py", line 7, in <module>
    driver = webdriver.PhantomJS(r'C:\Users\abdurrub\Anaconda3\Scripts\phantomjs
.exe',service_args=['--ignore-ssl-errors=true', '--ssl-protocol=any'])
  File "C:\Python34\lib\site-packages\selenium\webdriver\phantomjs\webdriver.py"
, line 52, in __init__
  File "C:\Python34\lib\site-packages\selenium\webdriver\common\service.py", lin
e 71, in start
    os.path.basename(self.path), self.start_error_message)
selenium.common.exceptions.WebDriverException: Message: 'phantomjs.exe' executab
le needs to be in PATH

Exception ignored in: <bound method Service.__del__ of <selenium.webdriver.phant
omjs.service.Service object at 0x02104890>>
Traceback (most recent call last):
  File "C:\Python34\lib\site-packages\selenium\webdriver\common\service.py", lin
e 163, in __del__
  File "C:\Python34\lib\site-packages\selenium\webdriver\common\service.py", lin
e 135, in stop
    if self.process is None:
AttributeError: 'Service' object has no attribute 'process'

by (202 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.

Your answer

Your name to display (optional):
Privacy: Your email address will only be used for sending these notifications.
Anti-spam verification:
To avoid this verification in future, please log in or register.

1 Answer

by (171 points)
0 votes
  • Download PhantomJS binary from http://phantomjs.org/
  • Extract zip file and add it to System PATH. 
  • If you do not add PhantomJS.exe binary to the System PATH variable you can even use as below.
browser = webdriver.PhantomJS(executable_path='C:\Phantom\phantomjs-2.0.0-windows\bin\phantomjs.exe')