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

1 like 0 dislike
2.0k views
by

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
    startupinfo)
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__
    self.service.start()
  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__
    self.stop()
  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 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 (181 points)
  • 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')

 


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

...