From b5e16807ea52d7cbef5bcd5df8a224d046b30955 Mon Sep 17 00:00:00 2001 From: Anastasiya Semenkevich Date: Thu, 29 Feb 2024 19:48:34 +0300 Subject: [PATCH] chore: added 2 attempts when clicking add buttons during permission creation and replaced id by object name --- test/e2e/gui/screens/community_settings.py | 51 ++++++++++++++-------- 1 file changed, 33 insertions(+), 18 deletions(-) diff --git a/test/e2e/gui/screens/community_settings.py b/test/e2e/gui/screens/community_settings.py index a0b67d5ec1..43c2657b92 100644 --- a/test/e2e/gui/screens/community_settings.py +++ b/test/e2e/gui/screens/community_settings.py @@ -531,28 +531,43 @@ class PermissionsSettingsView(QObject): self._create_permission_button.wait_until_hidden() @allure.step('Open Who holds context menu') - def open_who_holds_context_menu(self): - for child in walk_children(self._who_holds_list_item.object): - if getattr(child, 'id', '') == 'addItemButton': - driver.mouseClick(child) - return - raise LookupError('Add button for who holds not found') + def open_who_holds_context_menu(self, attempt: int = 2): + try: + for child in walk_children(self._who_holds_list_item.object): + if getattr(child, 'objectName', '') == 'addItemButton': + driver.mouseClick(child) + return + except LookupError: + if attempt: + return self.open_who_holds_context_menu(attempt - 1) + else: + raise LookupError('Add button for who holds not found') @allure.step('Open Is allowed to context menu') - def open_is_allowed_to_context_menu(self): - for child in walk_children(self._is_allowed_to_list_item.object): - if getattr(child, 'id', '') == 'addItemButton': - driver.mouseClick(child) - return - raise LookupError('Add button for allowed to not found') + def open_is_allowed_to_context_menu(self, attempt: int = 2): + try: + for child in walk_children(self._is_allowed_to_list_item.object): + if getattr(child, 'objectName', '') == 'addItemButton': + driver.mouseClick(child) + return + except LookupError: + if attempt: + return self.open_is_allowed_to_context_menu(attempt - 1) + else: + raise LookupError('Add button for allowed to not found') @allure.step('Open In context menu') - def open_in_context_menu(self): - for child in walk_children(self._in_list_item.object): - if getattr(child, 'id', '') == 'addItemButton': - driver.mouseClick(child) - return - raise LookupError('Add button for in not found') + def open_in_context_menu(self, attempt: int = 2): + try: + for child in walk_children(self._in_list_item.object): + if getattr(child, 'objectName', '') == 'addItemButton': + driver.mouseClick(child) + return + except LookupError: + if attempt: + return self.open_in_context_menu(attempt - 1) + else: + raise LookupError('Add button for in not found') @allure.step('Switch hide permission checkbox') def switch_hide_permission_checkbox(self, state):