Browse Source

Handled WebDriverException from Chrome driver version 113+.

Sarah Boyce 1 week ago
parent
commit
afbb8c709d
1 changed files with 9 additions and 1 deletions
  1. 9 1
      django/contrib/admin/tests.py

+ 9 - 1
django/contrib/admin/tests.py

@@ -123,13 +123,21 @@ class AdminSeleniumTestCase(SeleniumTestCase, StaticLiveServerTestCase):
         """
         Block until a new page has loaded and is ready.
         """
+        from selenium.common.exceptions import WebDriverException
         from selenium.webdriver.common.by import By
         from selenium.webdriver.support import expected_conditions as ec
 
         old_page = self.selenium.find_element(By.TAG_NAME, "html")
         yield
         # Wait for the next page to be loaded
-        self.wait_until(ec.staleness_of(old_page), timeout=timeout)
+        try:
+            self.wait_until(ec.staleness_of(old_page), timeout=timeout)
+        except WebDriverException:
+            # Issue in version 113+ of Chrome driver where a WebDriverException
+            # error is raised rather than a StaleElementReferenceException, see:
+            # https://issues.chromium.org/issues/42323468
+            pass
+
         self.wait_page_ready(timeout=timeout)
 
     def admin_login(self, username, password, login_url="/admin/"):