ソースを参照

avoid false negative test caused by is_displayed()

Falko Schindler 2 年 前
コミット
b2e6c6c924
1 ファイル変更3 行追加1 行削除
  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}")]'
             query = f'//*[not(self::script) and not(self::style) and contains(text(), "{text}")]'
             element = self.selenium.find_element(By.XPATH, query)
             element = self.selenium.find_element(By.XPATH, query)
             if not element.is_displayed():
             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
             return element
         except NoSuchElementException:
         except NoSuchElementException:
             raise AssertionError(f'Could not find "{text}"')
             raise AssertionError(f'Could not find "{text}"')