Explorar el Código

avoid false negative test caused by is_displayed()

Falko Schindler hace 2 años
padre
commit
b2e6c6c924
Se han modificado 1 ficheros con 3 adiciones y 1 borrados
  1. 3 1
      tests/screen.py

+ 3 - 1
tests/screen.py

@@ -95,7 +95,9 @@ class Screen:
             query = f'//*[not(self::script) and not(self::style) and contains(text(), "{text}")]'
             element = self.selenium.find_element(By.XPATH, query)
             if not element.is_displayed():
-                raise AssertionError(f'Found "{text}" but it is hidden')
+                self.wait(0.1)  # HACK: repeat check after a short delay to avoid timing issue on fast machines
+                if not element.is_displayed():
+                    raise AssertionError(f'Found "{text}" but it is hidden')
             return element
         except NoSuchElementException:
             raise AssertionError(f'Could not find "{text}"')