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

Commit 3e3b20b

Browse files
committed
chore: remove click from Button class
1 parent 20aec1d commit 3e3b20b

File tree

8 files changed

+25
-51
lines changed

8 files changed

+25
-51
lines changed

gui/components/onboarding/before_started_popup.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ def is_visible(self) -> bool:
2525
@allure.step('Allow all and get started')
2626
def get_started(self):
2727
self._acknowledge_checkbox.set(True)
28-
self._terms_of_use_checkBox.set(True, x=10)
28+
self._terms_of_use_checkBox.set(True)
2929
assert self._terms_of_use_link.is_visible, f"Terms of use link is missing"
3030
assert self._privacy_policy_link.is_visible, f"Privacy Policy link is missing"
3131
self._get_started_button.click()

gui/elements/button.py

Lines changed: 1 addition & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -10,16 +10,4 @@
1010

1111

1212
class Button(QObject):
13-
14-
@allure.step('Click {0}')
15-
def click(
16-
self,
17-
x: typing.Union[int, driver.UiTypes.ScreenPoint] = None,
18-
y: typing.Union[int, driver.UiTypes.ScreenPoint] = None,
19-
button: driver.MouseButton = None
20-
):
21-
if None not in (x, y, button):
22-
getattr(self.object, 'clicked')()
23-
LOG.info('%s: clicked', self)
24-
else:
25-
super(Button, self).click(x, y, button)
13+
pass

gui/elements/check_box.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,9 +12,9 @@
1212
class CheckBox(QObject):
1313

1414
@allure.step("Set {0} value: {1}")
15-
def set(self, value: bool, x: int = None, y: int = None):
15+
def set(self, value: bool):
1616
if self.is_checked is not value:
17-
self.click(x, y)
17+
self.click()
1818
assert driver.waitFor(
1919
lambda: self.is_checked is value, configs.timeouts.UI_LOAD_TIMEOUT_MSEC), 'Value not changed'
2020
LOG.info('%s: value changed to "%s"', self, value)

gui/elements/object.py

Lines changed: 11 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -96,36 +96,22 @@ def click(
9696
):
9797
driver.mouseClick(
9898
self.object,
99-
x or self.width // 2,
100-
y or self.height // 2,
99+
x or int(self.object.width * 0.1),
100+
y or int(self.object.height * 0.1),
101101
button or driver.Qt.LeftButton
102102
)
103-
LOG.info('%s: clicked', self)
103+
LOG.info('%s: is clicked with Qt.LeftButton', self)
104104

