Browse Source

adding user.should_not_see

Rodja Trappe 2 years ago
parent
commit
2af8ff43f5
2 changed files with 8 additions and 1 deletions
  1. 1 1
      tests/test_auto_context.py
  2. 7 0
      tests/user.py

+ 1 - 1
tests/test_auto_context.py

@@ -5,7 +5,7 @@ from nicegui import ui
 from .user import User
 
 
-def test_adding_element_to_index_page(user: User):
+def test_adding_element_to_shared_index_page(user: User):
     ui.button('add label', on_click=lambda: ui.label('added'))
 
     user.open('/')

+ 7 - 0
tests/user.py

@@ -1,6 +1,7 @@
 import threading
 import time
 
+import pytest
 from nicegui import globals, ui
 from selenium import webdriver
 from selenium.common.exceptions import NoSuchElementException
@@ -45,6 +46,12 @@ class User():
     def should_see(self, text: str) -> None:
         assert self.selenium.title == text or self.find(text).text == text
 
+    def should_not_see(self, text: str) -> None:
+        assert self.selenium.title != text
+        with pytest.raises(AssertionError):
+            element = self.find(text)
+            print(element.get_attribute('outerHTML'))
+
     def click(self, target_text: str) -> None:
         self.find(target_text).click()