Просмотр исходного кода

ref: upgrade selenium (#61253)

this one includes my fix for ResourceWarnings :D
anthony sottile 1 год назад
Родитель
Сommit
5197ce3eb3
3 измененных файлов с 13 добавлено и 15 удалено
  1. 1 2
      requirements-dev-frozen.txt
  2. 1 1
      requirements-dev.txt
  3. 11 12
      src/sentry/testutils/pytest/selenium.py

+ 1 - 2
requirements-dev-frozen.txt

@@ -136,7 +136,6 @@ pycparser==2.21
 pydantic==1.10.9
 pyflakes==3.1.0
 pyjwt==2.4.0
-pyopenssl==23.0.0
 pyparsing==3.0.9
 pyrsistent==0.18.1
 pysocks==1.7.1
@@ -170,7 +169,7 @@ rfc3339-validator==0.1.2
 rfc3986-validator==0.1.1
 rsa==4.8
 s3transfer==0.6.1
-selenium==4.3.0
+selenium==4.16.0
 sentry-arroyo==2.14.25
 sentry-cli==2.16.0
 sentry-forked-django-stubs==4.2.7.post1

+ 1 - 1
requirements-dev.txt

@@ -14,7 +14,7 @@ pytest-rerunfailures>=11
 pytest-sentry>=0.1.11
 pytest-xdist>=3
 responses>=0.23.1
-selenium>=4.3.0
+selenium>=4.16.0
 sentry-cli>=2.16.0
 
 # pre-commit dependencies

+ 11 - 12
src/sentry/testutils/pytest/selenium.py

@@ -205,13 +205,12 @@ class Browser:
         Waits until ``selector`` is visible and enabled to be clicked, or until ``timeout``
         is hit, whichever happens first.
         """
+        wait = WebDriverWait(self.driver, timeout)
         if selector:
-            condition = expected_conditions.element_to_be_clickable((By.CSS_SELECTOR, selector))
+            wait.until(expected_conditions.element_to_be_clickable((By.CSS_SELECTOR, selector)))
         else:
             raise ValueError
 
-        WebDriverWait(self.driver, timeout).until(condition)
-
         return self
 
     def wait_until(self, selector=None, xpath=None, title=None, timeout=10):
@@ -219,17 +218,16 @@ class Browser:
         Waits until ``selector`` is found in the browser, or until ``timeout``
         is hit, whichever happens first.
         """
+        wait = WebDriverWait(self.driver, timeout)
         if selector:
-            condition = expected_conditions.presence_of_element_located((By.CSS_SELECTOR, selector))
+            wait.until(expected_conditions.presence_of_element_located((By.CSS_SELECTOR, selector)))
         elif xpath:
-            condition = expected_conditions.presence_of_element_located((By.XPATH, xpath))
+            wait.until(expected_conditions.presence_of_element_located((By.XPATH, xpath)))
         elif title:
-            condition = expected_conditions.title_is(title)
+            wait.until(expected_conditions.title_is(title))
         else:
             raise ValueError
 
-        WebDriverWait(self.driver, timeout).until(condition)
-
         return self
 
     def wait_until_test_id(self, selector):
@@ -240,15 +238,16 @@ class Browser:
         Waits until ``selector`` is NOT found in the browser, or until
         ``timeout`` is hit, whichever happens first.
         """
+        wait = WebDriverWait(self.driver, timeout)
         if selector:
-            condition = expected_conditions.presence_of_element_located((By.CSS_SELECTOR, selector))
+            wait.until_not(
+                expected_conditions.presence_of_element_located((By.CSS_SELECTOR, selector))
+            )
         elif title:
-            condition = expected_conditions.title_is(title)
+            wait.until_not(expected_conditions.title_is(title))
         else:
             raise
 
-        WebDriverWait(self.driver, timeout).until_not(condition)
-
         return self
 
     def wait_until_script_execution(self, script, timeout=10):