Skip to content
This repository was archived by the owner on Aug 13, 2024. It is now read-only.

Commit 5ad590b

Browse files
committed
chore: added 2 attempts when clicking add buttons during permission creation and replaced id by object name
1 parent 6ffd472 commit 5ad590b

File tree

1 file changed

+33
-18
lines changed

1 file changed

+33
-18
lines changed

gui/screens/community_settings.py

Lines changed: 33 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -531,28 +531,43 @@ def create_permission(self):
531531
self._create_permission_button.wait_until_hidden()
532532

533533
@allure.step('Open Who holds context menu')
534-
def open_who_holds_context_menu(self):
535-
for child in walk_children(self._who_holds_list_item.object):
536-
if getattr(child, 'id', '') == 'addItemButton':
537-
driver.mouseClick(child)
538-
return
539-
raise LookupError('Add button for who holds not found')
534+
def open_who_holds_context_menu(self, attempt: int = 2):
535+
try:
536+
for child in walk_children(self._who_holds_list_item.object):
537+
if getattr(child, 'objectName', '') == 'addItemButton':
538+
driver.mouseClick(child)
539+
return
540+
except LookupError:
541+
if attempt:
542+
return self.open_who_holds_context_menu(attempt - 1)
543+
else:
544+
raise LookupError('Add button for who holds not found')
540545

541546
@allure.step('Open Is allowed to context menu')
542-
def open_is_allowed_to_context_menu(self):
543-
for child in walk_children(self._is_allowed_to_list_item.object):
544-
if getattr(child, 'id', '') == 'addItemButton':
545-
driver.mouseClick(child)
546-
return
547-
raise LookupError('Add button for allowed to not found')
547+
def open_is_allowed_to_context_menu(self, attempt: int = 2):
548+
try:
549+
for child in walk_children(self._is_allowed_to_list_item.object):
550+
if getattr(child, 'objectName', '') == 'addItemButton':
551+
driver.mouseClick(child)
552+
return
553+
except LookupError:
554+
if attempt:
555+
return self.open_is_allowed_to_context_menu(attempt - 1)
556+
else:
557+
raise LookupError('Add button for allowed to not found')
548558

549559
@allure.step('Open In context menu')
550-
def open_in_context_menu(self):
551-
for child in walk_children(self._in_list_item.object):
552-
if getattr(child, 'id', '') == 'addItemButton':
553-
driver.mouseClick(child)
554-
return
555-
raise LookupError('Add button for in not found')
560+
def open_in_context_menu(self, attempt: int = 2):
561+
try:
562+
for child in walk_children(self._in_list_item.object):
563+
if getattr(child, 'objectName', '') == 'addItemButton':
564+
driver.mouseClick(child)
565+
return
566+
except LookupError:
567+
if attempt:
568+
return self.open_in_context_menu(attempt - 1)
569+
else:
570+
raise LookupError('Add button for in not found')
556571

557572
@allure.step('Switch hide permission checkbox')
558573
def switch_hide_permission_checkbox(self, state):

0 commit comments

Comments
 (0)