From 92403f5d30c5cb163b11dd0bb4368c55079813df Mon Sep 17 00:00:00 2001 From: Yevheniia Berdnyk Date: Fri, 18 Aug 2023 19:20:40 +0300 Subject: [PATCH] e2e: fix for navigation issue --- .../critical/chats/test_1_1_public_chats.py | 34 +++++++++---------- .../tests/critical/chats/test_group_chat.py | 32 ++++++++--------- .../onboarding/test_onboarding_flows.py | 4 +-- .../critical/test_pairing_devices_sync.py | 2 +- .../critical/test_public_chat_browsing.py | 34 +++++++++---------- .../tests/medium/test_activity_center.py | 10 +++--- .../tests/medium/test_browser_profile.py | 4 +-- .../test_deeplink_chat_share_profile.py | 6 ++-- test/appium/views/base_view.py | 28 ++++++++++----- test/appium/views/home_view.py | 7 ++-- test/appium/views/profile_view.py | 4 +-- 11 files changed, 87 insertions(+), 78 deletions(-) diff --git a/test/appium/tests/critical/chats/test_1_1_public_chats.py b/test/appium/tests/critical/chats/test_1_1_public_chats.py index a683ba9840..4fc295c4aa 100644 --- a/test/appium/tests/critical/chats/test_1_1_public_chats.py +++ b/test/appium/tests/critical/chats/test_1_1_public_chats.py @@ -845,7 +845,7 @@ class TestOneToOneChatMultipleSharedDevicesNewUi(MultipleSharedDeviceTestCase): self.profile_1.just_fyi("Sending contact request via Profile > Contacts") for home in (self.home_1, self.home_2): - home.click_system_back_button_until_element_is_shown() + home.navigate_back_to_home_view() home.chats_tab.click() self.home_1.send_contact_request_via_bottom_sheet(self.public_key_2) @@ -855,7 +855,7 @@ class TestOneToOneChatMultipleSharedDevicesNewUi(MultipleSharedDeviceTestCase): self.profile_1.just_fyi("Sending message to contact via Messages > Recent") self.chat_1 = self.home_1.get_chat(self.username_2).click() self.chat_1.send_message('hey') - self.home_2.click_system_back_button_until_element_is_shown() + self.home_2.navigate_back_to_home_view() self.chat_2 = self.home_2.get_chat(self.username_1).click() self.message_1, self.message_2, self.message_3, self.message_4 = \ "Message 1", "Message 2", "Message 3", "Message 4" @@ -919,9 +919,7 @@ class TestOneToOneChatMultipleSharedDevicesNewUi(MultipleSharedDeviceTestCase): @marks.testrail_id(702782) def test_1_1_chat_emoji_send_reply_and_open_link(self): for chat in self.chat_1, self.chat_2: - element = chat.chat_message_input - if not element.is_element_displayed(): - chat.click_system_back_button_until_element_is_shown(element) + chat.navigate_back_to_chat_view() self.home_1.just_fyi("Check that can send emoji in 1-1 chat") emoji_name = random.choice(list(emoji.EMOJI_UNICODE)) emoji_unicode = emoji.EMOJI_UNICODE[emoji_name] @@ -1086,14 +1084,14 @@ class TestOneToOneChatMultipleSharedDevicesNewUi(MultipleSharedDeviceTestCase): self.home_1.jump_to_messages_home() self.home_1.profile_button.click() self.profile_1.edit_profile_picture('sauce_logo.png') - self.profile_1.click_system_back_button_until_element_is_shown() + self.profile_1.navigate_back_to_home_view() self.profile_1.chats_tab.click() self.chat_2.just_fyi("Send messages with non-latin symbols") self.home_1.jump_to_card_by_text(self.username_2) self.chat_1.send_message("just a text") # Sending a message here so the next ones will be in a separate line - self.home_2.click_system_back_button_until_element_is_shown() + self.home_2.navigate_back_to_home_view() self.home_2.jump_to_card_by_text(self.username_1) messages = ['hello', '¿Cómo estás tu año?', 'ё, доброго вечерочка', '® æ ç ♥'] [self.chat_2.send_message(message) for message in messages] @@ -1132,7 +1130,7 @@ class TestOneToOneChatMultipleSharedDevicesNewUi(MultipleSharedDeviceTestCase): def test_1_1_chat_push_emoji(self): message_no_pn, message = 'No PN', 'Text push notification' - [home.click_system_back_button_until_element_is_shown() for home in self.homes] + [home.navigate_back_to_home_view() for home in self.homes] self.home_2.profile_button.click() self.home_1.chats_tab.click() @@ -1144,7 +1142,7 @@ class TestOneToOneChatMultipleSharedDevicesNewUi(MultipleSharedDeviceTestCase): self.chat_1.send_message(message) self.device_1.just_fyi("Device 1 puts app on background to receive emoji push notification") - self.device_1.click_system_back_button_until_element_is_shown() + self.device_1.navigate_back_to_home_view() self.device_1.profile_button.click() self.device_2.just_fyi("Check text push notification and tap it") @@ -1182,7 +1180,7 @@ class TestOneToOneChatMultipleSharedDevicesNewUi(MultipleSharedDeviceTestCase): @marks.testrail_id(702855) def test_1_1_chat_edit_message(self): - [home.click_system_back_button_until_element_is_shown() for home in self.homes] + [home.navigate_back_to_home_view() for home in self.homes] self.chat_2.jump_to_card_by_text(self.username_1) self.chat_1.jump_to_card_by_text(self.username_2) @@ -1237,7 +1235,7 @@ class TestOneToOneChatMultipleSharedDevicesNewUi(MultipleSharedDeviceTestCase): except TimeoutException: self.errors.append( "%s can't share an image via Gmail." % ("Sender" if chat is self.chat_1 else "Receiver")) - chat.click_system_back_button_until_element_is_shown(element="chat") + chat.navigate_back_to_chat_view() for chat in self.chat_1, self.chat_2: chat.just_fyi("Open the image and save it") @@ -1254,7 +1252,7 @@ class TestOneToOneChatMultipleSharedDevicesNewUi(MultipleSharedDeviceTestCase): toast_element_text, chat.get_translation_by_key("photo-saved"), device_name)) else: self.errors.append("Message about saving a photo is not shown for %s." % device_name) - chat.click_system_back_button_until_element_is_shown(element="chat") + chat.navigate_back_to_chat_view() for chat in self.chat_1, self.chat_2: chat.just_fyi("Check that image is saved in gallery") @@ -1307,7 +1305,7 @@ class TestOneToOneChatMultipleSharedDevicesNewUi(MultipleSharedDeviceTestCase): for chat in (self.chat_2, self.chat_1): 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") - self.chat_1.click_system_back_button_until_element_is_shown() + self.chat_1.navigate_back_to_home_view() if self.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") @@ -1325,7 +1323,7 @@ class TestOneToOneChatMultipleSharedDevicesNewUi(MultipleSharedDeviceTestCase): if pn_to_disappear: if not pn_to_disappear.is_element_disappeared(90): self.errors.append("Push notification was not removed after initial message deletion") - [device.click_system_back_button_until_element_is_shown() for device in (self.device_1, self.device_2)] + [device.navigate_back_to_home_view() for device in (self.device_1, self.device_2)] self.errors.verify_no_errors() @marks.testrail_id(702783) @@ -1380,7 +1378,7 @@ class TestOneToOneChatMultipleSharedDevicesNewUi(MultipleSharedDeviceTestCase): @marks.testrail_id(703496) def test_1_1_chat_mute_chat(self): - self.home_1.click_system_back_button_until_element_is_shown() + self.home_1.navigate_back_to_home_view() self.home_1.chats_tab.click() self.home_1.just_fyi("Mute chat") self.home_1.mute_chat_long_press(self.username_2) @@ -1397,13 +1395,13 @@ class TestOneToOneChatMultipleSharedDevicesNewUi(MultipleSharedDeviceTestCase): self.errors.append("Message '%s' is not shown in chat for receiver after mute" % muted_message) self.chat_1.just_fyi("Unmute chat") - self.chat_1.click_system_back_button_until_element_is_shown() + self.chat_1.navigate_back_to_home_view() chat.long_press_element() if self.home_1.mute_chat_button.text != transl["unmute-chat"]: self.errors.append("Chat is not muted") expected_text = "Muted until you turn it back on" if not self.home_1.element_by_text(expected_text).is_element_displayed(): - self.errors.append("Text '%s' is not shown for muted chat" %expected_text) + self.errors.append("Text '%s' is not shown for muted chat" % expected_text) self.home_1.mute_chat_button.click() unmuted_message = "after unmute" @@ -1421,7 +1419,7 @@ class TestOneToOneChatMultipleSharedDevicesNewUi(MultipleSharedDeviceTestCase): @marks.testrail_id(702784) def test_1_1_chat_delete_via_long_press_relogin(self): - self.home_2.click_system_back_button_until_element_is_shown() + self.home_2.navigate_back_to_home_view() self.home_2.chats_tab.click() self.home_2.just_fyi("Deleting chat via delete button and check it will not reappear after relaunching app") diff --git a/test/appium/tests/critical/chats/test_group_chat.py b/test/appium/tests/critical/chats/test_group_chat.py index c540ed8203..0bf52db2c3 100644 --- a/test/appium/tests/critical/chats/test_group_chat.py +++ b/test/appium/tests/critical/chats/test_group_chat.py @@ -178,7 +178,7 @@ class TestGroupChatMultipleDeviceMergedNewUI(MultipleSharedDeviceTestCase): self.homes[0].just_fyi('Admin adds future members to contacts') for i in range(3): - self.homes[i].click_system_back_button_until_element_is_shown() + self.homes[i].navigate_back_to_home_view() self.homes[i].chats_tab.click() for i in range(1, 3): @@ -194,7 +194,7 @@ class TestGroupChatMultipleDeviceMergedNewUI(MultipleSharedDeviceTestCase): ) ) for i in range(1, 3): - self.homes[i].click_system_back_button_until_element_is_shown() + self.homes[i].navigate_back_to_home_view() self.homes[0].just_fyi('Admin creates group chat') self.chat_name = self.homes[0].get_random_chat_name() @@ -209,7 +209,7 @@ class TestGroupChatMultipleDeviceMergedNewUI(MultipleSharedDeviceTestCase): @marks.testrail_id(702807) def test_group_chat_join_send_text_messages_push(self): message_to_admin = self.message_to_admin - [self.homes[i].click_system_back_button_until_element_is_shown() for i in range(3)] + [self.homes[i].navigate_back_to_home_view() for i in range(3)] self.homes[1].get_chat(self.chat_name).click() self.chats[1].send_message(message_to_admin) @@ -232,7 +232,7 @@ class TestGroupChatMultipleDeviceMergedNewUI(MultipleSharedDeviceTestCase): @marks.testrail_id(703202) def test_group_chat_reactions(self): - [self.homes[i].click_system_back_button_until_element_is_shown() for i in range(3)] + [self.homes[i].navigate_back_to_home_view() for i in range(3)] [self.homes[i].get_chat(self.chat_name).click() for i in range(3)] message = "This is a test message to check some reactions." self.chats[0].just_fyi("Admin sends a message") @@ -284,7 +284,7 @@ class TestGroupChatMultipleDeviceMergedNewUI(MultipleSharedDeviceTestCase): ) except NoSuchElementException: self.errors.append("User profile was not opened from the list of reactions") - self.chats[0].click_system_back_button_until_element_is_shown(element="chat") + self.chats[0].navigate_back_to_chat_view() self.chats[1].just_fyi("Member_1 removes 'thumbs-up' reaction and adds 'sad' one") self.chats[1].add_remove_same_reaction(message=message, emoji="thumbs-up") @@ -319,7 +319,7 @@ class TestGroupChatMultipleDeviceMergedNewUI(MultipleSharedDeviceTestCase): for chat in self.chats[1], self.chats[2]: chat.just_fyi("Just making the session not to quit") - chat.click_system_back_button_until_element_is_shown() + chat.navigate_back_to_home_view() self.chats[0].just_fyi("Admin checks info about voted users after relogin") message_element.emojis_below_message( @@ -345,7 +345,7 @@ class TestGroupChatMultipleDeviceMergedNewUI(MultipleSharedDeviceTestCase): @marks.testrail_id(703297) def test_group_chat_send_image_save_and_share(self): - [self.homes[i].click_system_back_button_until_element_is_shown() for i in range(3)] + [self.homes[i].navigate_back_to_home_view() for i in range(3)] for i in range(3): self.homes[i].get_chat(self.chat_name).click() @@ -373,9 +373,9 @@ class TestGroupChatMultipleDeviceMergedNewUI(MultipleSharedDeviceTestCase): self.chats[0].wait_for_current_package_to_be('com.google.android.gm') except TimeoutException: self.errors.append("Admin can't share an image via Gmail.") - self.chats[0].click_system_back_button_until_element_is_shown(element="chat") + self.chats[0].navigate_back_to_chat_view() - self.chats[1].click_system_back_button_until_element_is_shown() + self.chats[1].navigate_back_to_home_view() self.chats[2].just_fyi("Member_2 opens the image and saves it") self.chats[2].chat_element_by_text(image_description).image_in_message.click() @@ -390,22 +390,22 @@ class TestGroupChatMultipleDeviceMergedNewUI(MultipleSharedDeviceTestCase): toast_element_text, self.chats[2].get_translation_by_key("photo-saved"))) else: self.errors.append("Message about saving a photo is not shown for member_2.") - self.chats[2].click_system_back_button_until_element_is_shown(element="chat") + self.chats[2].navigate_back_to_chat_view() self.chats[2].just_fyi("Member_2 checks that image was saved in gallery") self.chats[2].show_images_button.click() self.chats[2].allow_button.click_if_shown() if not self.chats[2].get_image_by_index(0).is_element_image_similar_to_template("saucelabs_sauce_gallery.png"): self.errors.append("Image is not saved to gallery for member_2.") - self.chats[2].click_system_back_button_until_element_is_shown(element="chat") + self.chats[2].navigate_back_to_chat_view() self.errors.verify_no_errors() @marks.testrail_id(702808) def test_group_chat_offline_pn(self): - self.homes[0].click_system_back_button_until_element_is_shown() - [self.homes[i].jump_to_messages_home() for i in range(3)] for i in range(1, 3): + self.homes[i].navigate_back_to_home_view() + self.homes[i].chats_tab.click() self.homes[i].groups_tab.click() self.homes[i].get_chat(self.chat_name).click() @@ -443,7 +443,7 @@ class TestGroupChatMultipleDeviceMergedNewUI(MultipleSharedDeviceTestCase): @marks.xfail(reason="Pin feature is in development", run=False) @marks.testrail_id(702732) def test_group_chat_pin_messages(self): - [self.homes[i].click_system_back_button_until_element_is_shown() for i in range(3)] + [self.homes[i].navigate_back_to_home_view() for i in range(3)] [self.homes[i].get_chat(self.chat_name).click() for i in range(3)] self.message_1, self.message_2, self.message_3, self.message_4 = \ @@ -522,7 +522,7 @@ class TestGroupChatMultipleDeviceMergedNewUI(MultipleSharedDeviceTestCase): @marks.testrail_id(703495) def test_group_chat_mute_chat(self): - [self.homes[i].click_system_back_button_until_element_is_shown() for i in range(3)] + [self.homes[i].navigate_back_to_home_view() for i in range(3)] self.homes[1].just_fyi("Member 1 mutes the chat for 1 hour") self.homes[1].mute_chat_long_press(self.chat_name, "mute-for-1-hour") @@ -564,7 +564,7 @@ class TestGroupChatMultipleDeviceMergedNewUI(MultipleSharedDeviceTestCase): if not self.chats[1].chat_element_by_text(muted_message).is_element_displayed(30): self.errors.append( "Message '%s' is not shown in chat for %s after mute" % (muted_message, self.usernames[1])) - self.chats[1].click_system_back_button_until_element_is_shown() + self.chats[1].navigate_back_to_home_view() self.chats[1].just_fyi("Change device time so chat will be unmuted by timer") unmute_time = current_time + datetime.timedelta(minutes=61) diff --git a/test/appium/tests/critical/onboarding/test_onboarding_flows.py b/test/appium/tests/critical/onboarding/test_onboarding_flows.py index a01831e87e..3781d5403e 100644 --- a/test/appium/tests/critical/onboarding/test_onboarding_flows.py +++ b/test/appium/tests/critical/onboarding/test_onboarding_flows.py @@ -52,7 +52,7 @@ class TestOnboardingOneDeviceMerged(MultipleSharedDeviceTestCase): self.profile.share_via_messenger() if not self.profile.element_by_text_part(public_key).is_element_displayed(): self.errors.append("Can't share public key") - self.profile.click_system_back_button_until_element_is_shown() + self.profile.navigate_back_to_home_view() self.home.just_fyi("Check that can paste contact code in chat message input") self.profile.home_button.double_click() @@ -80,7 +80,7 @@ class TestOnboardingOneDeviceMerged(MultipleSharedDeviceTestCase): wallet.share_via_messenger() if not wallet.element_by_text_part(address).is_element_displayed(): self.errors.append("Can't share address") - wallet.click_system_back_button_until_element_is_shown() + wallet.navigate_back_to_home_view() self.home.just_fyi("Check that can paste wallet address in chat message input") wallet.home_button.click() diff --git a/test/appium/tests/critical/test_pairing_devices_sync.py b/test/appium/tests/critical/test_pairing_devices_sync.py index 5912043cb1..d49ec96139 100644 --- a/test/appium/tests/critical/test_pairing_devices_sync.py +++ b/test/appium/tests/critical/test_pairing_devices_sync.py @@ -151,7 +151,7 @@ class TestPairingSyncMultipleDevicesMerged(MultipleSharedDeviceTestCase): web_page = dapp.open_url('status.im') web_page.add_to_bookmarks() if not web_page.home_button.is_element_displayed(): - web_page.click_system_back_button_until_element_is_shown() + web_page.navigate_back_to_home_view() self.home_1.just_fyi("Close the ENS banner") [home.home_button.double_click() for home in (self.home_1, self.home_2)] diff --git a/test/appium/tests/critical/test_public_chat_browsing.py b/test/appium/tests/critical/test_public_chat_browsing.py index 0f133a6fe7..bc712052e2 100644 --- a/test/appium/tests/critical/test_public_chat_browsing.py +++ b/test/appium/tests/critical/test_public_chat_browsing.py @@ -343,7 +343,7 @@ class TestCommunityOneDeviceMerged(MultipleSharedDeviceTestCase): def test_community_navigate_to_channel_when_relaunch(self): text_message = 'some_text' if not self.channel.chat_message_input.is_element_displayed(): - self.home.click_system_back_button_until_element_is_shown() + self.home.navigate_back_to_home_view() self.home.get_to_community_channel_from_home(self.community_name) self.channel.send_message(text_message) @@ -355,7 +355,7 @@ class TestCommunityOneDeviceMerged(MultipleSharedDeviceTestCase): def test_community_copy_and_paste_message_in_chat_input(self): message_texts = ['mmmeowesage_text', 'https://status.im'] if not self.channel.chat_message_input.is_element_displayed(): - self.home.click_system_back_button_until_element_is_shown() + self.home.navigate_back_to_home_view() self.home.get_to_community_channel_from_home(self.community_name) for message in message_texts: @@ -371,7 +371,7 @@ class TestCommunityOneDeviceMerged(MultipleSharedDeviceTestCase): @marks.testrail_id(702869) def test_community_undo_delete_message(self): if not self.channel.chat_message_input.is_element_displayed(): - self.home.click_system_back_button_until_element_is_shown() + self.home.navigate_back_to_home_view() self.home.get_to_community_channel_from_home(self.community_name) message_to_delete = "message to delete and undo" self.channel.send_message(message_to_delete) @@ -494,7 +494,7 @@ class TestCommunityOneDeviceMerged(MultipleSharedDeviceTestCase): if not pytest_config_global['pr_number']: self.home.just_fyi("Perform back up") - self.home.click_system_back_button_until_element_is_shown() + self.home.navigate_back_to_home_view() self.home.profile_button.click() profile.sync_settings_button.click() profile.backup_settings_button.click() @@ -542,7 +542,7 @@ class TestCommunityMultipleDeviceMerged(MultipleSharedDeviceTestCase): self.homes = self.home_1, self.home_2 = self.device_1.get_home_view(), self.device_2.get_home_view() self.public_key_2 = self.home_2.get_public_key_via_share_profile_tab() self.profile_1 = self.home_1.get_profile_view() - [home.click_system_back_button_until_element_is_shown() for home in self.homes] + [home.navigate_back_to_home_view() for home in self.homes] [home.chats_tab.click() for home in self.homes] self.home_1.add_contact(self.public_key_2) self.home_2.handle_contact_request(self.username_1) @@ -554,7 +554,7 @@ class TestCommunityMultipleDeviceMerged(MultipleSharedDeviceTestCase): self.chat_2 = self.home_2.get_chat(self.username_1).click() # self.chat_2.send_message(self.text_message) # [home.click_system_back_button_until_element_is_shown() for home in self.homes] - self.home_1.click_system_back_button_until_element_is_shown() + self.home_1.navigate_back_to_home_view() self.home_1.just_fyi("Open community to message") self.home_1.communities_tab.click() @@ -665,7 +665,7 @@ class TestCommunityMultipleDeviceMerged(MultipleSharedDeviceTestCase): else: self.errors.append("Image options button is not shown for an image from gallery.") - self.channel_2.click_system_back_button_until_element_is_shown(element="chat") + self.channel_2.navigate_back_to_chat_view() self.channel_2.just_fyi("Can reply to gallery") self.channel_2.quote_message(image_description) @@ -707,7 +707,7 @@ class TestCommunityMultipleDeviceMerged(MultipleSharedDeviceTestCase): toast_element_text, self.channel_1.get_translation_by_key("photo-saved"))) else: self.errors.append("Message about saving a photo is not shown.") - self.channel_1.click_system_back_button_until_element_is_shown(element="chat") + self.channel_1.navigate_back_to_chat_view() self.channel_1.just_fyi("Check that image is saved in gallery") self.channel_1.show_images_button.click() @@ -725,7 +725,7 @@ class TestCommunityMultipleDeviceMerged(MultipleSharedDeviceTestCase): self.channel_2.wait_for_current_package_to_be('com.google.android.gm') except TimeoutException: self.errors.append("Can't share image") - self.channel_2.click_system_back_button_until_element_is_shown(element="chat") + self.channel_2.navigate_back_to_chat_view() self.channel_2.just_fyi("Can reply to images") self.channel_2.quote_message(image_description) @@ -818,7 +818,7 @@ class TestCommunityMultipleDeviceMerged(MultipleSharedDeviceTestCase): } for home in self.home_1, self.home_2: if not home.chat_floating_screen.is_element_displayed(): - home.click_system_back_button_until_element_is_shown() + home.navigate_back_to_home_view() home.get_to_community_channel_from_home(self.community_name) for key, data in preview_urls.items(): @@ -935,7 +935,7 @@ class TestCommunityMultipleDeviceMerged(MultipleSharedDeviceTestCase): profile_1.element_by_text(self.username_2).click() self.chat_1.unblock_contact_button.click() self.chat_1.close_button.click() - self.chat_1.click_system_back_button_until_element_is_shown() + self.chat_1.navigate_back_to_home_view() self.home_2.just_fyi("Check that can send message in community after unblock") self.chat_2.send_message(message_unblocked) @@ -979,7 +979,7 @@ class TestCommunityMultipleDeviceMerged(MultipleSharedDeviceTestCase): @marks.testrail_id(703086) def test_community_mark_all_messages_as_read(self): for home in self.home_1, self.home_2: - home.click_system_back_button_until_element_is_shown() + home.navigate_back_to_home_view() home.communities_tab.click() self.home_2.get_chat(self.community_name, community=True).click() self.community_2.get_channel(self.channel_name).click() @@ -1003,9 +1003,9 @@ class TestCommunityMultipleDeviceMerged(MultipleSharedDeviceTestCase): @marks.testrail_id(702786) def test_community_mentions_push_notification(self): - self.home_1.click_system_back_button_until_element_is_shown() + self.home_1.navigate_back_to_home_view() if not self.channel_2.chat_message_input.is_element_displayed(): - self.channel_2.click_system_back_button_until_element_is_shown() + self.channel_2.navigate_back_to_home_view() self.home_2.communities_tab.click() self.home_2.get_chat(self.community_name, community=True).click() self.community_2.get_channel(self.channel_name).click() @@ -1094,7 +1094,7 @@ class TestCommunityMultipleDeviceMerged(MultipleSharedDeviceTestCase): } for home in self.homes: - home.click_system_back_button_until_element_is_shown() + home.navigate_back_to_home_view() home.jump_to_communities_home() community = home.get_chat(self.community_name, community=True).click() community.get_channel(self.channel_name).click() @@ -1133,7 +1133,7 @@ class TestCommunityMultipleDeviceMerged(MultipleSharedDeviceTestCase): @marks.testrail_id(702845) def test_community_leave(self): - self.home_2.click_system_back_button_until_element_is_shown() + self.home_2.navigate_back_to_home_view() self.home_2.jump_to_communities_home() community = self.home_2.get_chat(self.community_name, community=True) community_to_leave = CommunityView(self.drivers[1]) @@ -1147,7 +1147,7 @@ class TestCommunityMultipleDeviceMerged(MultipleSharedDeviceTestCase): @marks.testrail_id(702948) def test_community_hashtag_links_to_community_channels(self): for home in self.homes: - home.click_system_back_button_until_element_is_shown() + home.navigate_back_to_home_view() self.home_2.jump_to_messages_home() self.home_1.jump_to_communities_home() diff --git a/test/appium/tests/medium/test_activity_center.py b/test/appium/tests/medium/test_activity_center.py index 4f1a736b36..522d6ef626 100644 --- a/test/appium/tests/medium/test_activity_center.py +++ b/test/appium/tests/medium/test_activity_center.py @@ -21,7 +21,7 @@ class TestActivityCenterContactRequestMultipleDevicePR(MultipleSharedDeviceTestC self.profile_1, self.profile_2 = self.home_1.get_profile_view(), self.home_2.get_profile_view() self.public_key_1 = self.home_1.get_public_key() self.public_key_2 = self.home_2.get_public_key_via_share_profile_tab() - [home.click_system_back_button_until_element_is_shown() for home in self.homes] + [home.navigate_back_to_home_view() for home in self.homes] [home.chats_tab.click() for home in self.homes] @marks.testrail_id(702850) @@ -40,7 +40,7 @@ class TestActivityCenterContactRequestMultipleDevicePR(MultipleSharedDeviceTestC chat.view_profile_new_contact_button.click_until_presence_of_element(chat.profile_block_contact_button) chat.profile_add_to_contacts_button.click() - self.home_2.click_system_back_button_until_element_is_shown() + self.home_2.navigate_back_to_home_view() self.device_1.just_fyi("Device 1: check there is no PN when receiving new message to activity centre") self.device_1.open_notification_bar() @@ -121,7 +121,7 @@ class TestActivityCenterContactRequestMultipleDevicePR(MultipleSharedDeviceTestC self.errors.append("Contact was not added to contact list after accepting contact request (as receiver)") self.device_2.just_fyi('Device1 check that contact appeared in contact list mutually') - self.home_2.click_system_back_button_until_element_is_shown() + self.home_2.navigate_back_to_home_view() self.home_2.chats_tab.click() self.home_2.contacts_tab.click() if not self.home_2.contact_details_row(username=self.username_1).is_element_displayed(20): @@ -144,7 +144,7 @@ class TestActivityMultipleDevicePR(MultipleSharedDeviceTestCase): self.homes = self.home_1, self.home_2 = self.device_1.get_home_view(), self.device_2.get_home_view() self.profile_1, self.profile_2 = self.home_1.get_profile_view(), self.home_2.get_profile_view() self.public_key_2 = self.home_2.get_public_key() - self.home_2.click_system_back_button_until_element_is_shown() + self.home_2.navigate_back_to_home_view() [home.chats_tab.click() for home in self.homes] self.home_1.add_contact(self.public_key_2) @@ -157,7 +157,7 @@ class TestActivityMultipleDevicePR(MultipleSharedDeviceTestCase): self.chat_1.send_message(self.one_to_one_message) self.chat_2 = self.home_2.get_chat(self.username_1).click() self.chat_2.send_message(self.text_message) - [home.click_system_back_button_until_element_is_shown() for home in self.homes] + [home.navigate_back_to_home_view() for home in self.homes] self.home_1.just_fyi("Open community to message") self.home_1.communities_tab.click() diff --git a/test/appium/tests/medium/test_browser_profile.py b/test/appium/tests/medium/test_browser_profile.py index 4263e89c6b..f7fc46115e 100644 --- a/test/appium/tests/medium/test_browser_profile.py +++ b/test/appium/tests/medium/test_browser_profile.py @@ -193,7 +193,7 @@ class TestBrowserProfileOneDevice(MultipleSharedDeviceTestCase): self.home.share_via_messenger() if not self.home.element_by_text_part('Hey join me on Status: https://join.status.im/u/%s' % chat_key).is_element_displayed(20): self.errors.append("No expected message in input field when sharing via 'Invite friend'") - self.home.click_system_back_button_until_element_is_shown() + self.home.navigate_back_to_home_view() self.home.just_fyi("Check it via bottom sheet menu") self.home.plus_button.click() @@ -201,7 +201,7 @@ class TestBrowserProfileOneDevice(MultipleSharedDeviceTestCase): self.home.share_via_messenger() if not self.home.element_by_text_part('Hey join me on Status: https://join.status.im/u/%s' % chat_key).is_element_displayed(20): self.errors.append("No expected message in input field when sharing via 'bottom sheet'") - self.home.click_system_back_button_until_element_is_shown() + self.home.navigate_back_to_home_view() self.errors.verify_no_errors() @marks.testrail_id(702160) diff --git a/test/appium/tests/medium/test_deeplink_chat_share_profile.py b/test/appium/tests/medium/test_deeplink_chat_share_profile.py index 5015c0f5ba..8015071bcf 100644 --- a/test/appium/tests/medium/test_deeplink_chat_share_profile.py +++ b/test/appium/tests/medium/test_deeplink_chat_share_profile.py @@ -99,7 +99,7 @@ class TestDeeplinkChatProfileOneDevice(MultipleSharedDeviceTestCase): 'https://join.status.im/u/%s' % dummy_user["public_key"]).is_element_displayed(): self.errors.append("Can't share public key of contact") for _ in range(2): - chat.click_system_back_button_until_element_is_shown() + chat.navigate_back_to_home_view() @marks.testrail_id(702252) def test_share_user_profile_url_public_chat(self): @@ -115,7 +115,7 @@ class TestDeeplinkChatProfileOneDevice(MultipleSharedDeviceTestCase): 'https://join.status.im/%s' % self.public_chat_name).is_element_displayed(): self.errors.append("Can't share link to public chat") for _ in range(2): - self.public_chat.click_system_back_button_until_element_is_shown() + self.public_chat.navigate_back_to_home_view() self.public_chat.get_back_to_home_view() @marks.testrail_id(702251) @@ -134,7 +134,7 @@ class TestDeeplinkChatProfileOneDevice(MultipleSharedDeviceTestCase): browser.element_by_text_part(expeceted_text_2).is_element_displayed()): self.errors.append("Can't share link to URL") - browser.click_system_back_button_until_element_is_shown() + browser.navigate_back_to_home_view() self.errors.verify_no_errors() diff --git a/test/appium/views/base_view.py b/test/appium/views/base_view.py index 167c22e5fa..18d3c014eb 100644 --- a/test/appium/views/base_view.py +++ b/test/appium/views/base_view.py @@ -383,15 +383,12 @@ class BaseView(object): for _ in range(times): self.driver.press_keycode(4) - def click_system_back_button_until_element_is_shown(self, attempts=3, element='home'): + def navigate_back_to_home_view(self, attempts=3): counter = 0 - if self.chat_floating_screen.is_element_displayed(2) or self.community_floating_screen.is_element_displayed(2): + while self.chat_floating_screen.is_element_displayed(2) \ + or self.community_floating_screen.is_element_displayed(2): self.driver.press_keycode(4) - if element == 'home': - element = self.chats_tab - elif element == 'chat': - chat = self.get_chat_view() - element = chat.chat_message_input + element = self.chats_tab while not element.is_element_displayed(1) and counter <= attempts: self.driver.press_keycode(4) try: @@ -400,7 +397,19 @@ class BaseView(object): except (NoSuchElementException, TimeoutException): counter += 1 else: - self.driver.info("Could not reach %s element by pressing back" % element.name) + self.driver.info("Could not reach home view by pressing system back button") + + def navigate_back_to_chat_view(self, attempts=3): + counter = 0 + element = self.get_chat_view().chat_message_input + while not element.is_element_displayed(1) and counter <= attempts: + self.driver.press_keycode(4) + try: + element.wait_for_element(2) + return + except (NoSuchElementException, TimeoutException): + counter += 1 + self.driver.info("Could not reach chat view by pressing system back button") def get_app_from_background(self): self.driver.info('Get Status back from Recent apps') @@ -608,7 +617,8 @@ class BaseView(object): self.hide_keyboard_if_shown() if self.chat_floating_screen.is_element_displayed(1): Button(self.driver, xpath='//*[@content-desc="%s"]//*[@content-desc="%s"]' % - (self.chat_floating_screen.accessibility_id, self.jump_to_button.accessibility_id)).click() + (self.chat_floating_screen.accessibility_id, + self.jump_to_button.accessibility_id)).click() elif self.community_floating_screen.is_element_displayed(1): Button(self.driver, xpath='//*[@content-desc="%s"]//*[@content-desc="%s"]' % (self.community_floating_screen.accessibility_id, diff --git a/test/appium/views/home_view.py b/test/appium/views/home_view.py index 67a621b10c..4c7188aa7c 100644 --- a/test/appium/views/home_view.py +++ b/test/appium/views/home_view.py @@ -403,7 +403,7 @@ class HomeView(BaseView): chat.profile_add_to_contacts_button.click() if nickname: chat.set_nickname(nickname) - self.click_system_back_button_until_element_is_shown() + self.navigate_back_to_home_view() def create_group_chat(self, user_names_to_add: list, group_chat_name: str = 'new_group_chat'): self.driver.info("## Creating group chat '%s'" % group_chat_name, device=False) @@ -428,9 +428,10 @@ class HomeView(BaseView): chat.click_system_back_button() chat.view_profile_new_contact_button.click_until_presence_of_element(chat.profile_add_to_contacts_button) chat.profile_add_to_contacts_button.click() - self.click_system_back_button_until_element_is_shown() + self.navigate_back_to_home_view() - def create_community_e2e(self, name: str, description="some_description", set_image=False, file_name='sauce_logo.png', + def create_community_e2e(self, name: str, description="some_description", set_image=False, + file_name='sauce_logo.png', require_approval=True): self.driver.info("## Creating community '%s', set image is set to '%s'" % (name, str(set_image)), device=False) self.plus_community_button.click() diff --git a/test/appium/views/profile_view.py b/test/appium/views/profile_view.py index 3a8e22dfa9..88002d729c 100644 --- a/test/appium/views/profile_view.py +++ b/test/appium/views/profile_view.py @@ -371,13 +371,13 @@ class ProfileView(BaseView): chat.public_key_edit_box.send_keys(public_key) chat.view_profile_new_contact_button.click_until_presence_of_element(chat.profile_add_to_contacts_button) chat.profile_add_to_contacts_button.click() - self.click_system_back_button_until_element_is_shown() + self.navigate_back_to_home_view() def switch_push_notifications(self): self.driver.info("Enabling push notifications via Profile") self.profile_notifications_button.scroll_and_click() self.profile_notifications_toggle_button.click() - self.click_system_back_button_until_element_is_shown() + self.navigate_back_to_home_view() def add_custom_network(self, rpc_url: str, name: str, symbol: str, netwrok_id:str): self.driver.info("## Add custom network", device=False)