chore: remove click from Button class

This commit is contained in:
Anastasiya Semenkevich 2024-03-13 11:44:28 +03:00 committed by Anastasiya
parent fb2133af86
commit e80774ccce
8 changed files with 25 additions and 51 deletions

View File

@ -25,7 +25,7 @@ class BeforeStartedPopUp(BasePopup):
@allure.step('Allow all and get started') @allure.step('Allow all and get started')
def get_started(self): def get_started(self):
self._acknowledge_checkbox.set(True) self._acknowledge_checkbox.set(True)
self._terms_of_use_checkBox.set(True, x=10) self._terms_of_use_checkBox.set(True)
assert self._terms_of_use_link.is_visible, f"Terms of use link is missing" assert self._terms_of_use_link.is_visible, f"Terms of use link is missing"
assert self._privacy_policy_link.is_visible, f"Privacy Policy link is missing" assert self._privacy_policy_link.is_visible, f"Privacy Policy link is missing"
self._get_started_button.click() self._get_started_button.click()

View File

@ -10,16 +10,4 @@ LOG = logging.getLogger(__name__)
class Button(QObject): class Button(QObject):
pass
@allure.step('Click {0}')
def click(
self,
x: typing.Union[int, driver.UiTypes.ScreenPoint] = None,
y: typing.Union[int, driver.UiTypes.ScreenPoint] = None,
button: driver.MouseButton = None
):
if None not in (x, y, button):
getattr(self.object, 'clicked')()
LOG.info('%s: clicked', self)
else:
super(Button, self).click(x, y, button)

View File

@ -12,9 +12,9 @@ LOG = logging.getLogger(__name__)
class CheckBox(QObject): class CheckBox(QObject):
@allure.step("Set {0} value: {1}") @allure.step("Set {0} value: {1}")
def set(self, value: bool, x: int = None, y: int = None): def set(self, value: bool):
if self.is_checked is not value: if self.is_checked is not value:
self.click(x, y) self.click()
assert driver.waitFor( assert driver.waitFor(
lambda: self.is_checked is value, configs.timeouts.UI_LOAD_TIMEOUT_MSEC), 'Value not changed' lambda: self.is_checked is value, configs.timeouts.UI_LOAD_TIMEOUT_MSEC), 'Value not changed'
LOG.info('%s: value changed to "%s"', self, value) LOG.info('%s: value changed to "%s"', self, value)

View File

@ -96,36 +96,22 @@ class QObject:
): ):
driver.mouseClick( driver.mouseClick(
self.object, self.object,
x or self.width // 2, x or int(self.object.width * 0.1),
y or self.height // 2, y or int(self.object.height * 0.1),
button or driver.Qt.LeftButton button or driver.Qt.LeftButton
) )
LOG.info('%s: clicked', self) LOG.info('%s: is clicked with Qt.LeftButton', self)
@allure.step('Native click {0}') @allure.step('Native click {0}')
def native_click( def native_mouse_click(
self, self,
x: typing.Union[int, driver.UiTypes.ScreenPoint] = None, x: typing.Union[int, driver.UiTypes.ScreenPoint] = None,
y: typing.Union[int, driver.UiTypes.ScreenPoint] = None, y: typing.Union[int, driver.UiTypes.ScreenPoint] = None,
button: driver.MouseButton = None button: driver.MouseButton = None
): ):
driver.nativeMouseClick( driver.nativeMouseClick(
x or self.bounds.x + self.width // 2, x or int(self.bounds.x + self.width // 2),
y or self.bounds.y + self.height // 2, y or int(self.bounds.y + self.height // 2),
button or driver.MouseButton.LeftButton
)
LOG.info(f'{self}: native clicked')
@allure.step('Native click {0}')
def native_click(
self,
x: typing.Union[int, driver.UiTypes.ScreenPoint] = None,
y: typing.Union[int, driver.UiTypes.ScreenPoint] = None,
button: driver.MouseButton = None
):
driver.nativeMouseClick(
x or self.bounds.x + self.width // 2,
y or self.bounds.y + self.height // 2,
button or driver.MouseButton.LeftButton button or driver.MouseButton.LeftButton
) )
LOG.info(f'{self}: native clicked') LOG.info(f'{self}: native clicked')
@ -145,18 +131,18 @@ class QObject:
assert driver.waitFor(lambda: _hover(), timeout_msec) assert driver.waitFor(lambda: _hover(), timeout_msec)
return self return self
@allure.step('Open context menu') @allure.step('Right click on {0}')
def open_context_menu( def right_click(
self, self,
x: typing.Union[int, driver.UiTypes.ScreenPoint] = None, x: typing.Union[int, driver.UiTypes.ScreenPoint] = None,
y: typing.Union[int, driver.UiTypes.ScreenPoint] = None, y: typing.Union[int, driver.UiTypes.ScreenPoint] = None,
): ):
self.click( self.click(
x or self.width // 2, x or int(self.width // 2),
y or self.height // 2, y or int(self.height // 2),
driver.Qt.RightButton driver.Qt.RightButton
) )
LOG.info('%s: clicked via Right Mouse Button', self) LOG.info('%s: right clicked with Qt.RightButton', self)
@allure.step('Wait until appears {0}') @allure.step('Wait until appears {0}')
def wait_until_appears(self, timeout_msec: int = configs.timeouts.UI_LOAD_TIMEOUT_MSEC): def wait_until_appears(self, timeout_msec: int = configs.timeouts.UI_LOAD_TIMEOUT_MSEC):

