1

I crossposted this to the UC github discussions:

I'm a hack hobbyist so please forgive my lack of codiing skills.

Yesterday my chromedriver and uc (I think) updated and I'm now getting a Timeout exception

Traceback (most recent call last):
  File "C:\Users\admin\OneDrive\PycharmProjects\webscrape\nba.py", line 157, in <module>
    mgm_data = mgm_scrape(Url, max_list_len)
  File "C:\Users\admin\OneDrive\PycharmProjects\webscrape\CommonFuns.py", line 407, in mgm_scrape
    WebDriverWait(driver, timeout).until(EC.presence_of_element_located((By.CLASS_NAME, "participant")))
  File "C:\Users\admin\AppData\Local\Programs\Python\Python39\lib\site-packages\selenium\webdriver\support\wait.py", line 105, in until
    raise TimeoutException(message, screen, stacktrace)

When I use the normal chromedriver (not uc) everything runs without error.

OS - Win11 selenium - 4.16.0 seleniumbase - 4.22.1 Python - 3.9 URL - https://sports.ks.betmgm.com/en/sports/basketball-7/betting/usa-9

Code that works - first 4 lines are the only difference:

**service = Service()
   options = webdriver.ChromeOptions()
   driver = webdriver.Chrome(service=service, options=options)  # mgm only works with normal chrome webdriver**

   # driver = sbDriver(uc_cdp=True, incognito=True)
   

   # driver.set_window_size(930, 930)
   # driver.get('https://nowsecure.nl')
   # time.sleep(20)
   # driver.save_screenshot('C:/Users/admin/Desktop/nowsecure.png')
   mgm_web = Url
   driver.get(mgm_web)
   sleep_time = 2.5 + (max_list_len / 40)
   time.sleep(sleep_time)

   # time.sleep(4) # ncaabb tourney sleep time to click button

   # try to click more button twice for long list lengths
   button_loops = int(max_list_len / 50)
   if max_list_len > 73:
       for i in range(button_loops):
           try:
               more_button = driver.find_element(By.CSS_SELECTOR,
                                                 '#main-view > ms-widget-layout > ms-widget-slot > ms-composable-widget > ms-widget-slot > ms-tabbed-grid-widget > div > div')
               more_button.location_once_scrolled_into_view
           except NoSuchElementException:
               print("no mgm button")
               break
           else:
               time.sleep(2)
               more_button.click()
               time.sleep(3)


   # manage stale element errors
   timeout = sleep_time
   for i in range(4):
       try:
           WebDriverWait(driver, timeout).until(EC.presence_of_element_located((By.CLASS_NAME, "participant")))
           mgm_team_name = driver.find_elements(By.CLASS_NAME, "participant")
           # WebDriverWait(driver, timeout).until(EC.presence_of_element_located((By.XPATH,
           # '//*[@id="main-view"]/ms-fixture-list/div/div/div/div/ms-grid/div/ms-event-group[1]/ms-six-pack-event[1]/div[2]/a/ms-event-detail/ms-event-name/ms-inline-tooltip/div/div[1]/div/div/div[1]/div')))
           # mgm_team_name = driver.find_elements(By.XPATH,
           # '//*[@id="main-view"]/ms-fixture-list/div/div/div/div/ms-grid/div/ms-event-group[1]/ms-six-pack-event[1]/div[2]/a/ms-event-detail/ms-event-name/ms-inline-tooltip/div/div[1]/div/div/div[1]/div')
           for j in range(len(mgm_team_name)):
               mgm_team_name[j] = mgm_team_name[j].text
           print(mgm_team_name)
           print('mgm name stale element loops', i)
           break
       except StaleElementReferenceException or NoSuchElementException or TimeoutException:
           continue

Code that used to work but now doesn't:

driver = sbDriver(uc_cdp=True, incognito=True)


    # driver.set_window_size(930, 930)
    # driver.get('https://nowsecure.nl')
    ...  same code as before
1
  • It did resolve when Chrome 131 was released. Commented Nov 21, 2024 at 15:03

0

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.