On Tue, 6 May 2014 17:58:09 +0200
Misnyovszki Adam <amisn...@redhat.com> wrote:

> Hi,
> first patch extends webui tests with a callback function, and an
> assert_disabled function, to check if a field is disabled under
> certain conditions.
> Second patch extends range tests with this checking functionality
> depending on range types.
> Thanks
> Adam

Fixed issue in 22, when the element, which is checked, doesn't exist,
test returns false positive.
Thanks
Adam
>From 5c080056bfcc2ab3589bffff7a43e4d01bcd8041 Mon Sep 17 00:00:00 2001
From: Adam Misnyovszki <amisn...@redhat.com>
Date: Wed, 7 May 2014 14:30:29 +0200
Subject: [PATCH] webui tests: callback, assert_disabled feature added

Added a callback feature to webui tests,
to extend functionality. Also added
assert_disabled function to ui_driver, to
check if a field is disabled in the browser.
---
 ipatests/test_webui/ui_driver.py | 22 ++++++++++++++++++++--
 1 file changed, 20 insertions(+), 2 deletions(-)

diff --git a/ipatests/test_webui/ui_driver.py b/ipatests/test_webui/ui_driver.py
index 7cfe21ad8985b04fcb296adccf0277a5f02833b9..ce63d570e978f7fe68d35a89b14cc5714e313856 100644
--- a/ipatests/test_webui/ui_driver.py
+++ b/ipatests/test_webui/ui_driver.py
@@ -1000,7 +1000,7 @@ class UI_driver(object):
             key = field[1]
             val = field[2]
 
-            if undo:
+            if undo and not hasattr(key, '__call__'):
                 self.assert_undo_button(key, False, parent)
 
             if widget_type == 'textbox':
@@ -1025,8 +1025,13 @@ class UI_driver(object):
                 self.fill_multivalued(key, val, parent)
             elif widget_type == 'table':
                 self.select_record(val, parent, key)
+            # this meta field specifies a function, to extend functionality of
+            # field checking
+            elif widget_type == 'callback':
+                if hasattr(key, '__call__'):
+                    key(val)
             self.wait()
-            if undo:
+            if undo and not hasattr(key, '__call__'):
                 self.assert_undo_button(key, True, parent)
 
     def validate_fields(self, fields, parent=None):
@@ -1551,6 +1556,19 @@ class UI_driver(object):
         else:
             assert visible, "Element not visible: %s" % selector
 
+    def assert_disabled(self, selector, parent=None, negative=False):
+        """
+        Assert that element defined by selector is disabled
+        """
+        if not parent:
+            parent = self.get_form()
+        el = self.find(selector, By.CSS_SELECTOR, parent, strict=True)
+        dis = self.find(selector+"[disabled]", By.CSS_SELECTOR, parent)
+        if negative:
+            assert dis is None, "Element is disabled: %s" % selector
+        else:
+            assert dis, "Element is not disabled: %s" % selector
+
     def assert_record(self, pkey, parent=None, table_name=None, negative=False):
         """
         Assert that record is in current search table
-- 
1.9.0

_______________________________________________
Freeipa-devel mailing list
Freeipa-devel@redhat.com
https://www.redhat.com/mailman/listinfo/freeipa-devel

Reply via email to