View File

@ -127,7 +127,7 @@ class LeftPanel(QObject):
@allure.step('Open context menu for community') @allure.step('Open context menu for community')
def open_community_context_menu(self, name: str) -> ContextMenu: def open_community_context_menu(self, name: str) -> ContextMenu:
driver.objectMap.realName(self._get_community(name))['name'] = name driver.objectMap.realName(self._get_community(name))['name'] = name
self._get_community(name).open_context_menu() self._get_community(name).right_click()
return ContextMenu().wait_until_appears() return ContextMenu().wait_until_appears()
@allure.step('Invite people in community') @allure.step('Invite people in community')

View File

@ -301,12 +301,12 @@ class LeftPanel(QObject):
@allure.step('Open general channel context menu') @allure.step('Open general channel context menu')
def open_general_channel_context_menu(self): def open_general_channel_context_menu(self):
self._general_channel_item.open_context_menu() self._general_channel_item.right_click()
return ContextMenu() return ContextMenu()
@allure.step('Open category context menu') @allure.step('Open category context menu')
def open_category_context_menu(self): def open_category_context_menu(self):
self._category_list_item.open_context_menu() self._category_list_item.right_click()
@allure.step('Open create category popup') @allure.step('Open create category popup')
def open_create_category_popup(self, attempts: int = 2) -> NewCategoryPopup: def open_create_category_popup(self, attempts: int = 2) -> NewCategoryPopup:
@ -385,7 +385,7 @@ class LeftPanel(QObject):
@allure.step('Right click on left panel') @allure.step('Right click on left panel')
def right_click_on_panel(self): def right_click_on_panel(self):
super(LeftPanel, self).open_context_menu() super(LeftPanel, self).right_click()
class Chat(QObject): class Chat(QObject):

View File

@ -50,7 +50,7 @@ class LeftPanel(QObject):
@allure.step('Open context menu group chat') @allure.step('Open context menu group chat')
def _open_context_menu_for_chat(self, chat_name: str) -> ContextMenu: def _open_context_menu_for_chat(self, chat_name: str) -> ContextMenu:
self._contact_item.real_name['objectName'] = chat_name self._contact_item.real_name['objectName'] = chat_name
self._contact_item.open_context_menu() self._contact_item.right_click()
return ContextMenu().wait_until_appears() return ContextMenu().wait_until_appears()
@allure.step('Open leave popup') @allure.step('Open leave popup')

View File

@ -83,14 +83,14 @@ class LeftPanel(QObject):
@allure.step('Open context menu from left wallet panel') @allure.step('Open context menu from left wallet panel')
@close_exists(BasePopup()) @close_exists(BasePopup())
def _open_context_menu(self) -> ContextMenu: def _open_context_menu(self) -> ContextMenu:
super(LeftPanel, self).open_context_menu() super(LeftPanel, self).right_click()
return ContextMenu().wait_until_appears() return ContextMenu().wait_until_appears()
@allure.step('Open context menu for account') @allure.step('Open context menu for account')
@close_exists(BasePopup()) @close_exists(BasePopup())
def _open_context_menu_for_account(self, account_name: str) -> ContextMenu: def _open_context_menu_for_account(self, account_name: str) -> ContextMenu:
self._wallet_account_item.real_name['title'] = account_name self._wallet_account_item.real_name['title'] = account_name
self._wallet_account_item.wait_until_appears().open_context_menu() self._wallet_account_item.wait_until_appears().right_click()
return ContextMenu().wait_until_appears() return ContextMenu().wait_until_appears()
@allure.step("Select Hide/Include in total balance from context menu for account") @allure.step("Select Hide/Include in total balance from context menu for account")
@ -175,17 +175,17 @@ class SavedAddressesView(QObject):
@allure.step('Open edit address popup for saved address') @allure.step('Open edit address popup for saved address')
def open_edit_address_popup(self, name: str) -> 'EditSavedAddressPopup': def open_edit_address_popup(self, name: str) -> 'EditSavedAddressPopup':
self.open_context_menu(name).select_edit_saved_address() self.right_click(name).select_edit_saved_address()
return EditSavedAddressPopup() return EditSavedAddressPopup()
@allure.step('Delete saved address from the list') @allure.step('Delete saved address from the list')
def delete_saved_address(self, address_name): def delete_saved_address(self, address_name):
self.open_context_menu(address_name).select_delete_saved_address() self.right_click(address_name).select_delete_saved_address()
assert ConfirmationPopup().get_confirmation_text().startswith('Are you sure you want to remove') assert ConfirmationPopup().get_confirmation_text().startswith('Are you sure you want to remove')
ConfirmationPopup().confirm() ConfirmationPopup().confirm()
@allure.step('Open context menu in saved address') @allure.step('Open context menu in saved address')
def open_context_menu(self, name) -> ContextMenu: def right_click(self, name) -> ContextMenu:
self._open_menu_button.real_name['objectName'] = 'savedAddressView_Delegate_menuButton' + '_' + name self._open_menu_button.real_name['objectName'] = 'savedAddressView_Delegate_menuButton' + '_' + name
self._address_list_item.real_name['objectName'] = 'savedAddressView_Delegate' + '_' + name self._address_list_item.real_name['objectName'] = 'savedAddressView_Delegate' + '_' + name
self._address_list_item.hover() self._address_list_item.hover()