From 5647bb4ac91ef9870a9734f983a7f047024ebf6e Mon Sep 17 00:00:00 2001 From: Yevheniia Berdnyk Date: Fri, 1 Sep 2023 17:50:38 +0300 Subject: [PATCH] e2e: fixes navigation, long press and so on --- .../critical/chats/test_1_1_public_chats.py | 7 ++-- .../tests/critical/chats/test_group_chat.py | 2 +- .../critical/test_public_chat_browsing.py | 11 +++--- test/appium/views/base_view.py | 4 +-- test/appium/views/chat_view.py | 34 +++++++++++------- .../discovery_general_channel.png | Bin 1806 -> 1811 bytes test/appium/views/home_view.py | 6 ++-- 7 files changed, 40 insertions(+), 24 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 4fc295c4aa..01f1d01b46 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 @@ -1153,13 +1153,13 @@ class TestOneToOneChatMultipleSharedDevicesNewUi(MultipleSharedDeviceTestCase): chat_2 = self.device_2.click_upon_push_notification_by_text(message) self.device_2.just_fyi("Send emoji message to Device 1 while it's on background") + self.device_1.put_app_to_background() + self.device_1.open_notification_bar() emoji_message = random.choice(list(emoji.EMOJI_UNICODE)) emoji_unicode = emoji.EMOJI_UNICODE[emoji_message] chat_2.send_message(emoji.emojize(emoji_message)) self.device_1.just_fyi("Device 1 checks PN with emoji") - self.device_1.put_app_to_background() - self.device_1.open_notification_bar() if not self.device_1.element_by_text_part(emoji_unicode).is_element_displayed(60): self.device_1.click_system_back_button() self.device_1.status_in_background_button.click() @@ -1312,8 +1312,9 @@ class TestOneToOneChatMultipleSharedDevicesNewUi(MultipleSharedDeviceTestCase): self.device_2.just_fyi("Send one more message and check that PN will be deleted with message deletion") message_to_delete = 'DELETE ME' self.home_1.put_app_to_background() - self.chat_2.send_message(message_to_delete) self.home_1.open_notification_bar() + self.chat_2.send_message(message_to_delete) + self.chat_2.chat_element_by_text(message_to_delete).wait_for_sent_state() if not self.home_1.get_pn(message_to_delete): self.home_1.click_system_back_button() self.home_1.status_in_background_button.click() diff --git a/test/appium/tests/critical/chats/test_group_chat.py b/test/appium/tests/critical/chats/test_group_chat.py index 0bf52db2c3..659caa6772 100644 --- a/test/appium/tests/critical/chats/test_group_chat.py +++ b/test/appium/tests/critical/chats/test_group_chat.py @@ -211,11 +211,11 @@ class TestGroupChatMultipleDeviceMergedNewUI(MultipleSharedDeviceTestCase): message_to_admin = self.message_to_admin [self.homes[i].navigate_back_to_home_view() for i in range(3)] self.homes[1].get_chat(self.chat_name).click() + self.chats[0].open_notification_bar() self.chats[1].send_message(message_to_admin) self.chats[0].just_fyi('Check that PN is received and after tap you are redirected to group chat') - self.chats[0].open_notification_bar() pn = self.homes[0].get_pn(message_to_admin) if pn: pn.click() diff --git a/test/appium/tests/critical/test_public_chat_browsing.py b/test/appium/tests/critical/test_public_chat_browsing.py index 709a7a6752..b19f93d3fa 100644 --- a/test/appium/tests/critical/test_public_chat_browsing.py +++ b/test/appium/tests/critical/test_public_chat_browsing.py @@ -1,5 +1,6 @@ import datetime import random +import time from datetime import timedelta import emoji @@ -337,7 +338,7 @@ class TestCommunityOneDeviceMerged(MultipleSharedDeviceTestCase): for element, template in element_templates.items(): if element.is_element_differs_from_template(template): element.save_new_screenshot_of_element('%s_different.png' % element.name) - self.errors.append("%s is different from expected %s!" % (element.name, template)) + self.errors.append("Element %s is different from expected template %s!" % (element.locator, template)) self.errors.verify_no_errors() @marks.testrail_id(702846) @@ -348,6 +349,7 @@ class TestCommunityOneDeviceMerged(MultipleSharedDeviceTestCase): self.home.get_to_community_channel_from_home(self.community_name) self.channel.send_message(text_message) + self.channel.chat_element_by_text(text_message).wait_for_visibility_of_element() self.channel.reopen_app() if not self.channel.chat_element_by_text(text_message).is_element_displayed(30): self.drivers[0].fail("Not navigated to channel view after reopening app") @@ -577,6 +579,7 @@ class TestCommunityMultipleDeviceMerged(MultipleSharedDeviceTestCase): self.chat_2.chat_element_by_text(self.community_name).view_community_button.click() self.community_2.join_community() self.channel_2 = self.community_2.get_channel(self.channel_name).click() + self.channel_2.chat_message_input.wait_for_visibility_of_element(20) @marks.testrail_id(702838) def test_community_message_send_check_timestamps_sender_username(self): @@ -1010,6 +1013,7 @@ class TestCommunityMultipleDeviceMerged(MultipleSharedDeviceTestCase): self.errors.append("New messages counter is not shown in community channel element") self.community_1.click_system_back_button() mark_as_read_button = self.community_1.mark_all_messages_as_read_button + self.home_1.community_floating_screen.wait_for_invisibility_of_element() community_1_element.long_press_until_element_is_shown(mark_as_read_button) mark_as_read_button.click() if community_1_element.new_messages_grey_dot.is_element_displayed(): @@ -1065,10 +1069,10 @@ class TestCommunityMultipleDeviceMergedTwo(MultipleSharedDeviceTestCase): self.channel_2 = self.community_2.get_channel(self.channel_name).click() @marks.testrail_id(702786) - @marks.xfail( - reason="Issue with username in PN, issue #6 in https://github.com/status-im/status-mobile/issues/15500") + @marks.xfail(reason="Issue with username in PN, issue #6 in 15500") def test_community_mentions_push_notification(self): self.home_1.navigate_back_to_home_view() + self.device_1.open_notification_bar() self.device_2.just_fyi("Invited member sends a message with a mention") self.channel_2.send_message("hi") @@ -1076,7 +1080,6 @@ class TestCommunityMultipleDeviceMergedTwo(MultipleSharedDeviceTestCase): self.channel_2.send_message_button.click() self.device_1.just_fyi("Admin gets push notification with the mention and tap it") - self.device_1.open_notification_bar() message_received = False if self.home_1.get_pn(self.username_1): self.device_1.click_upon_push_notification_by_text(self.username_1) diff --git a/test/appium/views/base_view.py b/test/appium/views/base_view.py index e144a7bd04..67379ab238 100644 --- a/test/appium/views/base_view.py +++ b/test/appium/views/base_view.py @@ -386,8 +386,8 @@ class BaseView(object): def navigate_back_to_home_view(self, attempts=3): counter = 0 - while self.chat_floating_screen.is_element_displayed(2) \ - or self.community_floating_screen.is_element_displayed(2): + while not self.chat_floating_screen.is_element_disappeared(2) \ + or not self.community_floating_screen.is_element_disappeared(2): self.driver.press_keycode(4) element = self.chats_tab while not element.is_element_displayed(1) and counter <= attempts: diff --git a/test/appium/views/chat_view.py b/test/appium/views/chat_view.py index 204e5e6e11..18db29d14e 100644 --- a/test/appium/views/chat_view.py +++ b/test/appium/views/chat_view.py @@ -5,7 +5,8 @@ from time import sleep import dateutil.parser from appium.webdriver.common.touch_action import TouchAction -from selenium.common.exceptions import NoSuchElementException, TimeoutException, StaleElementReferenceException +from selenium.common.exceptions import NoSuchElementException, TimeoutException, StaleElementReferenceException, \ + InvalidElementStateException from tests import emojis, common_password from views.base_element import Button, EditBox, Text, BaseElement, SilentButton @@ -334,9 +335,10 @@ class UsernameOptions(Button): class UsernameCheckbox(Button): - def __init__(self, driver, username): + def __init__(self, driver, username, state_on): self.username = username - super().__init__(driver, xpath="//*[@text='%s']/..//*[@content-desc='checkbox-off']" % username) + super().__init__(driver, xpath="//*[@text='%s']/..//*[@content-desc='checkbox-%s']" % ( + username, 'on' if state_on else 'off')) def click(self): try: @@ -488,6 +490,7 @@ class CommunityView(HomeView): self.driver.info("Share to %s community" % ', '.join(map(str, user_names_to_share))) self.jump_to_communities_home() home = self.get_home_view() + home.communities_tab.click() community_element = home.get_chat(community_name, community=True) # community_element.long_press_until_element_is_shown(self.view_members_button) community_element.long_press_until_element_is_shown(self.share_community_button) @@ -941,9 +944,9 @@ class ChatView(BaseView): self.introduce_yourself_edit_box.set_value(intro_message) self.request_membership_button.click_until_presence_of_element(self.element_by_text('Request pending…')) - def get_username_checkbox(self, username: str): + def get_username_checkbox(self, username: str, state_on=False): self.driver.info("Getting %s checkbox" % username) - return UsernameCheckbox(self.driver, username) + return UsernameCheckbox(self.driver, username, state_on) def accept_membership_for_group_chat_via_chat_view(self, username, accept=True): info = "%s membership to group chat" % username @@ -993,13 +996,18 @@ class ChatView(BaseView): try: self.chat_message_input.send_keys(message) break - except StaleElementReferenceException: + except (StaleElementReferenceException, InvalidElementStateException): time.sleep(1) except Exception as e: raise e else: raise StaleElementReferenceException(msg="Can't send keys to chat message input, loading") - self.send_message_button.click() + try: + self.send_message_button.click() + except NoSuchElementException: + self.chat_message_input.clear() + self.chat_message_input.send_keys(message) + self.send_message_button.click() def send_contact_request(self, message: str = 'Contact request message', wait_chat_input_sec=5): self.driver.info("Sending contact request message '%s'" % BaseElement(self.driver).exclude_emoji(message)) @@ -1017,7 +1025,7 @@ class ChatView(BaseView): def edit_message_in_chat(self, message_to_edit, message_to_update): self.driver.info("Looking for message '%s' to edit it" % message_to_edit) element = self.element_by_translation_id("edit-message") - self.chat_view_element_starts_with_text(message_to_edit).long_press_until_element_is_shown(element) + self.chat_element_by_text(message_to_edit).message_body.long_press_until_element_is_shown(element) element.click() self.chat_message_input.clear() self.chat_message_input.send_keys(message_to_update) @@ -1025,10 +1033,12 @@ class ChatView(BaseView): def delete_message_in_chat(self, message, everyone=True): self.driver.info("Looking for message '%s' to delete it" % message) - self.chat_view_element_starts_with_text(message).long_press_element() - for_everyone, for_me = self.element_by_translation_id("delete-for-everyone"), self.element_by_translation_id( - "delete-for-me") - for_everyone.click() if everyone else for_me.click() + if everyone: + delete_button = self.element_by_translation_id("delete-for-everyone") + else: + delete_button = self.element_by_translation_id("delete-for-me") + self.chat_element_by_text(message).message_body.long_press_until_element_is_shown(delete_button) + delete_button.click() def copy_message_text(self, message_text): self.driver.info("Copying '%s' message via long press" % message_text) diff --git a/test/appium/views/elements_templates/discovery_general_channel.png b/test/appium/views/elements_templates/discovery_general_channel.png index 3acc32ece710d713b29af3897d2008a0acf109fd..81b1aa15bf96c48a4095c3d4c6813539496ef89e 100644 GIT binary patch delta 1795 zcmV+e2mJVs4wDX$B!AjTL_t(|oZXvUY!p=#$A2?BY|D1penHo;ti?biLaYLziN#7t zAT`DspKLV7ga@BAnh;)$kq6YwWvvS)KtNjn417=pMO*kiGSoZ&vO${kNbQjFwML#bUp#m zX#H4t)x^w<$TkN~0!&kE`$rX%lk+s&Nx;-p?HrqhKsr5dVYdme+}cMSbKG{DfN1p5 zTKMw83f#=XCSWleJf$K_Rv{pfP#4CkM*5GYZX&#Z0%pb49pw2i|`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_~hTzAFKKYpu8F84zLL7R diff --git a/test/appium/views/home_view.py b/test/appium/views/home_view.py index dbf992d97e..49cbe2a6d1 100644 --- a/test/appium/views/home_view.py +++ b/test/appium/views/home_view.py @@ -36,7 +36,7 @@ class ChatElement(SilentButton): if self.community_channel: super().__init__( driver, - xpath="//*[@content-desc='chat-name-text']//*[starts-with(@text,'# %s')]/.." % username_part) + xpath="//*[@content-desc='chat-name-text']//*[starts-with(@text,'# %s')]/../.." % username_part) elif community: super().__init__( driver, @@ -411,7 +411,9 @@ class HomeView(BaseView): self.new_chat_button.click() chat = self.get_chat_view() self.start_a_new_chat_bottom_sheet_button.click() - [chat.get_username_checkbox(user_name).click() for user_name in user_names_to_add] + for user_name in user_names_to_add: + chat.get_username_checkbox(user_name).click_until_presence_of_element( + chat.get_username_checkbox(user_name, state_on=True)) self.setup_chat_button.click() chat.chat_name_editbox.send_keys(group_chat_name) chat.create_button.click()