35

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,
            
        )
vvvvv
  • 25,404
  • 19
  • 49
  • 81
Col Burn
  • 359
  • 1
  • 3
  • 3
  • 3
    have you checked your driver version is the same as your chrome version ? – Akzy Jun 26 '22 at 13:57
  • 1
    So...I just downgraded my chromedriver to 102. And it works. My Chrome version is 103 though...so not sure how my code is working :/ – jqlifer1 Jun 28 '22 at 01:12
  • 1
    how do you downgrade? chrome auto-update policy is so annoying and doesn't seem to let me – fersarr Jul 01 '22 at 11:50

8 Answers8

20

You need to upgrade Google Chrome and your Chrome Driver to version 104:

  1. Install Google Chrome Beta from here: https://www.google.com/chrome/beta/

  2. Update ChromeDriver to 104 manually (it is not in brew yet) https://chromedriver.storage.googleapis.com/index.html?path=104.0.5112.20/

  3. Set the chrome_options.binary_location:

    Windows - "C:\Program Files\Google\Chrome Beta\Application\chrome.exe"

    MacOS - "/Applications/Google Chrome Beta.app/Contents/MacOS/Google Chrome Beta"

TylerH
  • 20,799
  • 66
  • 75
  • 101
Dmytro Durach
  • 209
  • 1
  • 3
  • CHROME_OPTIONS.binary_location = "C:\Program Files\Google\Chrome Beta\Application\chrome.exe" just added that line before the chrome driver is initialized but yet when I execute the code the Beta version is not opened. Any idea of what I'm missing? – juanddiaz13 Jul 11 '22 at 14:02
  • The following worked for me: options = webdriver.ChromeOptions() options.binary_location = "C:/Program Files/Google/Chrome Beta/Application/chrome.exe" wd = webdriver.Chrome('chromedriver',options=options) – user3347814 Jul 18 '22 at 20:23
  • 1
    I get this message with 104.0.5112.48 as well. Not for all websites though. – user2396640 Jul 22 '22 at 14:08
10

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).

YiannisHa
  • 101
  • 4
  • In a tutorial I followed they recommended me using pyvirtualDisplay for my headless server and indeed it doesn't work without it :( – samuelnehool Jun 29 '22 at 13:32
7

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

Rami A.
  • 10,302
  • 4
  • 44
  • 87
Nirmal
  • 111
  • 1
  • 1
  • 12
5

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

import time

time.sleep(5)
pricco
  • 2,763
  • 1
  • 21
  • 22
dtadams79
  • 51
  • 3
  • Hi @David Adams, where exactly would you insert time.sleep(5)? Would that be before the driver.get(url) or after? I am answering it myself: you put the time.sleep(x) before driver.get(url). It worked for me. Thank you David for the suggestion! – jqlifer1 Jul 04 '22 at 06:36
  • @jqlifer1 I put the sleep after the driver.get(url) so that the page had time to load because that's what my automation needed. I'm glad putting it before your call worked in your application. – dtadams79 Jul 05 '22 at 11:09
  • @dtadams79 - unfortunately, it is not working consistently for me. I even tried putting before AND after driver.get(url) but still does not work...I think I will just wait for the 104 version of chrome and chromedriver. I don't want to install beta chrome 104 as I don't want to lose all my personal user data (or bother trying to reload all of it)/ – jqlifer1 Jul 05 '22 at 11:53
  • @jqlifer1 I added the following to my script in the pre-execution chrome driver initialization:
    driver.implicitly_wait(10)
    driver.set_script_timeout(10)
    – dtadams79 Jul 12 '22 at 12:26
3

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)
Arosha De Silva
  • 597
  • 8
  • 18
2

I think this will work but as a temporary workaround.

while True:
    try:
        driver.get('https://katalon.com/')
        break
    except:
        continue
Mahdi
  • 967
  • 4
  • 18
  • 34
0

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.

gymshoe
  • 7,495
  • 5
  • 20
  • 21
-1

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

ChrisGPT was on strike
  • 127,765
  • 105
  • 273
  • 257
  • Can you please provide the actual thread link? I think you have put the code instead of the web link. Thank you. I am trying to understand how it will be for windows. – jqlifer1 Jul 07 '22 at 03:17