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
from driver import objects_access
import driver
from gui.elements.object import QObject
class WalletToastMessage(QObject):
def __init__(self):
super(WalletToastMessage, self).__init__('ephemeralNotificationList_StatusToastMessage')
self._wallet_toast_messages_list = QObject('mainWallet_Ephemeral_Notification_List')
super(WalletToastMessage, self).__init__('mainWallet_Ephemeral_Notification_List')
self._wallet_toast_message = QObject('ephemeralNotificationList_StatusToastMessage')
@allure.step('Check message at the bottom')
def get_toast_message(self, name: str):
for item in objects_access.walk_children(self._wallet_toast_messages_list.object):
if getattr(item, 'text', '') == name:
return item
raise LookupError(f'Wallet toast message: {name} not found')
@property
@allure.step('Get toast messages')
def get_toast_messages(self):
messages = []
for obj in driver.findAllObjects(self._wallet_toast_message.real_name):
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):
match network_tab:
case WalletNetworkSettings.EDIT_NETWORK_LIVE_TAB.value:
WalletToastMessage().get_toast_message(
WalletNetworkSettings.REVERT_TO_DEFAULT_LIVE_MAINNET_TOAST_MESSAGE.value)
assert (WalletNetworkSettings.REVERT_TO_DEFAULT_LIVE_MAINNET_TOAST_MESSAGE.value in
WalletToastMessage().get_toast_messages)
case WalletNetworkSettings.EDIT_NETWORK_TEST_TAB.value:
WalletToastMessage().get_toast_message(
WalletNetworkSettings.REVERT_TO_DEFAULT_TEST_MAINNET_TOAST_MESSAGE.value)
assert (WalletNetworkSettings.REVERT_TO_DEFAULT_TEST_MAINNET_TOAST_MESSAGE.value in
WalletToastMessage().get_toast_messages)
@allure.step('Verify elements for the edit network view')
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()
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()
assert networks.is_testnet_mode_toggle_checked(), f"Testnet toggle if off when it should not"