Search code examples
pythonseleniumsplinter

Selenium: browser.visit(url) fails on linux but works on windows


I am running a simple splinter (uses selenium) script which does

browser.visit(url)

On my windows machine, the python script runs fine. However, on my linux server, the script will not run. It immediately stops at above and crashes.

  File "<stdin>", line 1, in <module>
  File "test.py", line 57, in run
    browser.visit(url)
  File "/usr/local/lib/python2.7/dist-packages/splinter/driver/webdriver/__init__.py", line 53, in visit
    self.connect(url)
  File "/usr/local/lib/python2.7/dist-packages/splinter/request_handler/request_handler.py", line 23, in connect
    self._create_connection()
  File "/usr/local/lib/python2.7/dist-packages/splinter/request_handler/request_handler.py", line 48, in _create_connection
    self.conn = http_client.HTTPConnection(self.host, self.port)
  File "/usr/lib/python2.7/httplib.py", line 693, in __init__
    self._set_hostport(host, port)
  File "/usr/lib/python2.7/httplib.py", line 712, in _set_hostport
    i = host.rfind(':')
AttributeError: 'NoneType' object has no attribute 'rfind'

Solution

  • (this answer is here only to close the question.)

    You were using:

    http:/
    

    Inside if your browser.visit method.. You forgot the ending slash!

    http://