Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Chromedriver selenium python

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()
like image 593
PyMak Avatar asked Jun 24 '26 10:06

PyMak


1 Answers

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/

like image 85
ahmedshahriar Avatar answered Jun 27 '26 06:06

ahmedshahriar



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!