Remove error message from selenium attempting to check the latest geckodriver version at startup

38 views Asked by At

I sometimes start Selenium without an internet connection, and whenever I do that, it displays the following error message:

Exception managing firefox: error sending request for url (https://github.com/mozilla/geckodriver/releases/latest): error trying to connect: dns error: No such host is known. (os error 11001)

Now I could just wrap the code in a try-catch-statement each time, but I was wondering whether there is a proper way to either suppress this error message, or alternatively disable the update check?

For context, I run selenium in python on Windows 10, using geckodriver to connect to Firefox.

2

There are 2 answers

2
JeffC On

I'm assuming you are either using a driver manager or Selenium 4.6+ that now includes Selenium Manager, a driver manager. That's likely the driver manager trying to check if you've got the most recent browser driver installed.

I wouldn't disable the check because it's keeping your browser driver up-to-date. You could put it in a try-catch to suppress the message and write something to the logs, if you wanted.

0
ordinary_python_programmer On

So after digging in, I found three possible solutions:

  • Disabling the update check: Like described here, can be achieved with either a config file or environment variable.
  • Setting the log level higher: Can be done in python like this:
import logging
logging.getLogger("selenium.webdriver.common.selenium_manager").setLevel(logging.CRITICAL)
  • Using a try and catch block: The exception is a generic WebDriverException.

Neither of them are particularily clean, as they all also hide other errors, but that is all I can think of. If someone else has a better idea I will accept it.