Fixed get toast messages method (#209)

This commit is contained in:
Valentina1133 2023-10-25 14:34:00 +02:00 committed by GitHub
parent 5f94f36a35
commit 923c9d6284
3 changed files with 20 additions and 14 deletions

View File

@ -1,18 +1,23 @@
import allure import allure
from driver import objects_access import driver
from gui.elements.object import QObject from gui.elements.object import QObject
class WalletToastMessage(QObject): class WalletToastMessage(QObject):
def __init__(self): def __init__(self):
super(WalletToastMessage, self).__init__('ephemeralNotificationList_StatusToastMessage') super(WalletToastMessage, self).__init__('mainWallet_Ephemeral_Notification_List')
self._wallet_toast_messages_list = QObject('mainWallet_Ephemeral_Notification_List') self._wallet_toast_message = QObject('ephemeralNotificationList_StatusToastMessage')
@allure.step('Check message at the bottom') @property
def get_toast_message(self, name: str): @allure.step('Get toast messages')
for item in objects_access.walk_children(self._wallet_toast_messages_list.object): def get_toast_messages(self):
if getattr(item, 'text', '') == name: messages = []
return item for obj in driver.findAllObjects(self._wallet_toast_message.real_name):
raise LookupError(f'Wallet toast message: {name} not found') messages.append(str(obj.primaryText))
if len(messages) == 0:
raise LookupError(
'Toast messages were not found')
else:
return messages

View File

@ -217,11 +217,11 @@ class EditNetworkSettings(WalletSettingsView):
def check_toast_message(self, network_tab): def check_toast_message(self, network_tab):
match network_tab: match network_tab:
case WalletNetworkSettings.EDIT_NETWORK_LIVE_TAB.value: case WalletNetworkSettings.EDIT_NETWORK_LIVE_TAB.value:
WalletToastMessage().get_toast_message( assert (WalletNetworkSettings.REVERT_TO_DEFAULT_LIVE_MAINNET_TOAST_MESSAGE.value in
WalletNetworkSettings.REVERT_TO_DEFAULT_LIVE_MAINNET_TOAST_MESSAGE.value) WalletToastMessage().get_toast_messages)
case WalletNetworkSettings.EDIT_NETWORK_TEST_TAB.value: case WalletNetworkSettings.EDIT_NETWORK_TEST_TAB.value:
WalletToastMessage().get_toast_message( assert (WalletNetworkSettings.REVERT_TO_DEFAULT_TEST_MAINNET_TOAST_MESSAGE.value in
WalletNetworkSettings.REVERT_TO_DEFAULT_TEST_MAINNET_TOAST_MESSAGE.value) WalletToastMessage().get_toast_messages)
@allure.step('Verify elements for the edit network view') @allure.step('Verify elements for the edit network view')
def check_available_elements_on_edit_view(self, network_tab): def check_available_elements_on_edit_view(self, network_tab):

View File

@ -28,7 +28,8 @@ def test_switch_testnet_mode(main_screen: MainWindow):
networks.switch_testnet_mode_toggle().click_turn_on_testnet_mode_in_testnet_modal() networks.switch_testnet_mode_toggle().click_turn_on_testnet_mode_in_testnet_modal()
with step('Verify that Testnet mode turned on'): with step('Verify that Testnet mode turned on'):
WalletToastMessage().get_toast_message(WalletNetworkSettings.TESTNET_ENABLED_TOAST_MESSAGE.value) assert WalletNetworkSettings.TESTNET_ENABLED_TOAST_MESSAGE.value in WalletToastMessage().get_toast_messages
assert len(WalletToastMessage().get_toast_messages) == 1
TestnetModeBanner().wait_until_appears() TestnetModeBanner().wait_until_appears()
assert networks.is_testnet_mode_toggle_checked(), f"Testnet toggle if off when it should not" assert networks.is_testnet_mode_toggle_checked(), f"Testnet toggle if off when it should not"