Explore Courses Blog Tutorials Interview Questions
0 votes
in DevOps and Agile by (19.7k points)

I am attempting to run this script:

However, the script fails at the line session = webdriver.PhantomJS() with the following error

Traceback (most recent call last):

  File "", line 236, in <module>

    session = webdriver.PhantomJS()

  File "/home/<user>/.local/lib/python2.7/site-packages/selenium/webdriver/phantomjs/", line 51, in __init__


  File "/home/<user>/.local/lib/python2.7/site-packages/selenium/webdriver/common/", line 69, in start

    os.path.basename(self.path), self.start_error_message)

selenium.common.exceptions.WebDriverException: Message: 'phantomjs' executable needs to be in PATH. 

Exception AttributeError: "'Service' object has no attribute 'process'" in <bound method Service.__del__ of <selenium.webdriver.phantomjs.service.Service object at 0x7f6f632864d0>> ignored

How do I add phantomjs to my PATH? I am running ubuntu 16.04 and installed selenium via npm install selenium.

1 Answer

0 votes
by (62.9k points)

I solved the same problem with this command in the command-line interface

export PATH=${PATH:+$PATH:}/home/<login>/phantomjs/bin

It's work if /home/login/phantomjs/bin is the path for folder with executable 'phantomjs'.

If you are interested to learn Selenium on a much deeper level and want to become a professional in the testing domain, you should enroll yourself in industry-based Selenium online courses!

Welcome to Intellipaat Community. Get your technical queries answered by top developers!

30.5k questions

32.6k answers


108k users

Browse Categories