105105
@allure.step('Native click {0}')
106-
def native_click(
106+
def native_mouse_click(
107107
self,
108108
x: typing.Union[int, driver.UiTypes.ScreenPoint] = None,
109109
y: typing.Union[int, driver.UiTypes.ScreenPoint] = None,
110110
button: driver.MouseButton = None
111111
):
112112
driver.nativeMouseClick(
113-
x or self.bounds.x + self.width // 2,
114-
y or self.bounds.y + self.height // 2,
115-
button or driver.MouseButton.LeftButton
116-
)
117-
LOG.info(f'{self}: native clicked')
118-
119-
@allure.step('Native click {0}')
120-
def native_click(
121-
self,
122-
x: typing.Union[int, driver.UiTypes.ScreenPoint] = None,
123-
y: typing.Union[int, driver.UiTypes.ScreenPoint] = None,
124-
button: driver.MouseButton = None
125-
):
126-
driver.nativeMouseClick(
127-
x or self.bounds.x + self.width // 2,
128-
y or self.bounds.y + self.height // 2,
113+
x or int(self.bounds.x + self.width // 2),
114+
y or int(self.bounds.y + self.height // 2),
129115
button or driver.MouseButton.LeftButton
130116
)
131117
LOG.info(f'{self}: native clicked')
@@ -145,18 +131,18 @@ def _hover():
145131
assert driver.waitFor(lambda: _hover(), timeout_msec)
146132
return self
147133

148-
@allure.step('Open context menu')
149-
def open_context_menu(
134+
@allure.step('Right click on {0}')
135+
def right_click(
150136
self,
151137
x: typing.Union[int, driver.UiTypes.ScreenPoint] = None,
152138
y: typing.Union[int, driver.UiTypes.ScreenPoint] = None,
153139
):
154140
self.click(
155-
x or self.width // 2,
156-
y or self.height // 2,
141+
x or int(self.width // 2),
142+
y or int(self.height // 2),
157143
driver.Qt.RightButton
158144
)
159-
LOG.info('%s: clicked via Right Mouse Button', self)
145+
LOG.info('%s: right clicked with Qt.RightButton', self)
160146

161147
@allure.step('Wait until appears {0}')
162148
def wait_until_appears(self, timeout_msec: int = configs.timeouts.UI_LOAD_TIMEOUT_MSEC):

gui/main_window.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -127,7 +127,7 @@ def get_community_logo(self, name: str) -> Image:
127127
@allure.step('Open context menu for community')
128128
def open_community_context_menu(self, name: str) -> ContextMenu:
129129
driver.objectMap.realName(self._get_community(name))['name'] = name
130-
self._get_community(name).open_context_menu()
130+
self._get_community(name).right_click()
131131
return ContextMenu().wait_until_appears()
132132

133133
@allure.step('Invite people in community')

gui/screens/community.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -301,12 +301,12 @@ def select_channel(self, name: str):
301301

302302
@allure.step('Open general channel context menu')
303303
def open_general_channel_context_menu(self):
304-
self._general_channel_item.open_context_menu()
304+
self._general_channel_item.right_click()
305305
return ContextMenu()
306306

307307
@allure.step('Open category context menu')
308308
def open_category_context_menu(self):
309-
self._category_list_item.open_context_menu()
309+
self._category_list_item.right_click()
310310

311311
@allure.step('Open create category popup')
312312
def open_create_category_popup(self, attempts: int = 2) -> NewCategoryPopup:
@@ -385,7 +385,7 @@ def get_channel_or_category_index(self, name: str) -> int:
385385

386386
@allure.step('Right click on left panel')
387387
def right_click_on_panel(self):
388-
super(LeftPanel, self).open_context_menu()
388+
super(LeftPanel, self).right_click()
389389

390390

391391
class Chat(QObject):

gui/screens/messages.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ def start_chat(self):
5050
@allure.step('Open context menu group chat')
5151
def _open_context_menu_for_chat(self, chat_name: str) -> ContextMenu:
5252
self._contact_item.real_name['objectName'] = chat_name
53-
self._contact_item.open_context_menu()
53+
self._contact_item.right_click()
5454
return ContextMenu().wait_until_appears()
5555

5656
@allure.step('Open leave popup')

gui/screens/wallet.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -83,14 +83,14 @@ def select_account(self, account_name: str) -> 'WalletAccountView':
8383
@allure.step('Open context menu from left wallet panel')
8484
@close_exists(BasePopup())
8585
def _open_context_menu(self) -> ContextMenu:
86-
super(LeftPanel, self).open_context_menu()
86+
super(LeftPanel, self).right_click()
8787
return ContextMenu().wait_until_appears()
8888

8989
@allure.step('Open context menu for account')
9090
@close_exists(BasePopup())
9191
def _open_context_menu_for_account(self, account_name: str) -> ContextMenu:
9292
self._wallet_account_item.real_name['title'] = account_name
93-
self._wallet_account_item.wait_until_appears().open_context_menu()
93+
self._wallet_account_item.wait_until_appears().right_click()
9494
return ContextMenu().wait_until_appears()
9595

9696
@allure.step("Select Hide/Include in total balance from context menu for account")
@@ -175,17 +175,17 @@ def open_add_saved_address_popup(self, attempt=2) -> 'AddressPopup':
175175

176176
@allure.step('Open edit address popup for saved address')
177177
def open_edit_address_popup(self, name: str) -> 'EditSavedAddressPopup':
178-
self.open_context_menu(name).select_edit_saved_address()
178+
self.right_click(name).select_edit_saved_address()
179179
return EditSavedAddressPopup()
180180

181181
@allure.step('Delete saved address from the list')
182182
def delete_saved_address(self, address_name):
183-
self.open_context_menu(address_name).select_delete_saved_address()
183+
self.right_click(address_name).select_delete_saved_address()
184184
assert ConfirmationPopup().get_confirmation_text().startswith('Are you sure you want to remove')
185185
ConfirmationPopup().confirm()
186186

187187
@allure.step('Open context menu in saved address')
188-
def open_context_menu(self, name) -> ContextMenu:
188+
def right_click(self, name) -> ContextMenu:
189189
self._open_menu_button.real_name['objectName'] = 'savedAddressView_Delegate_menuButton' + '_' + name
190190
self._address_list_item.real_name['objectName'] = 'savedAddressView_Delegate' + '_' + name
191191
self._address_list_item.hover()

0 commit comments

Comments
 (0)