[virt-tools-list] [PATCH 08/10] uitests: Fix selection of items in long menus that don't fit on screen

Povilas Kanapickas povilas at radix.lt
Sat Sep 1 22:25:22 UTC 2018


Signed-off-by: Povilas Kanapickas <povilas at radix.lt>
---
 tests/uitests/details.py | 11 +++++++----
 tests/uitests/utils.py   | 13 ++++++++++++-
 2 files changed, 19 insertions(+), 5 deletions(-)

diff --git a/tests/uitests/details.py b/tests/uitests/details.py
index d19afb36..685eb654 100644
--- a/tests/uitests/details.py
+++ b/tests/uitests/details.py
@@ -203,7 +203,7 @@ class Details(uiutils.UITestCase):
         tab = self._select_hw(win, "NIC :54:32:10", "network-tab")
         src = tab.find("Network source:", "combo box")
         src.click()
-        tab.find_fuzzy("macvtap", "menu item").click()
+        tab.find_fuzzy("macvtap", "menu item").bring_on_screen().click()
         tab.find("Device model:", "combo box").click_combo_entry()
         tab.find("rtl8139", "menu item").click()
         mode = tab.find_fuzzy("Source mode:", "combo box")
@@ -215,7 +215,8 @@ class Details(uiutils.UITestCase):
 
         # Manual bridge
         src.click()
-        tab.find_fuzzy("Specify shared device", "menu item").click()
+        tab.find_fuzzy("Specify shared device",
+                       "menu item").bring_on_screen().click()
         appl.click()
         # Check validation error
         alert = self.app.root.find("vmm dialog", "alert")
@@ -228,7 +229,8 @@ class Details(uiutils.UITestCase):
         # Network with portops
         src.click()
         self.pressKey("Home")
-        tab.find_fuzzy("plainbridge-portgroups", "menu item").click()
+        tab.find_fuzzy("plainbridge-portgroups",
+                       "menu item").bring_on_screen().click()
         c = tab.find_fuzzy("Portgroup:", "combo box")
         c.click_combo_entry()
         self.assertTrue(c.find("engineering", "menu item").selected)
@@ -238,7 +240,8 @@ class Details(uiutils.UITestCase):
 
         # Network with vport stuff
         src.click()
-        tab.find_fuzzy("OpenVSwitch", "menu item").click()
+        tab.find_fuzzy("OpenVSwitch",
+                       "menu item").bring_on_screen().click()
         t = tab.find("Virtual port", "toggle button")
         t.click()
         t.find("Type:", "text").text = "802.1Qbg"
diff --git a/tests/uitests/utils.py b/tests/uitests/utils.py
index 300731d2..1efee55b 100644
--- a/tests/uitests/utils.py
+++ b/tests/uitests/utils.py
@@ -256,6 +256,18 @@ class VMMDogtailNode(dogtail.tree.Node):
         clickY = self.position[1] + 5
         dogtail.rawinput.click(clickX, clickY, button)
 
+    def bring_on_screen(self, key_name="Down", max_tries=100):
+        """
+        Attempts to bring the item to screen by repeatedly clicking the given
+        key. Raises exception if max_tries attempts are exceeded.
+        """
+        cur_try = 0
+        while not self.onscreen:
+            dogtail.rawinput.pressKey(key_name)
+            cur_try += 1
+            if cur_try > max_tries:
+                raise RuntimeError("Could not bring widget on screen")
+        return self
 
     #########################
     # Widget search helpers #
-- 
2.17.1





More information about the virt-tools-list mailing list