3

Disclaimer

This is my first time using stack overflow, and I'm relatively new to coding, so if I've missed any important info, or not done something 'properly' feel free to let me know.

The Problem

I've just installed selenium using pip3 install selenium which all went fine, I imported everything as I believe I'm supposed to.

import selenium
from selenium import webdriver

To test I then added default_browser = webdriver.Firefox() But unfortunately met this error:

Traceback (most recent call last):
  File "/home/kali/Documents/coding/ProjectName/main.py", line 4, in <module>
    default_browswer = webdriver.Firefox()
  File "/home/kali/.local/lib/python3.8/site-packages/selenium/webdriver/firefox/webdriver.py", line 170, in __init__
    RemoteWebDriver.__init__(
  File "/home/kali/.local/lib/python3.8/site-packages/selenium/webdriver/remote/webdriver.py", line 157, in __init__
    self.start_session(capabilities, browser_profile)
  File "/home/kali/.local/lib/python3.8/site-packages/selenium/webdriver/remote/webdriver.py", line 252, in start_session
    response = self.execute(Command.NEW_SESSION, parameters)
  File "/home/kali/.local/lib/python3.8/site-packages/selenium/webdriver/remote/webdriver.py", line 321, in execute
    self.error_handler.check_response(response)
  File "/home/kali/.local/lib/python3.8/site-packages/selenium/webdriver/remote/errorhandler.py", line 242, in check_response
    raise exception_class(message, screen, stacktrace)
selenium.common.exceptions.WebDriverException: Message: newSession

I've tried following the steps from this stack overflow question, including:

  1. Trying to update selenium using pip3 install -U selenium AND sudo pip3 install selenium --upgrade
  2. I've upgraded geckodriver by following the steps 1-3 from here, and then replacing step 4 with sudo mv geckodriver /usr/local/bin/geckodriver
  3. Troubleshooting geckodriver using multiple ports by running: `strace geckodriver 2>&1 | grep -iE 'bind|getsockname' which returned
bind(3, {sa_family=AF_INET, sin_port=htons(4444), sin_addr=inet_addr("127.0.0.1")}, 16) = -1 EADDRINUSE (Address already in use)

I then ran netstat -tulpn | grep -i 4444 which returned:

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

This apparently meant that I need to let the OS allocate a free port: geckodriver --port 0 which returned:

1605300277587   geckodriver INFO    geckodriver 0.19.1
1605300277592   geckodriver INFO    Listening on 127.0.0.1:37399

After this the terminal continues to run and doesn't give me back my xyz:~$: thing.

None of this has made any difference whatsoever to my issue, and I can't really find any other resources that are related, so if anyone knows what I could try, I'd appreciate it.

bamishr
  • 410
  • 1
  • 6
  • 23

0 Answers0