e2e: fixes navigation, long press and so on

This commit is contained in:
Yevheniia Berdnyk 2023-09-01 17:50:38 +03:00
parent f3f85f9911
commit 5647bb4ac9
No known key found for this signature in database
GPG Key ID: 0642C73C66214825
7 changed files with 40 additions and 24 deletions

View File

@ -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()

View File

@ -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()

View File

@ -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)

View File

@ -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:

View File

@ -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)

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.8 KiB

After

Width:  |  Height:  |  Size: 1.8 KiB

View File

@ -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()