Selenium Python Headless Webdriver (PhantomJS) Not Working

cdfh :

So I'm having trouble getting selenium to work with a headless driver, specifically PhantomJS. I'm trying to get it to work on an Ubuntu webserver (Ubuntu 14.04.2 LTS).

Running the following commands from a python interpreter (Python 2.7.6) gives:

from selenium import webdriver
driver = webdriver.PhantomJS()

Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/usr/local/lib/python2.7/dist-packages/selenium/webdriver/phantomjs/webdriver.py", line 51, in __init__
    self.service.start()
  File "/usr/local/lib/python2.7/dist-packages/selenium/webdriver/phantomjs/service.py", line 76, in start
    raise WebDriverException("Unable to start phantomjs with ghostdriver: %s" % e)
selenium.common.exceptions.WebDriverException: Message: Unable to start phantomjs with ghostdriver: [Errno 2] No such file or directory

I've also tried:

driver = webdriver.PhantomJS(executable_path="/usr/local/lib/python2.7/dist-packages/selenium/webdriver/phantomjs/")

Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/usr/local/lib/python2.7/dist-packages/selenium/webdriver/phantomjs/webdriver.py", line 51, in __init__
    self.service.start()
  File "/usr/local/lib/python2.7/dist-packages/selenium/webdriver/phantomjs/service.py", line 76, in start
    raise WebDriverException("Unable to start phantomjs with ghostdriver: %s" % e)
selenium.common.exceptions.WebDriverException: Message: Unable to start phantomjs with ghostdriver: [Errno 13] Permission denied

I also added it to the python path:

import sys
sys.path.append("/usr/local/lib/python2.7/dist-packages/selenium/webdriver/phantomjs/")

I am currently logged in as root. Permissions for the phantomjs directory are:

drwxr-sr-x  2 root staff 4096 Sep  9 06:58 phantomjs

and for phantomjs/webdriver.py:

-rw-r--r--  1 root root  2985 Sep  9 06:58 webdriver.py

I've confirmed selenium is installed and up-to-date (pip install selenium --upgrade). It is installed at:

/usr/local/lib/python2.7/dist-packages/selenium/webdriver/phantomjs/

print selenium.__version__
2.47.1

I've looked at:

I've been testing my program on a locally hosted server (on OSX), using chromedriver. I'm actually using Splinter (https://splinter.readthedocs.org/en/latest/#headless-drivers) for that, and have tried the other headless drivers (django and zope.testbrowser) but have had similar issues.

I'm open to any suggestions, I don't mind changing driver if required.

Thanks in advance for any help.

Lukasz Dynowski :

I had the same problem as you with the same errors. I have tried to install it on openSuse Server. I ended up installing PhantomJS form source -unfortunately without any success. The way that worked for me was installing Phantomjs via npm

sudo npm install -g phantomjs

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

Using PhantomJS for headless browser in Selenium - Python

headless option not working selenium python

--headless is not an option in chrome webdriver for selenium python

Trouble connecting to phantomJs webdriver using python and selenium

python proxy in selenium firefox headless not working

Python Selenium Chromedriver not working with --headless option

Selenium Python Paste Not Working in Headless Mode

PhantomJS 2.5.0-beta for Selenium WebDriver not working in Linux

Selenium Webdriver python XPath not working

python selenium webdriver click() not working

Selenium webdriver: Click not working in python

clickAndHold is not working in Selenium webdriver (python)

PhantomJS WebDriver headless: ".click" Method has no effect

phantomjs + selenium in python proxy-auth not working

python selenium phantomJS new tab not working

Running Selenium with Headless Chrome Webdriver

Headless automation with Nodejs Selenium Webdriver

how to handle alerts in selenium with phantomjs headless browser

How to enable PhantomJS WebDriver in Selenium?

phantomjs and selenium - webdriver does not work

Send keys not working selenium webdriver python

Selenium webdriver is not working in Python. (chromedriver 115.0.5790.171)

Python Selenium Headless download

Selenium working with Chrome, but not headless Chrome

Headless Selenium suddenly stopped working

headless mode on firefox in selenium webdriver does not respond

Selenium webdriver doesnt work in headless mode

upload file by Chrome File Upload dialog using selenium webdriver in headless mode in python

Selenium Safari WebDriver Not Working