Page 1 of 1

[Python] selenium webdriver help

Posted: 2023-11-14 04:47
by ramack
Hi,
I'm needing help from you Python pros....I've got a pretty basic/simple Python script that scrapes a website and modifies some stuff in my account. The script works with Python2, but I'm wanting to get it to work in the python3 environment. I switch to python2 by:
$ sudo -s update-alternatives --config python
and selecting option 1.

After a bit of troubleshooting, I've narrowed it down to something with selenium and firefox. Just executing select commands from IDLE causes the firefox related errors below.

Code: Select all

import time, os, datetime, selenium
from selenium import webdriver
from selenium.webdriver.common.keys import Keys

driver = webdriver.Firefox()
Traceback (most recent call last):
  File "<pyshell#3>", line 1, in <module>
    driver = webdriver.Firefox()
  File "/usr/lib/python3/dist-packages/selenium/webdriver/firefox/webdriver.py", line 194, in __init__
    self.service.start()
  File "/usr/lib/python3/dist-packages/selenium/webdriver/common/service.py", line 106, in start
    self.assert_process_still_running()
  File "/usr/lib/python3/dist-packages/selenium/webdriver/common/service.py", line 119, in assert_process_still_running
    raise WebDriverException(f"Service {self.path} unexpectedly exited. Status code was: {return_code}")
selenium.common.exceptions.WebDriverException: Message: Service geckodriver unexpectedly exited. Status code was: 1

However, if instead of firefox, I attempt the same with chrome, it opens and closes without issue.

Code: Select all

driver = webdriver.Chrome()
driver.close()
Any suggestions???

Re: [Python] selenium webdriver help

Posted: 2023-11-15 07:06
by stevepusser
I think the versions of Firefox, selenium, and geckodriver (possibly that one's embedded in Firefox) will be crucial to solving the issue.

Have you done a websearch on that error message?

Re: [Python] selenium webdriver help

Posted: 2023-11-16 01:02
by ramack
Yup, thanks for responding. One thing that I tried last night was to include the path to the binary. While it didn't resolve the issue, it did produce a different error "DeprecationWarning: firefox_profile has been deprecated, please pass in an Options object". I'm looking into what that involves as a resolution.