1
0
Эх сурвалжийг харах

report error if element is not displayed

Rodja Trappe 2 жил өмнө
parent
commit
6143e8095e
1 өөрчлөгдсөн 4 нэмэгдсэн , 1 устгасан
  1. 4 1
      tests/screen.py

+ 4 - 1
tests/screen.py

@@ -93,7 +93,10 @@ class Screen:
     def find(self, text: str) -> WebElement:
         try:
             query = f'//*[not(self::script) and not(self::style) and contains(text(), "{text}")]'
-            return self.selenium.find_element(By.XPATH, query)
+            element = self.selenium.find_element(By.XPATH, query)
+            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}"')