skip to Main Content

I am using Selenium to access a service that require login. I login one time then the login in data saved into user data, a dir that I specify as following:

    chrome_options.add_argument("--user-data-dir=%s" % self.user_dir)

Everything was okay until I updated the system (Ubuntu server). Chromium was updated from 108 to 110. The first issue i faced that I need to update the ChromeDriver to 110.0.5481.77.

Now, when I use Selenium as usual, it took long time until I get the following error:

File "/home/user/bots/teleBots/app/wa.py", line 49, in __init__
    browser = webdriver.Chrome(executable_path=driver, options=self.chrome_options,
  File "/home/user/ak_env_9/lib/python3.9/site-packages/selenium/webdriver/chrome/webdriver.py", line 81, in __init__
    super().__init__(
  File "/home/user/ak_env_9/lib/python3.9/site-packages/selenium/webdriver/chromium/webdriver.py", line 106, in __init__
    super().__init__(
  File "/home/user/ak_env_9/lib/python3.9/site-packages/selenium/webdriver/remote/webdriver.py", line 288, in __init__
    self.start_session(capabilities, browser_profile)
  File "/home/user/ak_env_9/lib/python3.9/site-packages/selenium/webdriver/remote/webdriver.py", line 381, in start_session
    response = self.execute(Command.NEW_SESSION, parameters)
  File "/home/user/ak_env_9/lib/python3.9/site-packages/selenium/webdriver/remote/webdriver.py", line 444, in execute
    self.error_handler.check_response(response)
  File "/home/user/ak_env_9/lib/python3.9/site-packages/selenium/webdriver/remote/errorhandler.py", line 249, in check_response
    raise exception_class(message, screen, stacktrace)
selenium.common.exceptions.WebDriverException: Message: unknown error: unable to discover open pages

I searched for solution and most of them suggest using the option:

    chrome_options.add_argument("--no-sandbox")

and others:

        chrome_options.add_argument("--remote-debugging-port=9222")

But nothing works for me until I removed the user dir option:

    #chrome_options.add_argument("--user-data-dir=%s" % self.user_dir)

It works for me but I have to log in everytime I run the script.

How can I solved this issue?

Is there anyway to downgrade chromium browser to 108? (I need deb file for ubuntu)

Or anyway to keep login active other than using user-data-dir?

2

Answers


  1. Chosen as BEST ANSWER

    I was lucky to find in my downloads dir an old version of google chrome (108).

    I installed it using the command:

    sudo dpkg -i google-chrome-stable_current_amd64.deb
    

    Then, I downloaded the right version of the chrome driver from: https://chromedriver.chromium.org/downloads

    and yes! Life back to it usual. Could be a bug in the new chrome driver. Hopefully we can find other solutions for version 110


  2. It’s a breaking change of headless in Chrome 109. Change your argument --headless or --headless=chrome to --headless=new

    Based on this answer :
    https://stackoverflow.com/a/73840130

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search