From 2cd12f4d5e623ba37bf1beb19a1d6c15a1833de1 Mon Sep 17 00:00:00 2001 From: Nikhil Dhandre Date: Fri, 15 Nov 2019 18:30:39 +0530 Subject: [PATCH] warning property for Input --- src/widgetastic_patternfly/__init__.py | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/src/widgetastic_patternfly/__init__.py b/src/widgetastic_patternfly/__init__.py index 3ae736a..14551a2 100644 --- a/src/widgetastic_patternfly/__init__.py +++ b/src/widgetastic_patternfly/__init__.py @@ -219,16 +219,27 @@ class Input(TextInput): Has some additional methods. """ + WARNING_LOCATOR = "./following-sibling::div" + HELP_BLOCK_LOCATOR = "./following-sibling::span" + @property def help_block(self): e = self.browser.element(self) try: - help_block = self.browser.element('./following-sibling::span', parent=e) + help_block = self.browser.element(self.HELP_BLOCK_LOCATOR, parent=e) except NoSuchElementException: return None else: return self.browser.text(help_block) + @property + def warning(self): + try: + self.browser.wait_for_element(self.WARNING_LOCATOR, timeout=3) + return self.browser.text(self.WARNING_LOCATOR) + except NoSuchElementException: + return None + class FlashMessages(Widget): """Represents the block of flash messages."""