selenium / seleniumwire unknown error: cannot determine loading status from unknown error: unexpected command response

Viewed 31197

Here is the error:

selenium.common.exceptions.WebDriverException: Message: unknown error: cannot determine loading status
from unknown error: unexpected command response
  (Session info: chrome=103.0.5060.53)

I'm using proper webdriver and chrome version:

Here is the script, its job is to open a webpage from the normal user data directory and provide a response.

from seleniumwire import webdriver  # Import from seleniumwire


chrome_options = webdriver.ChromeOptions()
chrome_options.add_argument("user-data-dir=C:\\selenium") 

driver = webdriver.Chrome(chrome_options=chrome_options)

driver.get('https://katalon.com/
')


for request in driver.requests:
    if request.response:
        print(
            
            request.response.status_code,
            
        )
8 Answers

There is a known issue with non-headless chromedriver browsers, you can read more about it here.

As of now there has not been a fix for chromedriver version 103 or less.

EDIT: This has been fixed for Chromedriver version 103 as well. Download chromedriver's latest 103 version from here.

What you can do:

  • Upgrade to chromedriver version 104 and use the Google 104 Beta version, following Dmytro Durach's instructions. The issue is definitely fixed as seen in the patch notes for chromedriver version 104.

  • Use a headless browser. Instructions on configuring chromedriver headless.

  • Use the incognito workaround found here. It seems to work for a few people.

  • Wait until the issue is fixed. From what I can tell they are actively working on it. Any updates will be posted here.

  • Use a try...except block to infinitely retry (not recommended).

There has been issue with chromeDriver 103 version and there is an issue raised for the same with Chromium community.

Please find below the bug ids for the same,

https://bugs.chromium.org/p/chromedriver/issues/detail?id=4121&q=label%3AMerge-Request-103

You can see all the conversations in the above bug thread.

For now, until this issue is fixed try to "Downgrade Chrome Browser To v102" and "Download Selenium Chrome Driver 102" and try to run your script, as this issue is happening in 103 version.

Because of this reason, Selenium community has closed the issue with regard to the same because the issue is related to Chrome team. https://github.com/SeleniumHQ/selenium/issues/10799

I built in a static wait; it's not elegant, but it worked for my purpose:

import time

time.sleep(5)

I think this will work but as a temporary workaround.

while True:
    try:
        driver.get('https://katalon.com/')
        break
    except:
        continue

On chrome version 103, If you open the chrome with incognito and disabled site isolation trials it would not give this error

options = webdriver.ChromeOptions()
options.add_argument("--incognito")
options.add_argument("--disable-site-isolation-trials")
driver = webdriver.Chrome(chrome_options=options)

I was getting the same reported error with Chrome ver=103: “Message: unknown error: cannot determine loading status from unknown error: unexpected command response”, although my error is generated from clicking an element. I tried the following suggestions listed above which did not work: Incognito mode, headless browser (which would not work for my application), adding time.sleep(10). (I am adverse to loading the Chrome beta version 104, at this time.)

What is peculiar about this error (at least in my application) is that while an exception is thrown, I can see that the code generating it (clicking an element) actually executes as expected - the element IS in fact clicked.

So I have had success with just ignoring the error with the following code:

try:  
   next_elm.click()
except:
   pass

And then continuing with the rest of my code. Not a very elegant work-around, but it works in my application.

Solution in Code:

from selenium import webdriver
from selenium.webdriver.chrome.options import Options
from selenium.webdriver.chrome.service import Service 
from webdriver_manager.chrome import ChromeDriverManager


# 1
option = Options()
option.binary_location='/Applications/Google Chrome 
Beta.app/Contents/MacOS/Google Chrome Beta'

# 2
driver = webdriver.Chrome(service=Service(ChromeDriverManager(version='104.0.5112.20').install()), options=option)

see: this thread

Related