0

Currently I'm using multiple exceptions in a for loop. However, they are still throwing exception errors and I'm not certain why they are not being handled.

Here is my code:

for x in range (15):
    actions.click_and_hold(element1).move_to_element(element2).release().perform()
    try:
        WebDriverWait(driver, 5).until(
            EC.visibility_of_element_located((elementLocator))
            )
        return True
    except (StaleElementReferenceException, TimeoutException):
        break

Here is the error being thrown:

StaleElementReferenceException: Message: stale element reference: element is not attached to the page document
  (Session info: headless chrome=67.0.3396.30)
  (Driver info: chromedriver=2.36.540469 (1881fd7f8641508feb5166b7cae561d87723cfa8),platform=Mac OS X 10.13.4 x86_64)
undetected Selenium
  • 183,867
  • 41
  • 278
  • 352
Cal Corbin
  • 190
  • 15

1 Answers1

0

I don't see any issue in your code block as such but your main issue seems to be in the version compatibility between the binaries you are using as follows :

  • You are using chromedriver=2.36
  • Release Notes of chromedriver=2.36 clearly mentions the following :

Supports Chrome v63-65

  • You are using chrome=67.0
  • Release Notes of ChromeDriver v2.38 clearly mentions the following :

Supports Chrome v65-67

So there is a clear mismatch between the ChromeDriver version (v2.36) and the Chrome Browser version (v67.0)

Solution

  • Upgrade ChromeDriver to current ChromeDriver v2.38 level.
  • Keep Chrome version at Chrome v67.x levels. (as per ChromeDriver v2.38 release notes)
  • Clean your Project Workspace through your IDE and Rebuild your project with required dependencies only.
  • Use CCleaner tool to wipe off all the OS chores before and after the execution of your test Suite.
  • If your base Web Client version is too old, then uninstall it through Revo Uninstaller and install a recent GA and released version of Web Client.
  • Take a System Reboot.
  • Execute your @Test.
undetected Selenium
  • 183,867
  • 41
  • 278
  • 352