12

OS: Ubuntu 16.04.3 LTS (GNU/Linux 4.4.0-1066-aws x86_64)

Selenium Version: selenium==3.6.0

Browser: Mozilla Firefox 63.0

Geckodriver version : geckodriver-v0.19.0-linux64

Expected Behavior -

Create a new firefox browser and do some steps - parsing the website.

Actual Behavior -

Crashing with a log :-

    self.driver = webdriver.Firefox()
  File "/home/ubuntu/env/local/lib/python2.7/site-packages/selenium/webdriver/firefox/webdriver.py", line 154, in __init__
    keep_alive=True)
  File "/home/ubuntu/env/local/lib/python2.7/site-packages/selenium/webdriver/remote/webdriver.py", line 151, in __init__
    self.start_session(desired_capabilities, browser_profile)
  File "/home/ubuntu/env/local/lib/python2.7/site-packages/selenium/webdriver/remote/webdriver.py", line 240, in start_session
    response = self.execute(Command.NEW_SESSION, parameters)
  File "/home/ubuntu/env/local/lib/python2.7/site-packages/selenium/webdriver/remote/webdriver.py", line 308, in execute
    self.error_handler.check_response(response)
  File "/home/ubuntu/env/local/lib/python2.7/site-packages/selenium/webdriver/remote/errorhandler.py", line 194, in check_response
    raise exception_class(message, screen, stacktrace)
selenium.common.exceptions.WebDriverException: Message: newSession

Has anyone faced this issue before and has a possible solution ?

UPDATE : Ran the following command : geckodriver --log trace & curl -d '{}' 127.0.0.1:4444/session

Log :- https://pastebin.com/TirTNKrG

das-g
  • 9,718
  • 4
  • 38
  • 80
skyfail
  • 404
  • 1
  • 6
  • 18
  • Never seen this exception before and don't understand what could possibly be the issue. – skyfail Oct 25 '18 at 20:39
  • Try running the geckodriver with trace logging and invoking the "newSession" command manually: geckodriver --log trace &; curl -d '{}' 127.0.0.1:XXXX/session (Replace "XXXX" with the port shown when starting geckodriver) – fzbd Oct 25 '18 at 20:51
  • @fzbd I removed the `;` from the above command you provided. Updated the question. – skyfail Oct 25 '18 at 21:09

3 Answers3

20

I fixed the issue by updating the selenium python package and using the latest geckodriver.

Thanks @fzbd for all your help.

Additional context -

Refer to the compatibility chart here - https://firefox-source-docs.mozilla.org/testing/geckodriver/Support.html#supported-platforms

update selenium :

 pip install -U selenium

update geckodriver (choose the correct version for your needs based on the above compatibility chart)

Check the versions for all components -

firefox -v
geckodriver -V
pip freeze | grep selenium
skyfail
  • 404
  • 1
  • 6
  • 18
12

Thanks @skyfail. Your answer helped me. The following sequence was performed and resolved the issue.

  1. To upgrade selenium run: sudo pip3 install selenium --upgrade

  2. To upgrade geckodriver follow steps 1-3 from this

  3. sudo mv geckodriver /usr/local/bin/geckodriver , /usr/local/bin is usually in your PATH so no need to edit it.
rok
  • 9,403
  • 17
  • 70
  • 126
0

In your log is the following line:

1540501901605 geckodriver ERROR Address in use (os error 98)

Which indicates that the driver is trying to use a port which is already used by some other process. Since the log doesn't show which port it is, you can run the driver with strace:

strace geckodriver 2>&1 | grep -iE 'bind|getsockname'

In my case I get these lines:

bind(3, {sa_family=AF_INET, sin_port=htons(4444), sin_addr=inet_addr("127.0.0.1")}, 16) = 0

getsockname(3, {sa_family=AF_INET, sin_port=htons(4444), sin_addr=inet_addr("127.0.0.1")}, [128->16]) = 0

You can then check which process is using the port (for example):

netstat -tulpn | grep -i 4444 

In my case returning:

tcp 0 0 127.0.0.1:4444 0.0.0.0:* LISTEN 31471/geckodriver

According to a issue about geckodriver port logging, you can let the os allocate a free port:

geckodriver --port 0

If all this doesn't work out, there may an incompatibility between your version of geckodriver and selenium, as this error in the log seems to suggest:

geckodriver::marionette TRACE <- [1,1,{"error":"unknown command","message":"newSession","stacktrace":"WebDriverError@chrome://marionette/content/error.js:178:5

I am using the following versions:

  • firefox 62.0.3
  • geckodriver 0.23.0
  • selenium 3.14.1
Community
  • 1
  • 1
fzbd
  • 477
  • 2
  • 8
  • `netstat -tulpn | grep -i 4444` gives me the same output that you're getting. – skyfail Oct 25 '18 at 21:46
  • Just to rule out other instances of the driver, can you run a `killall geckodriver; killall firefox` and try binding to a different port? If you still hit an unavailable address, `strace` should output `-1 EADDRINUSE (Address already in use)` – fzbd Oct 25 '18 at 21:52
  • I also edited the answer with a possible version incompatibility. – fzbd Oct 25 '18 at 22:03