selenium + PhantomJS- quick fix - troubleshoot

selenium + PhantomJS- quick fix - troubleshoot


Job Description

I'm trying to run PhantomJS from within selenium.webdriver on a Centos server. PhantomJS is in the path and is running properly from terminal. However in the script it appears to be launched, but afterwards cannot be reached on the specified port (I tried 2 different opened ports from my provider 29842 and 60099, they both are not working and neither launching it without a specified port).

The error happens here in selenium.webdriver.common.utils:

socket_ = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
socket_.connect(("localhost", port))
return True
except socket.error:
return False

This is from my script (I tried without any parameters as well as writing the complete path to the executable and neither worked):

self.browser = webdriver.PhantomJS(
'javascriptEnabled': True,
'platform': 'windows',
'browserName': 'Mozilla',
'version': '5.0',
'': "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_8_4) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/29.0.1547.57 Safari/537.36"

And this the script that initialises the webdriver from selenium.webdriver.phantomjs.service. I checked and subprocess.Popen actually lauches phantomjs, the error happens in the while loop:


All the packages are the latest version: python 2.7, selenium 2 and phantomjs 1.9 binary with ghostdriver integrated. I made the same script work properly on my Ubuntu local machine, doing exactly the same things I did on the server. What is different on the server?

Other open jobs by this client