3

i am working on a python project using selenium.

I get the following error and would like some help please

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

My chrome is version 103, and so is my chrome driver.

Here is the code

from selenium.webdriver.common.keys import Keys
from selenium.webdriver.common.by import By
from selenium.webdriver.support.ui import WebDriverWait
from selenium.webdriver.support import expected_conditions as EC
from selenium.webdriver.chrome.service import Service

player = input("Which player: ").lower()
PATH = "/Users/makfadel/Desktop/Desktop-items/chromedriver 2"
#driver = webdriver.Chrome(PATH)

s = Service(PATH)
browser = webdriver.Chrome(service=s)
browser.get("https://www.basketball-reference.com/leagues/NBA_2022_per_game.html")
search = browser.find_element(By.XPATH, "//*[@id='header']/div[3]/form/div/div/input[2]")
search.send_keys(player)
search.send_keys(Keys.RETURN)

try:
    element = WebDriverWait(browser, 10).until(
        EC.presence_of_element_located((By.XPATH, "//*[@id='players']/div[1]/div[1]/strong/a")))
    element.click()
    name = WebDriverWait(browser, 10).until(
        EC.presence_of_element_located((By.XPATH, "//*[@id='meta']/div[2]/h1/span")))
    print()
    print(name.text)
    print()
    szn = WebDriverWait(browser, 10).until(
        EC.presence_of_element_located((By.XPATH, "//*[@id='info']/div[4]/div[1]/div/p[1]/strong"))
    )
    games = WebDriverWait(browser, 10).until(
        EC.presence_of_element_located((By.XPATH, "//*[@id='info']/div[4]/div[2]/div[1]/p[1]"))
    )
    ppgame = WebDriverWait(browser, 10).until(
        EC.presence_of_element_located((By.XPATH, "//*[@id='info']/div[4]/div[2]/div[2]/p[1]"))
    )
    rebounds = WebDriverWait(browser, 10).until(
        EC.presence_of_element_located((By.XPATH, "//*[@id='info']/div[4]/div[2]/div[3]/p[1]"))
    )
    assists = WebDriverWait(browser, 10).until(
        EC.presence_of_element_located((By.XPATH, "//*[@id='info']/div[4]/div[2]/div[4]/p[1]"))
    )
    fg = WebDriverWait(browser, 10).until(
        EC.presence_of_element_located((By.XPATH, "//*[@id='info']/div[4]/div[3]/div[1]/p[1]"))
    )
    fg3 = WebDriverWait(browser, 10).until(
        EC.presence_of_element_located((By.XPATH, "//*[@id='info']/div[4]/div[3]/div[2]/p[1]"))
    )
    ft = WebDriverWait(browser, 10).until(
        EC.presence_of_element_located((By.XPATH, "//*[@id='info']/div[4]/div[3]/div[3]/p[1]"))
    )
    print(f"Season: {szn}")
    print(f"Games played: {games.text}")
    print(f"Points per game: {ppgame.text}")
    print(f"Rebounds per game: {rebounds.text}")
    print(f"Assists per game: {assists.text}")
    print(f"Field goal percentage: {fg.text}%")
    print(f"Field goal from 3 percentage: {fg3.text}%")
    print(f"Free throw percentage: {ft.text}%")
except Exception:
    print(f"No player named {player}")
finally:
    browser.quit()

1 Answer 1

4

There has been an issue with chrome driver 103 version

Please find below the bug ids for the same,

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

Check it on GitHub Selenium Issue - https://github.com/SeleniumHQ/selenium/issues/10799

Solution

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

  2. Upgrade the chromedriver to v104

sample code snippet -

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)

code reference - https://www.globalnerdy.com/2022/06/30/fix-the-chromedriver-103-bug-with-chromedriver-104/

Sign up to request clarification or add additional context in comments.

1 Comment

this is turning to be a massive pain, brew pip is supposed to work all of this mix up for you but in the end we have to install it manually & still tweak it and in my case non work 102,103,104

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.