From 01fa54117de5e77f3ec94207e9f66bbfd177ac9e Mon Sep 17 00:00:00 2001 From: Michal Reznik Date: Tue, 13 Mar 2018 18:51:10 +0100 Subject: [PATCH] ui_tests: add assert_notification() Add assert_notification() function to check whether we have a notification of particular type/ https://pagure.io/freeipa/issue/7441 Reviewed-By: Petr Vobornik --- ipatests/test_webui/ui_driver.py | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/ipatests/test_webui/ui_driver.py b/ipatests/test_webui/ui_driver.py index 71efe6705..3c7ea5f47 100644 --- a/ipatests/test_webui/ui_driver.py +++ b/ipatests/test_webui/ui_driver.py @@ -1875,3 +1875,21 @@ class UI_driver(object): is_enabled = not self.has_class(li, 'disabled') assert is_enabled == enabled, ('Invalid enabled state of action item %s. ' 'Expected: %s') % (action, str(visible)) + + def assert_notification(self, type='success', assert_text=None): + """ + Assert whether we have a notification of particular type + + type: type for assertion + assert_text: assert particular text when True + + Returns True if selector/text found + """ + + notification_type = 'div.notification-area .alert-{}'.format(type) + # wait for a half sec for notification to appear + self.wait(0.5) + is_present = self.find(notification_type, By.CSS_SELECTOR) + assert is_present, "Notification not present" + if assert_text: + assert assert_text in is_present.text