From 032a8786ffff6ad928905a4e80d55f9a95b8f41c Mon Sep 17 00:00:00 2001 From: Churikova Tetiana Date: Thu, 16 Dec 2021 17:25:42 +0100 Subject: [PATCH] e2e: fixes Signed-off-by: Churikova Tetiana --- .../atomic/account_management/test_profile.py | 3 ++- .../atomic/chats/test_chats_management.py | 3 +-- .../tests/atomic/chats/test_commands.py | 2 +- .../tests/atomic/chats/test_one_to_one.py | 16 +++++++-------- test/appium/tests/atomic/test_upgrade.py | 7 +++++-- test/appium/views/base_element.py | 6 ++++++ test/appium/views/base_view.py | 20 +++++++++++++++++-- test/appium/views/home_view.py | 5 ++--- test/appium/views/sign_in_view.py | 8 +------- test/appium/views/upgrade_dbs/chats/data.py | 12 +++++------ test/appium/views/wallet_view.py | 15 +++++++------- 11 files changed, 58 insertions(+), 39 deletions(-) diff --git a/test/appium/tests/atomic/account_management/test_profile.py b/test/appium/tests/atomic/account_management/test_profile.py index 04edbe4af4..906cbecf92 100644 --- a/test/appium/tests/atomic/account_management/test_profile.py +++ b/test/appium/tests/atomic/account_management/test_profile.py @@ -1036,7 +1036,7 @@ class TestProfileMultipleDevice(MultipleDeviceTestCase): profile_1.mail_server_button.click() profile_1.use_history_node_button.click() profile_1.home_button.click(desired_view='chat') - if not public_chat_1.chat_element_by_text(message).is_element_displayed(30): + if not public_chat_1.chat_element_by_text(message).is_element_displayed(60): self.errors.append('History was not fetched after enabling use_history_node') self.errors.verify_no_errors() @@ -1287,6 +1287,7 @@ class TestProfileMultipleDevice(MultipleDeviceTestCase): if not channel_2.chat_element_by_text(message_after_sync).is_element_displayed(30): self.errors.append("Message sent to community channel after sync is not shown!") [channel.back_button.click() for channel in (channel_1, channel_2)] + [home.get_chat(comm_before_sync_name, community=True).click() for home in (home_1, home_2)] comm_before_1.add_channel(channel_after_sync) if not comm_before_2.get_chat(channel_after_sync).is_element_displayed(30): self.errors.append("New added channel after sync is not shown!") diff --git a/test/appium/tests/atomic/chats/test_chats_management.py b/test/appium/tests/atomic/chats/test_chats_management.py index 5cfa166d36..99736a0e4b 100644 --- a/test/appium/tests/atomic/chats/test_chats_management.py +++ b/test/appium/tests/atomic/chats/test_chats_management.py @@ -616,7 +616,6 @@ class TestChatManagementMultipleDevice(MultipleDeviceTestCase): device_1.just_fyi('check that new messages from blocked user are not delivered') self.drivers[0].launch_app() device_1.sign_in() - home_1.join_public_chat(chat_name) for message in message_before_block_2, message_after_block_2: if chat_public_1.chat_element_by_text(message).is_element_displayed(): self.errors.append( @@ -1019,7 +1018,7 @@ class TestChatManagementMultipleDevice(MultipleDeviceTestCase): public_1.chat_message_input.send_keys('@') if (chat_1.search_user_in_mention_suggestion_list(ens_nickname_value).is_element_displayed() or chat_1.search_user_in_mention_suggestion_list(sender['username']).is_element_displayed()): - self.errors.append('Blcoked user is available in mention suggestion list') + self.errors.append('Blocked user is available in mention suggestion list') self.errors.verify_no_errors() diff --git a/test/appium/tests/atomic/chats/test_commands.py b/test/appium/tests/atomic/chats/test_commands.py index 14cea887c0..feb2cdd449 100644 --- a/test/appium/tests/atomic/chats/test_commands.py +++ b/test/appium/tests/atomic/chats/test_commands.py @@ -11,7 +11,7 @@ class TestCommandsMultipleDevices(MultipleDeviceTestCase): @marks.critical @marks.transaction def test_send_eth_in_1_1_chat_transaction_push(self): - sender = transaction_senders['A'] + sender = transaction_senders['B'] self.create_drivers(2) device_1, device_2 = SignInView(self.drivers[0]), SignInView(self.drivers[1]) home_1 = device_1.recover_access(passphrase=sender['passphrase'], enable_notifications=True) diff --git a/test/appium/tests/atomic/chats/test_one_to_one.py b/test/appium/tests/atomic/chats/test_one_to_one.py index 78a0986442..768eda31cb 100644 --- a/test/appium/tests/atomic/chats/test_one_to_one.py +++ b/test/appium/tests/atomic/chats/test_one_to_one.py @@ -208,7 +208,7 @@ class TestMessagesOneToOneChatMultiple(MultipleDeviceTestCase): message_before_edit, message_after_edit = "Message BEFORE edit 1", "Message AFTER edit 2" public_chat_1.send_message(message_before_edit) public_chat_1.edit_message_in_chat(message_before_edit, message_after_edit) - if not public_chat_1.element_by_text_part("⌫ Edited").is_element_displayed(): + if not public_chat_1.element_by_text_part("⌫ Edited").is_element_displayed(60): self.errors.append('No mark in message bubble about this message was edited') device_2.just_fyi( @@ -223,9 +223,9 @@ class TestMessagesOneToOneChatMultiple(MultipleDeviceTestCase): if not home_1.element_by_text_part(message_after_edit_1_1).is_element_present(): self.errors.append('UNedited message version displayed on preview') chat_private_1 = device_1_one_to_one_chat_element.click() - if not home_1.element_by_text_part(message_after_edit_1_1).is_element_present(): + if not home_1.element_by_text_part(message_after_edit_1_1).is_element_present(30): self.errors.append('No edited message in 1-1 chat displayed') - if not home_1.element_by_text_part("⌫ Edited").is_element_present(): + if not home_1.element_by_text_part("⌫ Edited").is_element_present(30): self.errors.append('No mark in message bubble about this message was edited on receiver side') device_2.just_fyi("Verify Device1 can not edit and delete received message from Device2") @@ -238,10 +238,10 @@ class TestMessagesOneToOneChatMultiple(MultipleDeviceTestCase): device_2.just_fyi("Delete message and check it is not shown in chat preview on home") chat_private_2.delete_message_in_chat(message_after_edit_1_1) for chat in (chat_private_2, chat_private_1): - if chat.chat_element_by_text(message_after_edit_1_1).is_element_displayed(): + if chat.chat_element_by_text(message_after_edit_1_1).is_element_displayed(30): self.errors.append("Deleted message is shown in chat view for 1-1 chat") chat_private_1.home_button.double_click() - if home_1.element_by_text(message_after_edit_1_1).is_element_displayed(): + if home_1.element_by_text(message_after_edit_1_1).is_element_displayed(30): self.errors.append("Deleted message is shown on chat element on home screen") device_2.just_fyi("Send one more message and check that PN will be deleted with message deletion") @@ -258,13 +258,13 @@ class TestMessagesOneToOneChatMultiple(MultipleDeviceTestCase): chat_private_2.just_fyi("Check for that edited message is shown for Device 2 and delete message in public chat") [home.home_button.double_click() for home in (home_1, home_2)] public_chat_1, public_chat_2 = home_1.get_chat('#%s' % chat_name).click(), home_2.join_public_chat(chat_name) - if not public_chat_2.element_by_text_part("⌫ Edited").is_element_displayed(): + if not public_chat_2.element_by_text_part("⌫ Edited").is_element_displayed(60): self.errors.append('No mark in message bubble about this message was edited') - if not public_chat_2.element_by_text_part(message_after_edit).is_element_displayed(): + if not public_chat_2.element_by_text_part(message_after_edit).is_element_displayed(60): self.errors.append('Message is not edited.') public_chat_1.delete_message_in_chat(message_after_edit) for chat in (public_chat_1, public_chat_2): - if chat.chat_element_by_text(message_after_edit).is_element_displayed(): + if chat.chat_element_by_text(message_after_edit).is_element_displayed(30): self.errors.append("Deleted message is shown in chat view for public chat") self.errors.verify_no_errors() diff --git a/test/appium/tests/atomic/test_upgrade.py b/test/appium/tests/atomic/test_upgrade.py index c057b4ba27..849c175132 100644 --- a/test/appium/tests/atomic/test_upgrade.py +++ b/test/appium/tests/atomic/test_upgrade.py @@ -13,6 +13,7 @@ import views.upgrade_dbs.group.data as group class TestUpgradeApplication(SingleDeviceTestCase): @marks.testrail_id(6284) + @marks.flaky def test_unread_previews_public_chat_version_upgrade(self): sign_in = SignInView(self.driver) unread_one_to_one_name, unread_public_name = 'All Whopping Dassierat', '#before-upgrade' @@ -117,8 +118,8 @@ class TestUpgradeApplication(SingleDeviceTestCase): public_chat = home.get_chat(mention).click() public_chat.scroll_to_start_of_history() pub_chat_data = chats[mention] + public_chat.element_starts_with_text(pub_chat_data['reply']).scroll_to_element() public_replied_message = public_chat.chat_element_by_text(pub_chat_data['reply']) - public_replied_message.scroll_to_element() if pub_chat_data['long'] not in public_replied_message.replied_message_text: self.errors.append("Reply is not present in message received in public chat %s after upgrade" % mention) public_chat.element_starts_with_text(pub_chat_data['mention']).scroll_to_element() @@ -477,6 +478,7 @@ class TestUpgradeMultipleApplication(MultipleDeviceTestCase): self.errors.verify_no_errors() @marks.testrail_id(695812) + @marks.flaky def test_devices_activity_centre_profile_settings_upgrade(self): self.create_drivers(2) user = ens_user @@ -524,7 +526,8 @@ class TestUpgradeMultipleApplication(MultipleDeviceTestCase): if not profile_1.accept_new_chats_from_contacts_only.is_element_displayed(): self.errors.append("Accept contacts from setting is not preserved after upgrade!") profile_1.profile_button.click() - profile_1.appearance_button.click() + profile_1.privacy_and_security_button.click() + profile_1.show_profile_pictures_of.scroll_to_element() if not profile_1.show_profile_pictures_of.is_element_image_similar_to_template('block_dark.png'): self.errors.append('Dark mode is not applied!') if not profile_1.element_by_translation_id("everyone").is_element_displayed(): diff --git a/test/appium/views/base_element.py b/test/appium/views/base_element.py index 1760482ad5..ae59a93b4e 100644 --- a/test/appium/views/base_element.py +++ b/test/appium/views/base_element.py @@ -399,3 +399,9 @@ class SilentButton(Button): def text(self): text = self.find_element().text return text + + +class CheckBox(Button): + def click(self): + super(CheckBox, self).click_until_presence_of_element(Button(self.driver, accessibility_id="checkbox-on")) + return self.navigate() diff --git a/test/appium/views/base_view.py b/test/appium/views/base_view.py index 4edf4d0ebe..f7f9a1fd6e 100644 --- a/test/appium/views/base_view.py +++ b/test/appium/views/base_view.py @@ -13,7 +13,7 @@ from selenium.common.exceptions import NoSuchElementException, TimeoutException from support.device_apps import start_web_browser from tests import common_password, pytest_config_global, transl -from views.base_element import Button, BaseElement, EditBox, Text +from views.base_element import Button, BaseElement, EditBox, Text, CheckBox class BackButton(Button): @@ -26,6 +26,7 @@ class BackButton(Button): return self.navigate() + class AllowButton(Button): def __init__(self, driver): super().__init__(driver, translation_id="allow", uppercase=True) @@ -191,9 +192,21 @@ class AirplaneModeButton(Button): def __init__(self, driver): super().__init__(driver, accessibility_id="Airplane mode") - def click(self): + def open_quick_action_menu(self): action = TouchAction(self.driver) action.press(None, 200, 0).move_to(None, 200, 300).perform() + + def click(self): + counter = 0 + desired_element = AirplaneModeButton(self.driver) + while not desired_element.is_element_present() and counter <= 3: + try: + self.open_quick_action_menu() + desired_element.wait_for_element(5) + except (NoSuchElementException, TimeoutException): + counter += 1 + else: + self.driver.info("%s element not found" % desired_element.name) super(AirplaneModeButton, self).click() self.driver.press_keycode(4) @@ -252,6 +265,9 @@ class BaseView(object): self.qr_code_image = Button(self.driver, accessibility_id="qr-code-image") self.sign_in_phrase = SignInPhraseText(self.driver) + # checkboxes and toggles + self.checkbox_button = CheckBox(self.driver, accessibility_id="checkbox-off") + # external browser self.open_in_status_button = OpenInStatusButton(self.driver) diff --git a/test/appium/views/home_view.py b/test/appium/views/home_view.py index 42c527ffb8..969f9a4cb0 100644 --- a/test/appium/views/home_view.py +++ b/test/appium/views/home_view.py @@ -1,6 +1,6 @@ import time from selenium.common.exceptions import TimeoutException, NoSuchElementException -from views.base_element import Button, Text, BaseElement, SilentButton +from views.base_element import Button, Text, BaseElement, SilentButton, CheckBox from views.base_view import BaseView from tests import test_dapp_url @@ -211,8 +211,7 @@ class HomeView(BaseView): # Sync using mobile data bottom sheet self.continue_syncing_button = Button(self.driver, accessibility_id="mobile-network-continue-syncing") self.stop_syncing_button = Button(self.driver, accessibility_id="mobile-network-stop-syncing") - self.remember_my_choice_checkbox = Button(self.driver, xpath="//*[@content-desc='remember-choice']" - "//*[@content-desc='checkbox']") + self.remember_my_choice_checkbox = CheckBox(self.driver, accessibility_id=":checkbox-on") # Connection status bottom sheet self.connected_to_n_peers_text = Text(self.driver, accessibility_id="connected-to-n-peers") diff --git a/test/appium/views/sign_in_view.py b/test/appium/views/sign_in_view.py index f38c5286c8..03cbfb6bb6 100644 --- a/test/appium/views/sign_in_view.py +++ b/test/appium/views/sign_in_view.py @@ -144,7 +144,7 @@ class SignInView(BaseView): self.first_username_on_choose_chat_name = Text(self.driver, xpath="//*[@content-desc='select-account-button-0']//android.widget.TextView[1]") self.get_keycard_banner = Button(self.driver, translation_id="get-a-keycard") - self.accept_tos_checkbox = Button(self.driver, xpath="//android.widget.CheckBox[@content-desc='checkbox']") + self.accept_tos_checkbox = self.checkbox_button # keycard recovery self.recover_with_keycard_button = Button(self.driver, accessibility_id="recover-with-keycard-button") @@ -178,9 +178,6 @@ class SignInView(BaseView): if not second_user: self.accept_tos_checkbox.click() self.get_started_button.click_until_presence_of_element(self.generate_key_button) - if not self.generate_key_button.is_element_displayed(): - [button.click() for button in - [self.accept_tos_checkbox, self.get_started_button, self.generate_key_button]] self.generate_key_button.click() self.next_button.click_until_absense_of_element(self.element_by_translation_id("intro-wizard-title2")) @@ -209,9 +206,6 @@ class SignInView(BaseView): if not second_user: self.accept_tos_checkbox.click() self.get_started_button.click_until_presence_of_element(self.access_key_button) - if not self.access_key_button.is_element_displayed(): - self.accept_tos_checkbox.click() - self.get_started_button.click() self.access_key_button.click() self.enter_seed_phrase_button.click() self.seedphrase_input.click() diff --git a/test/appium/views/upgrade_dbs/chats/data.py b/test/appium/views/upgrade_dbs/chats/data.py index 60e03781dd..b66e41599c 100644 --- a/test/appium/views/upgrade_dbs/chats/data.py +++ b/test/appium/views/upgrade_dbs/chats/data.py @@ -55,21 +55,21 @@ chats = { 'preview':'Request address for transaction accepted', 'messages': { 'audio': { - 'length':'00:10', - 'timestamp' : '1:02 PM' + 'length': '00:10', + 'timestamp': '1:02 PM' }, }, 'commands':{ - 'incoming_ETH_shared':{ - 'value':'0.01 ETH', + 'incoming_ETH_shared': { + 'value': '0.01 ETHro', 'status': "Shared 'Ethereum account'" }, 'incoming_ETH_confirmed': { - 'value': '0.1 ETH', + 'value': '0.1 ETHro', 'status': transl["status-confirmed"] }, 'incoming_ETH_declined': { - 'value': '20 ETH', + 'value': '20 ETHro', 'status': transl["transaction-declined"] }, 'incoming_STT_confirmed': { diff --git a/test/appium/views/wallet_view.py b/test/appium/views/wallet_view.py index 3e16c5bfd3..daeeb826a5 100644 --- a/test/appium/views/wallet_view.py +++ b/test/appium/views/wallet_view.py @@ -1,7 +1,7 @@ import time from tests import common_password -from views.base_element import Button, Text, EditBox, SilentButton +from views.base_element import Button, Text, EditBox, SilentButton, CheckBox from views.base_view import BaseView @@ -14,12 +14,13 @@ class TransactionHistoryButton(Button): return TransactionsView(self.driver) -class AssetCheckBox(SilentButton): +class AssetCheckBox(CheckBox): def __init__(self, driver, asset_name): super().__init__(driver, xpath="//*[@text='%s']" % asset_name) def click(self): - self.scroll_to_element(12).click() + self.scroll_to_element(12) + self.click() class BackupRecoveryPhrase(Button): @@ -101,12 +102,12 @@ class WalletView(BaseView): self.manage_assets_button = Button(self.driver, accessibility_id="wallet-manage-assets") self.manage_accounts_button = Button(self.driver, accessibility_id="wallet-manage-accounts") self.scan_tokens_button = Button(self.driver, accessibility_id="wallet-scan-token") - self.stt_check_box = Button(self.driver, - xpath="//*[@text='STT']/../android.view.ViewGroup[@content-desc='checkbox']") + self.stt_check_box = CheckBox(self.driver, + xpath="//*[@text='STT']/../android.view.ViewGroup[@content-desc='checkbox-off']") self.all_assets_full_names = Text(self.driver, - xpath="//*[@content-desc='checkbox']/../android.widget.TextView[1]") + xpath="//*[@content-desc='checkbox-off']/../android.widget.TextView[1]") self.all_assets_symbols = Button(self.driver, - xpath="//*[@content-desc='checkbox']/../android.widget.TextView[2]") + xpath="//*[@content-desc='checkbox-off']/../android.widget.TextView[2]") self.currency_item_text = Text(self.driver, xpath="//*[@content-desc='currency-item']//android.widget.TextView") self.address_text = Text(self.driver, accessibility_id="address-text")