From 432f7bcd8ce1710cd90c14ee88e7b31745063d83 Mon Sep 17 00:00:00 2001 From: Churikova Tetiana Date: Fri, 24 Feb 2023 20:05:30 +0100 Subject: [PATCH] e2e: 1-1 chat, communities --- test/appium/tests/base_test_case.py | 9 +- test/appium/tests/conftest.py | 2 +- .../critical/chats/test_1_1_public_chats.py | 79 +++-- .../critical/test_public_chat_browsing.py | 308 +++--------------- .../tests/medium/test_activity_center.py | 22 +- test/appium/views/base_element.py | 9 + test/appium/views/base_view.py | 4 + test/appium/views/chat_view.py | 99 ++++-- test/appium/views/home_view.py | 120 +------ 9 files changed, 205 insertions(+), 447 deletions(-) diff --git a/test/appium/tests/base_test_case.py b/test/appium/tests/base_test_case.py index 39b13c54bb..d98ff057c8 100644 --- a/test/appium/tests/base_test_case.py +++ b/test/appium/tests/base_test_case.py @@ -16,12 +16,11 @@ from selenium.common.exceptions import NoSuchElementException from selenium.common.exceptions import WebDriverException from selenium.webdriver.support.wait import WebDriverWait -from tests.conftest import option, sauce_username, sauce_access_key +from tests.conftest import option, sauce_username, sauce_access_key, apibase from support.api.network_api import NetworkApi from support.github_report import GithubHtmlReport from tests import test_suite_data, start_threads, appium_container, pytest_config_global from tests import transl -from tests.conftest import apibase executor_sauce_lab = 'https://%s:%s@ondemand.%s:443/wd/hub' % (sauce_username, sauce_access_key, apibase) @@ -394,11 +393,7 @@ class SauceSharedMultipleDeviceTestCase(AbstractTestCase): driver.quit() except WebDriverException: pass - if option.datacenter == 'eu-central-1': - url = 'https://eu-central-1.saucelabs.com/rest/v1/%s/jobs/%s/assets/%s' % ( - sauce_username, session_id, "log.json") - else: - url = sauce.jobs.get_job_asset_url(username=sauce_username, job_id=session_id, filename="log.json") + url = 'https://api.%s/rest/v1/%s/jobs/%s/assets/%s' % (apibase, sauce_username, session_id, "log.json") WebDriverWait(driver, 60, 2).until(lambda _: requests_session.get(url).status_code == 200) commands = requests_session.get(url).json() for command in commands: diff --git a/test/appium/tests/conftest.py b/test/appium/tests/conftest.py index dc088770d2..41ff03ee03 100644 --- a/test/appium/tests/conftest.py +++ b/test/appium/tests/conftest.py @@ -172,7 +172,7 @@ def pytest_configure(config): config.addinivalue_line("markers", "testrail_id(name): empty") global apibase if config.getoption('datacenter') == 'us-west-1': - apibase = 'saucelabs.com' + apibase = 'us-west-1.saucelabs.com' elif config.getoption('datacenter') == 'eu-central-1': apibase = 'eu-central-1.saucelabs.com' else: 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 db3072de4b..760b3d8755 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 @@ -3,12 +3,12 @@ import time import emoji import pytest +from selenium.common.exceptions import TimeoutException from tests import marks, common_password, run_in_parallel from tests.base_test_case import MultipleSharedDeviceTestCase, create_shared_drivers from tests.users import transaction_senders, basic_user, ens_user, ens_user_message_sender from views.sign_in_view import SignInView -from views.base_element import Button @pytest.mark.xdist_group(name="four_2") @@ -1033,7 +1033,8 @@ class TestOneToOneChatMultipleSharedDevicesNewUi(MultipleSharedDeviceTestCase): self.chat_1.quote_message(emoji_unicode) actual_text = self.chat_1.quote_username_in_message_input.text if actual_text != "You": - self.errors.append("'You' is not displayed in reply quote snippet replying to own message, '%s' instead" % actual_text) + self.errors.append( + "'You' is not displayed in reply quote snippet replying to own message, '%s' instead" % actual_text) self.chat_1.just_fyi("Clear quote and check there is not snippet anymore") self.chat_1.cancel_reply_button.click() @@ -1073,6 +1074,7 @@ class TestOneToOneChatMultipleSharedDevicesNewUi(MultipleSharedDeviceTestCase): self.home_1.just_fyi("Check that Device1 can pin own message in 1-1 chat") self.chat_1.send_message(self.message_1) self.chat_1.send_message(self.message_2) + self.chat_1.chat_element_by_text(self.message_1).wait_for_status_to_be("Delivered") self.chat_1.pin_message(self.message_1, 'pin-to-chat') if not self.chat_1.chat_element_by_text(self.message_1).pinned_by_label.is_element_displayed(): self.drivers[0].fail("Message is not pinned!") @@ -1084,7 +1086,7 @@ class TestOneToOneChatMultipleSharedDevicesNewUi(MultipleSharedDeviceTestCase): chat.pinned_messages_count.wait_for_element_text("2", message="Pinned messages count is not 2 as expected!") - self.home_1.just_fyi("Check pinned message are visible in Pinned panel for user %s" % (chat_number + 1)) + chat.just_fyi("Check pinned message are visible in Pinned panel for user %s" % (chat_number + 1)) chat.pinned_messages_count.click() for message in self.message_1, self.message_2: pinned_by = chat.pinned_messages_list.get_message_pinned_by_text(message) @@ -1108,10 +1110,17 @@ class TestOneToOneChatMultipleSharedDevicesNewUi(MultipleSharedDeviceTestCase): self.home_1.just_fyi("Check that Device1 can not pin more than 3 messages and 'Unpin' dialog appears") for message in (self.message_3, self.message_4): self.chat_1.send_message(message) + self.chat_1.chat_element_by_text(message).wait_for_status_to_be("Delivered") self.chat_1.pin_message(message, 'pin-to-chat') - if self.chat_1.pin_limit_popover.is_element_displayed(30): - self.chat_1.view_pinned_messages_button.click_until_presence_of_element(self.chat_1.pinned_messages_list) - self.chat_1.pinned_messages_list.message_element_by_text(self.message_2).click_inside_element_by_coordinate() + # if self.chat_1.pin_limit_popover.is_element_displayed(30): + self.chat_1.view_pinned_messages_button.click_until_presence_of_element(self.chat_1.pinned_messages_list) + # temp solution instead of getting pin_limit_popover: + if self.chat_1.pinned_messages_list.get_pinned_messages_number() > 3 \ + or self.chat_1.pinned_messages_list.message_element_by_text(self.message_4).is_element_displayed(): + self.errors.append("Can pin more than 3 messages in chat") + else: + self.chat_1.pinned_messages_list.message_element_by_text( + self.message_2).click_inside_element_by_coordinate() self.home_1.just_fyi("Unpin one message so that another could be pinned") self.chat_1.element_by_translation_id('unpin-from-chat').double_click() self.chat_1.chat_element_by_text(self.message_4).click() @@ -1119,36 +1128,32 @@ class TestOneToOneChatMultipleSharedDevicesNewUi(MultipleSharedDeviceTestCase): if not (self.chat_1.chat_element_by_text(self.message_4).pinned_by_label.is_element_displayed(30) and self.chat_2.chat_element_by_text(self.message_4).pinned_by_label.is_element_displayed(30)): self.errors.append("Message 4 is not pinned in chat after unpinning previous one") - else: - self.errors.append("Can pin more than 3 messages in chat") self.home_1.just_fyi("Check pinned messages are visible in Pinned panel for both users") for chat_number, chat in enumerate([self.chat_1, self.chat_2]): count = chat.pinned_messages_count.text if count != '3': - self.errors.append("Pinned messages count is not 3 for user %s" % (chat_number + 1)) + self.errors.append("Pinned messages count is %s but should be 3 for user %s" % (count, chat_number + 1)) self.home_1.just_fyi("Unpin one message and check it's unpinned for another user") self.chat_2.tap_by_coordinates(500, 100) - # temp solution until finding solution for distinguish system and not-system messages - message_element = Button(self.chat_1.driver, xpath="//*[starts-with(@text,'%s')]/ancestor::android.view.ViewGroup[@content-desc='chat-item']//*[starts-with(@text,'[:')]" % self.message_4) - message_element.long_press_element() - self.chat_1.element_by_translation_id("unpin-from-chat").click() - self.chat_2.chat_element_by_text(self.message_4).pinned_by_label.wait_for_invisibility_of_element() - if self.chat_2.chat_element_by_text(self.message_4).pinned_by_label.is_element_displayed(): + + self.chat_1.pin_message(self.message_4, action="unpin-from-chat") + try: + self.chat_2.chat_element_by_text(self.message_4).pinned_by_label.wait_for_invisibility_of_element() + except TimeoutException: self.errors.append("Message_4 is not unpinned!") for chat_number, chat in enumerate([self.chat_1, self.chat_2]): count = chat.pinned_messages_count.text if count != '2': self.errors.append( - "Pinned messages count is not 2 after unpinning the last pinned message for user %s" % ( - chat_number + 1) + "Pinned messages count is %s but should be 2 after unpinning the last pinned message for user %s" % + (count, chat_number + 1) ) self.errors.verify_no_errors() @marks.testrail_id(702745) - @marks.xfail(reason="On profile picture failed due to 14718") def test_1_1_chat_non_latin_messages_stack_update_profile_photo(self): self.home_1.click_system_back_button_until_element_is_shown() self.home_1.browser_tab.click() # temp, until profile is on browser tab @@ -1237,6 +1242,7 @@ class TestOneToOneChatMultipleSharedDevicesNewUi(MultipleSharedDeviceTestCase): self.errors.verify_no_errors() @marks.testrail_id(702855) + @marks.xfail(reason="blocked by 15166") def test_1_1_chat_edit_message(self): [device.click_system_back_button_until_element_is_shown() for device in (self.device_1, self.device_2)] @@ -1249,13 +1255,16 @@ class TestOneToOneChatMultipleSharedDevicesNewUi(MultipleSharedDeviceTestCase): "Device 1 sends text message and edits it in 1-1 chat. Device2 checks edited message is shown") message_before_edit_1_1, message_after_edit_1_1 = "Message before edit 1-1", "AFTER" self.chat_2.send_message(message_before_edit_1_1) - + self.chat_2.chat_element_by_text(message_before_edit_1_1).wait_for_status_to_be("Delivered") self.chat_2.edit_message_in_chat(message_before_edit_1_1, message_after_edit_1_1) chat_element = self.chat_1.chat_element_by_text(message_after_edit_1_1) if not chat_element.is_element_displayed(30): self.errors.append('No edited message in 1-1 chat displayed') - if chat_element.status != 'edited': - self.errors.append('"Edited" status can not be seen from receiver perspective') + try: + chat_element.wait_for_status_to_be('edited') + except TimeoutException: + self.errors.append('Edited message is shown for receiver with status %s but it should be "Edited"' % + chat_element.status) self.errors.verify_no_errors() @marks.testrail_id(702733) @@ -1271,6 +1280,7 @@ class TestOneToOneChatMultipleSharedDevicesNewUi(MultipleSharedDeviceTestCase): message_after_edit_1_1 = 'smth I should edit' message_to_delete_for_me = 'message to delete for me' self.chat_2.send_message(message_after_edit_1_1) + self.chat_2.chat_element_by_text(message_after_edit_1_1).wait_for_status_to_be("Delivered") chat_1_element = self.chat_1.chat_element_by_text(message_after_edit_1_1) chat_1_element.long_press_element() for action in ("edit", "delete-for-everyone"): @@ -1280,6 +1290,7 @@ class TestOneToOneChatMultipleSharedDevicesNewUi(MultipleSharedDeviceTestCase): self.device_2.just_fyi("Delete message for me and check it is only deleted for the author") self.chat_2.send_message(message_to_delete_for_me) + self.chat_2.chat_element_by_text(message_to_delete_for_me).wait_for_status_to_be("Delivered") self.chat_2.delete_message_in_chat(message_to_delete_for_me, everyone=False) if not self.chat_2.chat_element_by_text(message_to_delete_for_me).is_element_disappeared(20): self.errors.append("Deleted for me message is shown in chat for the author of message") @@ -1334,20 +1345,22 @@ class TestOneToOneChatMultipleSharedDevicesNewUi(MultipleSharedDeviceTestCase): self.home_2.just_fyi('Device2 checks "Sending" status when sending message from offline') self.chat_2.send_message(message_1) chat_element = self.chat_2.chat_element_by_text(message_1) - if not (chat_element.status == ':sending' or chat_element.status == ':sent'): - self.errors.append('Message status is not "Sending", it is "%s"!' % chat_element.status) + status = chat_element.status + if not (status == 'Sending' or status == 'Sent'): + self.errors.append('Message status is not "Sending", it is "%s"!' % status) self.home_2.just_fyi('Device2 goes back online and checks that status of the message is changed to "delivered"') - [home.toggle_airplane_mode() for home in (self.home_1, self.home_2)] - i = 1 - while i < 12: - i += 1 - time.sleep(10) - if chat_element.status == ':delivered': - break - else: + for i, home in enumerate([self.home_1, self.home_2]): + home.toggle_airplane_mode() + if "im.status.ethereum" not in home.driver.current_activity: + home.click_system_back_button_until_element_is_shown() + home.chats_tab.click() + home.get_chat(self.default_username_2 if i == 0 else self.default_username_1).click() + try: + chat_element.wait_for_status_to_be(expected_status='Delivered', timeout=120) + except TimeoutException: self.errors.append( - 'Message status was not delivered after back up online, it is "%s"!' % chat_element.status) + 'Message status was not delivered after back up online, it is "%s"!' % status) self.home_1.just_fyi('Device1 goes back online and checks that 1-1 chat will be fetched') if not self.chat_1.chat_element_by_text(message_1).is_element_displayed(60): @@ -1367,5 +1380,5 @@ class TestOneToOneChatMultipleSharedDevicesNewUi(MultipleSharedDeviceTestCase): self.home_2.reopen_app() if self.home_2.get_chat_from_home_view(self.default_username_1).is_element_displayed(15): self.errors.append( - 'Deleted chat %s is shown after re-login, but the chat has been deleted' % self.default_username_1) + 'Deleted chat %s is shown after re-login, but the chat has been deleted' % self.default_username_1) self.errors.verify_no_errors() diff --git a/test/appium/tests/critical/test_public_chat_browsing.py b/test/appium/tests/critical/test_public_chat_browsing.py index 905838e55f..ded08ae604 100644 --- a/test/appium/tests/critical/test_public_chat_browsing.py +++ b/test/appium/tests/critical/test_public_chat_browsing.py @@ -15,219 +15,6 @@ from views.chat_view import ChatView from selenium.common.exceptions import NoSuchElementException -@pytest.mark.xdist_group(name="one_2") -@marks.critical -class TestPublicChatMultipleDeviceMerged(MultipleSharedDeviceTestCase): - - def prepare_devices(self): - self.drivers, self.loop = create_shared_drivers(2) - device_1, device_2 = SignInView(self.drivers[0]), SignInView(self.drivers[1]) - self.home_1, self.home_2 = device_1.create_user(), device_2.create_user() - profile_1 = self.home_1.profile_button.click() - self.username_1 = profile_1.default_username_text.text - profile_1.home_button.click() - self.pub_chat_delete_long_press = 'pub-chat' - self.text_message = 'hello' - self.home_1.join_public_chat(self.pub_chat_delete_long_press) - [home.home_button.click() for home in (self.home_1, self.home_2)] - self.public_chat_name = self.home_1.get_random_chat_name() - self.chat_1 = self.home_1.join_public_chat(self.public_chat_name) - self.chat_2 = self.home_2.join_public_chat(self.public_chat_name) - self.chat_1.send_message(self.text_message) - - @marks.testrail_id(5313) - def test_public_chat_message_send_check_timestamps_while_on_different_tab(self): - message = self.text_message - self.chat_2.dapp_tab_button.click() - sent_time_variants = self.chat_1.convert_device_time_to_chat_timestamp() - timestamp = self.chat_1.chat_element_by_text(message).timestamp_on_tap - if sent_time_variants and timestamp: - if timestamp not in sent_time_variants: - self.errors.append("Timestamp is not shown, expected: '%s', in fact: '%s'" % - (sent_time_variants.join(','), timestamp)) - self.chat_2.home_button.click(desired_view='chat') - for chat in self.chat_1, self.chat_2: - chat.verify_message_is_under_today_text(message, self.errors) - if self.chat_2.chat_element_by_text(message).username.text != self.username_1: - self.errors.append("Default username '%s' is not shown next to the received message" % self.username_1) - self.errors.verify_no_errors() - - @marks.testrail_id(700734) - def test_public_chat_message_edit(self): - if not self.chat_2.chat_message_input.is_element_displayed(): - self.chat_2.home_button.click(desired_view='chat') - message_before_edit, message_after_edit = self.text_message, "Message AFTER edit 2" - self.chat_1.edit_message_in_chat(message_before_edit, message_after_edit) - for chat in (self.chat_1, self.chat_2): - if not chat.element_by_text_part("⌫ Edited").is_element_displayed(60): - self.errors.append('No mark in message bubble about this message was edited') - if not self.chat_2.element_by_text_part(message_after_edit).is_element_displayed(60): - self.errors.append('Message is not edited') - self.errors.verify_no_errors() - - @marks.testrail_id(700735) - def test_public_chat_message_delete(self): - message_to_delete = 'delete me, please' - self.chat_1.send_message(message_to_delete) - self.chat_1.delete_message_in_chat(message_to_delete) - for chat in (self.chat_1, self.chat_2): - if not chat.chat_element_by_text(message_to_delete).is_element_disappeared(30): - self.errors.append("Deleted message is shown in chat view for public chat") - self.errors.verify_no_errors() - - @marks.testrail_id(700719) - def test_public_chat_emoji_send_copy_paste_reply(self): - emoji_name = random.choice(list(emoji.EMOJI_UNICODE)) - emoji_unicode = emoji.EMOJI_UNICODE[emoji_name] - emoji_message = emoji.emojize(emoji_name) - self.chat_1.send_message(emoji_message) - for chat in self.chat_1, self.chat_2: - if not chat.chat_element_by_text(emoji_unicode).is_element_displayed(30): - self.errors.append('Message with emoji was not sent or received in public chat') - - self.chat_1.just_fyi("Can copy and paste emojis") - self.chat_1.element_by_text_part(emoji_unicode).long_press_element() - self.chat_1.element_by_text('Copy').click() - self.chat_1.chat_message_input.paste_text_from_clipboard() - if self.chat_1.chat_message_input.text != emoji_unicode: - self.errors.append('Emoji message was not copied') - - self.chat_1.just_fyi("Can reply to emojis") - self.chat_2.quote_message(emoji_unicode) - message_text = 'test message' - self.chat_2.chat_message_input.send_keys(message_text) - self.chat_2.send_message_button.click() - chat_element_1 = self.chat_1.chat_element_by_text(message_text) - if not chat_element_1.is_element_displayed(sec=10) or chat_element_1.replied_message_text != emoji_unicode: - self.errors.append('Reply message was not received by the sender') - self.errors.verify_no_errors() - - @marks.testrail_id(5360) - def test_public_chat_unread_messages_counter(self): - self.chat_1.send_message('пиу') - home_1 = self.chat_1.home_button.click() - message = 'test message' - self.chat_2.send_message(message) - if not self.chat_1.home_button.public_unread_messages.is_element_displayed(): - self.errors.append('New messages public chat badge is not shown on Home button') - chat_element = home_1.get_chat('#' + self.public_chat_name) - if not chat_element.new_messages_public_chat.is_element_displayed(): - self.errors.append('New messages counter is not shown in public chat') - self.errors.verify_no_errors() - - @marks.testrail_id(700718) - def test_public_chat_unread_messages_counter_for_mention_relogin(self): - message = 'test message2' - [chat.get_back_to_home_view() for chat in (self.chat_1, self.chat_2)] - chat_element = self.home_1.get_chat('#' + self.public_chat_name) - self.home_2.get_chat('#' + self.public_chat_name).click() - self.chat_2.select_mention_from_suggestion_list(self.username_1, self.username_1[:2]) - self.chat_2.send_message_button.click() - chat_element.new_messages_counter.wait_for_element(30) - chat_element.new_messages_counter.wait_for_element_text("1", 60) - chat_element.click() - self.home_1.home_button.double_click() - if self.home_1.home_button.public_unread_messages.is_element_displayed(): - self.errors.append('New messages public chat badge is shown on Home button') - if chat_element.new_messages_public_chat.is_element_displayed(): - self.errors.append('Unread messages badge is shown in public chat while there are no unread messages') - [home.get_chat('#' + self.public_chat_name).click() for home in (self.home_1, self.home_2)] - self.chat_1.send_message(message) - self.chat_2.chat_element_by_text(message).wait_for_element(20) - self.home_2.reopen_app() - chat_element = self.home_2.get_chat('#' + self.public_chat_name) - if chat_element.new_messages_public_chat.is_element_displayed(): - self.drivers[0].fail('New messages counter is shown after relogin') - self.errors.verify_no_errors() - - @marks.testrail_id(5319) - def test_public_chat_delete_chat_long_press(self): - [chat.get_back_to_home_view() for chat in (self.chat_1, self.chat_2)] - self.home_1.delete_chat_long_press('#%s' % self.pub_chat_delete_long_press) - self.home_2.just_fyi("Send message to deleted chat") - self.deleted_chat_2 = self.home_2.join_public_chat(self.pub_chat_delete_long_press) - self.deleted_chat_2.send_message() - if self.home_1.get_chat_from_home_view('#%s' % self.pub_chat_delete_long_press).is_element_displayed(): - self.drivers[0].fail('Deleted public chat reappears after sending message to it') - self.home_1.reopen_app() - if self.home_1.get_chat_from_home_view('#%s' % self.pub_chat_delete_long_press).is_element_displayed(): - self.drivers[0].fail('Deleted public chat reappears after relogin') - - @marks.testrail_id(700736) - def test_public_chat_link_send_open(self): - [chat.get_back_to_home_view() for chat in (self.chat_1, self.chat_2)] - [home.get_chat('#' + self.public_chat_name).click() for home in (self.home_1, self.home_2)] - url_message = 'http://status.im' - self.chat_2.send_message(url_message) - self.chat_1.element_starts_with_text(url_message, 'button').click() - web_view = self.chat_1.open_in_status_button.click() - if not web_view.element_by_text('Private, Secure Communication').is_element_displayed(60): - self.drivers[0].fail('URL was not opened from public chat') - - @marks.testrail_id(700737) - def test_public_chat_links_with_previews_github_youtube_twitter_gif_send_enable(self): - [chat.home_button.double_click() for chat in (self.chat_1, self.chat_2)] - [home.get_chat('#' + self.public_chat_name).click() for home in (self.home_1, self.home_2)] - giphy_url = 'https://giphy.com/gifs/this-is-fine-QMHoU66sBXqqLqYvGO' - preview_urls = {'github_pr': {'url': 'https://github.com/status-im/status-mobile/pull/11707', - 'txt': 'Update translations by jinhojang6 · Pull Request #11707 · status-im/status-mobile', - 'subtitle': 'GitHub'}, - 'yotube': { - 'url': 'https://www.youtube.com/watch?v=XN-SVmuJH2g&list=PLbrz7IuP1hrgNtYe9g6YHwHO6F3OqNMao', - 'txt': 'Status & Keycard – Hardware-Enforced Security', - 'subtitle': 'YouTube'}, - 'twitter': { - 'url': 'https://twitter.com/ethdotorg/status/1445161651771162627?s=20', - 'txt': "We've rethought how we translate content, allowing us to translate", - 'subtitle': 'Twitter' - }} - - self.home_1.just_fyi("Check enabling and sending first gif") - self.chat_2.send_message(giphy_url) - self.chat_2.element_by_translation_id("dont-ask").click() - self.chat_1.element_by_translation_id("enable").wait_and_click() - self.chat_1.element_by_translation_id("enable-all").wait_and_click() - self.chat_1.close_modal_view_from_chat_button.click() - if not self.chat_1.get_preview_message_by_text(giphy_url).preview_image: - self.errors.append("No preview is shown for %s" % giphy_url) - for key in preview_urls: - self.home_2.just_fyi("Checking %s preview case" % key) - data = preview_urls[key] - self.chat_2.send_message(data['url']) - message = self.chat_1.get_preview_message_by_text(data['url']) - if data['txt'] not in message.preview_title.text: - self.errors.append("Title '%s' does not match expected" % message.preview_title.text) - if message.preview_subtitle.text != data['subtitle']: - self.errors.append("Subtitle '%s' does not match expected" % message.preview_subtitle.text) - - self.home_2.just_fyi("Check if after do not ask again previews are not shown and no enable button appear") - if self.chat_2.element_by_translation_id("enable").is_element_displayed(): - self.errors.append("Enable button is still shown after clicking on 'Den't ask again'") - if self.chat_2.get_preview_message_by_text(giphy_url).preview_image: - self.errors.append("Preview is shown for sender without permission") - self.errors.verify_no_errors() - - @marks.testrail_id(6270) - def test_public_chat_mark_all_messages_as_read(self): - [chat.get_back_to_home_view() for chat in (self.chat_1, self.chat_2)] - self.home_2.get_chat('#' + self.public_chat_name).click() - self.chat_2.send_message(self.text_message) - if not self.home_1.home_button.public_unread_messages.is_element_displayed(): - self.errors.append('New messages public chat badge is not shown on Home button') - chat_element = self.home_1.get_chat('#' + self.public_chat_name) - if not chat_element.new_messages_public_chat.is_element_displayed(): - self.errors.append('New messages counter is not shown in public chat') - chat_element.long_press_element() - self.home_1.mark_all_messages_as_read_button.click() - self.home_1.home_button.double_click() - if self.home_1.home_button.public_unread_messages.is_element_displayed(): - self.errors.append('New messages public chat badge is shown on Home button after marking messages as read') - if chat_element.new_messages_public_chat.is_element_displayed(): - self.errors.append('Unread messages badge is shown in public chat while while there are no unread messages') - - self.errors.verify_no_errors() - - @pytest.mark.xdist_group(name="three_1") @marks.critical class TestPublicChatBrowserOneDeviceMerged(MultipleSharedDeviceTestCase): @@ -591,14 +378,11 @@ class TestCommunityMultipleDeviceMerged(MultipleSharedDeviceTestCase): self.profile_1.add_contact_via_contacts_list(self.public_key_2) self.profile_1.communities_tab.click() self.home_2.chats_tab.click() - self.home_2.handle_contact_request(self.default_username_1) - - self.community_leave = 'community_leave' self.text_message = 'hello' + + self.home_1.just_fyi("Open community to message") self.home_1.communities_tab.click() - self.home_1.create_community(name=self.community_leave, description='community to be left', require_approval=False) - self.home_1.back_button.double_click() self.community_name = self.home_1.get_random_chat_name() self.channel_name = self.home_1.get_random_chat_name() self.home_1.create_community(name=self.community_name, description='community to test', require_approval=False) @@ -606,13 +390,19 @@ class TestCommunityMultipleDeviceMerged(MultipleSharedDeviceTestCase): self.community_1.send_invite_to_community(self.default_username_2) self.channel_1 = self.community_1.add_channel(self.channel_name) self.channel_1.send_message(self.text_message) - self.chat_2 = self.home_2.get_chat(self.default_username_1).click() self.chat_2.element_by_text_part('View').click() - self.community_2 = CommunityView(self.drivers[1]) self.community_2.join_button.click() - self.channel_2 = self.community_2.get_chat(self.channel_name).click() + + self.home_1.just_fyi("Reopen community view to use new interface") + for home in (self.home_1, self.home_2): + home.jump_to_communities_home() + home.get_chat(self.community_name, community=True).click() + community_view = home.get_community_view() + community_view.get_channel(self.channel_name).click() + self.channel_2 = self.home_2.get_chat_view() + @marks.testrail_id(702838) @marks.xfail(reason="blocked by 14797") @@ -633,9 +423,6 @@ class TestCommunityMultipleDeviceMerged(MultipleSharedDeviceTestCase): @marks.testrail_id(702843) def test_community_message_edit(self): message_before_edit, message_after_edit = 'Message BEFORE edit', "Message AFTER edit 2" - if not self.channel_2.chat_message_input.is_element_displayed(): - self.home_2.communities_tab.click() - self.community_2.get_chat(self.channel_name).click() self.channel_1.send_message(message_before_edit) self.channel_1.edit_message_in_chat(message_before_edit, message_after_edit) for channel in (self.channel_1, self.channel_2): @@ -653,8 +440,8 @@ class TestCommunityMultipleDeviceMerged(MultipleSharedDeviceTestCase): for channel in (self.channel_1, self.channel_2): if not channel.chat_element_by_text(message_to_delete_everyone).is_element_disappeared(30): self.errors.append("Deleted message is shown in channel") - if not channel.element_by_translation_id('message-deleted-for-everyone').is_element_displayed(30): - self.errors.append("System message about deletion for everyone is not displayed") + if not self.channel_2.element_by_translation_id('message-deleted-for-everyone').is_element_displayed(30): + self.errors.append("System message about deletion for everyone is not displayed") self.home_2.just_fyi('Deleting message for me. Checking that message is deleted only for the author of the message') self.channel_2.send_message(message_to_delete_for_me) @@ -704,12 +491,11 @@ class TestCommunityMultipleDeviceMerged(MultipleSharedDeviceTestCase): 'yotube_short': { 'url': 'https://youtu.be/Je7yErjEVt4', 'txt': 'Status, your gateway to Ethereum', + 'subtitle': 'YouTube'}, + 'yotube_full': { + 'url': 'https://www.youtube.com/watch?v=XN-SVmuJH2g&list=PLbrz7IuP1hrgNtYe9g6YHwHO6F3OqNMao', + 'txt': 'Status & Keycard – Hardware-Enforced Security', 'subtitle': 'YouTube'} - # blocked by 14865 - # 'yotube_full': { - # 'url': 'https://www.youtube.com/watch?v=XN-SVmuJH2g&list=PLbrz7IuP1hrgNtYe9g6YHwHO6F3OqNMao', - # 'txt': 'Status & Keycard – Hardware-Enforced Security', - # 'subtitle': 'YouTube'} # twitter link is temporary removed from check as current xpath locator in message.preview_title is not applicable for this type of links # 'twitter': { # 'url': 'https://twitter.com/ethdotorg/status/1445161651771162627?s=20', @@ -752,7 +538,6 @@ class TestCommunityMultipleDeviceMerged(MultipleSharedDeviceTestCase): @marks.testrail_id(702841) def test_community_unread_messages_badge(self): - self.channel_1.send_message('пиу') self.channel_1.jump_to_communities_home() message = 'test message' self.channel_2.send_message(message) @@ -762,43 +547,46 @@ class TestCommunityMultipleDeviceMerged(MultipleSharedDeviceTestCase): self.errors.append('New message community badge is not shown') community_1 = community_element_1.click() - channel_1_element = community_1.get_chat('# %s' % self.channel_name) - # blocked of 14906 - # self.home_1.just_fyi('Check new messages badge is shown for community') - # if not channel_1_element.new_messages_public_chat.is_element_displayed(): - # self.errors.append('New messages channel badge is not shown on channel') + channel_1_element = community_1.get_channel(self.channel_name) + + self.home_1.just_fyi('Check new messages badge is shown for community') + if not community_element_1.new_messages_community.is_element_displayed(): + self.errors.append('New messages channel badge is not shown on channel') channel_1_element.click() self.errors.verify_no_errors() - - @marks.testrail_id(702842) - @marks.xfail(reason='blocked due to navigation issue 14906') - def test_community_mark_all_messages_as_read(self): - self.channel_2.send_message(self.text_message) - chan_1_element = self.community_1.get_chat('# %s' % self.channel_name) - if not chan_1_element.new_messages_public_chat.is_element_displayed(): - self.errors.append('New messages counter is not shown in public chat') - chan_1_element.long_press_element() - self.community_1.mark_all_messages_as_read_button.click() - if chan_1_element.new_messages_public_chat.is_element_displayed(): - self.errors.append('Unread messages badge is shown in community channel while there are no unread messages') - self.community_1.click_system_back_button_until_element_is_shown() - community_1_element = self.home_1.get_chat(self.community_name, community=True) - if community_1_element.new_messages_community.is_element_displayed(): - self.errors.append('New messages community badge is shown on community after marking messages as read') - self.errors.verify_no_errors() + # @marks.testrail_id(702842) + # Skipped until implemented in NEW UI + # def test_community_mark_all_messages_as_read(self): + # self.channel_1.jump_to_communities_home() + # self.home_1.get_chat(self.community_name, community=True).click() + # self.channel_2.send_message(self.text_message) + # #self.home_1.get_chat(self.community_name).click() + # channel_1_element = self.community_1.get_channel(self.channel_name) + # if not channel_1_element.new_messages_public_chat.is_element_displayed(): + # self.errors.append('New messages counter is not shown in public chat') + # mark_as_read_button = self.community_1.mark_all_messages_as_read_button + # channel_1_element.long_press_until_element_is_shown(mark_as_read_button) + # mark_as_read_button.click() + # if channel_1_element.new_messages_public_chat.is_element_displayed(): + # self.errors.append('Unread messages badge is shown in community channel while there are no unread messages') + # self.community_1.click_system_back_button_until_element_is_shown() + # community_1_element = self.home_1.get_chat(self.community_name, community=True) + # if community_1_element.new_messages_community.is_element_displayed(): + # self.errors.append('New messages community badge is shown on community after marking messages as read') + # self.errors.verify_no_errors() @marks.testrail_id(702845) + @marks.xfail(reason="blocked by 15187") def test_community_leave(self): - if not self.home_1.communities_tab.is_element_displayed(): - self.channel_1.click_system_back_button_until_element_is_shown() - comm_to_leave_element = self.home_1.get_chat(self.community_leave, community=True) - comm_to_leave_element.long_press_element() - community_to_leave = CommunityView(self.drivers[0]) + self.home_2.jump_to_communities_home() + community = self.home_2.element_by_text(self.community_name) + community_to_leave = CommunityView(self.drivers[1]) + community.long_press_until_element_is_shown(community_to_leave.leave_community_button) community_to_leave.leave_community_button.click() community_to_leave.leave_community_button.click() - if comm_to_leave_element.is_element_displayed(): + if community.is_element_displayed(): self.errors.append('Community is still shown in the list after leave') self.errors.verify_no_errors() diff --git a/test/appium/tests/medium/test_activity_center.py b/test/appium/tests/medium/test_activity_center.py index 5ae19cf683..9f56a6ff68 100644 --- a/test/appium/tests/medium/test_activity_center.py +++ b/test/appium/tests/medium/test_activity_center.py @@ -203,6 +203,7 @@ class TestActivityCenterMultipleDevicePR(MultipleSharedDeviceTestCase): self.profile_1.switch_push_notifications() @marks.testrail_id(702850) + @marks.xfail(reason="blocked with 15180") def test_activity_center_decline_contact_request_no_pn(self): self.device_1.put_app_to_background() self.device_2.just_fyi('Device2 sends a contact request to Device1') @@ -235,13 +236,21 @@ class TestActivityCenterMultipleDevicePR(MultipleSharedDeviceTestCase): self.errors.verify_no_errors() @marks.testrail_id(702851) - @marks.xfail(reason='blocked by 14798') def test_activity_center_mentions_in_community_jump_to(self): - self.device_2.just_fyi('Device2 sends a contact request to Device1') + self.device_2.just_fyi('Device2 re-sends a contact request to Device1') self.home_2.browser_tab.click() self.profile_2.click_system_back_button_until_element_is_shown(self.profile_2.contacts_button) - self.profile_2.add_contact_via_contacts_list(self.public_key_1) - self.profile_2.click_system_back_button_until_element_is_shown(self.profile_2.contacts_button) + + self.profile_2.contacts_button.wait_and_click(30) + self.profile_2.add_new_contact_button.wait_and_click() + chat = self.profile_2.get_chat_view() + chat.public_key_edit_box.click() + chat.public_key_edit_box.send_keys(self.public_key_1) + chat.view_profile_new_contact_button.click_until_presence_of_element(chat.profile_block_contact) + if chat.profile_remove_from_contacts.is_element_displayed(20): + chat.profile_remove_from_contacts.click() + chat.profile_add_to_contacts.click() + self.profile_2.click_system_back_button_until_element_is_shown() self.device_1.just_fyi('Device1 accepts pending contact request and check contact list') self.home_1.chats_tab.click() @@ -259,8 +268,6 @@ class TestActivityCenterMultipleDevicePR(MultipleSharedDeviceTestCase): self.home_1.create_community(name=self.community_name, description='community to test', require_approval=False) self.community_1 = CommunityView(self.drivers[0]) self.community_1.send_invite_to_community(self.default_username_2) - self.channel_1 = self.community_1.add_channel(self.channel_name) - self.channel_1.send_message(self.text_message) self.home_2.chats_tab.click() self.home_2.recent_tab.click() @@ -268,10 +275,11 @@ class TestActivityCenterMultipleDevicePR(MultipleSharedDeviceTestCase): self.chat_2.element_by_text_part('View').click() self.community_2 = CommunityView(self.drivers[1]) self.community_2.join_button.click() + self.channel_1 = self.community_1.add_channel(self.channel_name) + self.channel_1.send_message(self.text_message) self.channel_2 = self.community_2.get_chat(self.channel_name).click() self.community_2.just_fyi("Check Jump to screen and redirect on tap") - self.channel_2.click_system_back_button() self.community_2.jump_to_button.click() for card in (self.community_name, self.default_username_1): if not self.community_2.element_by_text_part(card).is_element_displayed(20): diff --git a/test/appium/views/base_element.py b/test/appium/views/base_element.py index 27eef03570..3ea04ff018 100644 --- a/test/appium/views/base_element.py +++ b/test/appium/views/base_element.py @@ -280,6 +280,15 @@ class BaseElement(object): action = TouchAction(self.driver) action.long_press(element).release().perform() + def long_press_until_element_is_shown(self, expected_element): + element = self.find_element() + self.driver.info("Long press on `%s` until expected element is shown" % self.name) + action = TouchAction(self.driver) + for _ in range(3): + action.long_press(element).release().perform() + if expected_element.is_element_displayed(): + return + def measure_time_before_element_appears(self, max_wait_time=30): def wrapper(): return self.wait_for_visibility_of_element(max_wait_time) diff --git a/test/appium/views/base_view.py b/test/appium/views/base_view.py index 6f75f1cf65..94467c8828 100644 --- a/test/appium/views/base_view.py +++ b/test/appium/views/base_view.py @@ -530,6 +530,10 @@ class BaseView(object): from views.chat_view import ChatView return ChatView(self.driver) + def get_community_view(self): + from views.chat_view import CommunityView + return CommunityView(self.driver) + def get_sign_in_view(self): from views.sign_in_view import SignInView return SignInView(self.driver) diff --git a/test/appium/views/chat_view.py b/test/appium/views/chat_view.py index 41ffcbbcf7..69c49f9c22 100644 --- a/test/appium/views/chat_view.py +++ b/test/appium/views/chat_view.py @@ -4,7 +4,7 @@ from datetime import datetime, timedelta from time import sleep import dateutil.parser -from selenium.common.exceptions import NoSuchElementException +from selenium.common.exceptions import NoSuchElementException, TimeoutException from tests import emojis from views.base_element import Button, EditBox, Text, BaseElement, SilentButton @@ -171,7 +171,8 @@ class ChatElementByText(Text): def username(self): class Username(Text): def __init__(self, driver, parent_locator: str): - super().__init__(driver, prefix=parent_locator, xpath="/android.view.ViewGroup/android.widget.TextView[1]") + super().__init__(driver, prefix=parent_locator, + xpath="/android.view.ViewGroup/android.widget.TextView[1]") return Username(self.driver, self.locator) @@ -191,8 +192,33 @@ class ChatElementByText(Text): @property def status(self) -> str: - result = re.search('\[(.*) DEBUG\]', Text(self.driver, prefix=self.locator, xpath="//*[contains(@text, 'DEBUG')]").text) - return result.group(1) if result else '' + Text(self.driver, xpath=self.locator).click() + status_element = Text(self.driver, prefix=self.locator, + xpath="//*[@content-desc='message-status']/android.widget.TextView") + status = '' + i = 1 + + while i < 5: + i += 1 + if Text(self.driver, prefix=self.locator, + xpath="//*[@content-desc='message-sending']").is_element_displayed(2): + status = "Sending" + break + else: + Text(self.driver, xpath=self.locator).click() + if status_element.is_element_displayed(2): + status = status_element.text + break + time.sleep(2) + return status + + def wait_for_status_to_be(self, expected_status: str, timeout: int = 30): + start_time = time.time() + while time.time() - start_time <= timeout: + if self.status == expected_status: + return + time.sleep(1) + raise TimeoutException("Message status was not changed to %s" % expected_status) @property def sent_status_checkmark(self) -> object: @@ -222,26 +248,6 @@ class ChatElementByText(Text): except NoSuchElementException: return '' - # Old UI - # def emojis_below_message(self, emoji: str = 'thumbs-up', own=True): - # class EmojisNumber(Text): - # def __init__(self, driver, parent_locator: str): - # self.own = own - # self.emoji = emoji - # self.emojis_id = 'emoji-' + str(emojis[self.emoji]) + '-is-own-' + str(self.own).lower() - # super().__init__(driver, prefix=parent_locator, xpath="/../..//*[@content-desc='%s']" % self.emojis_id) - # - # @property - # def text(self): - # try: - # text = self.find_element().text - # self.driver.info("%s is '%s' for '%s' where my reaction is set on message is '%s'" % (self.name, text, self.emoji, str(self.own))) - # return text - # except NoSuchElementException: - # return 0 - # - # return int(EmojisNumber(self.driver, self.locator).text) - def emojis_below_message(self, emoji: str = 'thumbs-up'): class EmojisNumber(Text): def __init__(self, driver, parent_locator: str): @@ -321,6 +327,7 @@ class CommunityView(HomeView): def __init__(self, driver): super().__init__(driver) + #### OLD UI # Main community page (list with channels) self.add_channel_button = HomeView(self.driver).plus_button self.community_create_a_channel_button = Button(self.driver, accessibility_id="community-create-channel") @@ -349,6 +356,15 @@ class CommunityView(HomeView): self.join_button = Button(self.driver, translation_id="join") self.follow_button = Button(self.driver, translation_id="follow") + #### NEW UI + # Communities initial page + self.community_description_text = Text(self.driver, accessibility_id="community-description-text") + + def get_channel(self, channel_name: str): + self.driver.info("Getting %s channel element in community" % channel_name) + chat_element = self.get_chat(username=channel_name, community_channel=True, wait_time=30) + return chat_element + def add_channel(self, name: str, description="Some new channel"): self.driver.info("Adding channel in community") self.plus_button.click() @@ -397,6 +413,7 @@ class CommunityView(HomeView): self.share_invite_button.click_until_presence_of_element(self.invite_button) self.back_button.click_until_presence_of_element(self.plus_button) + class PreviewMessage(ChatElementByText): def __init__(self, driver, text: str): super().__init__(driver, text=text) @@ -421,7 +438,8 @@ class PreviewMessage(ChatElementByText): def preview_title(self): class PreviewTitle(SilentButton): def __init__(self, driver, parent_locator: str): - super().__init__(driver, prefix=parent_locator, xpath="//*[@content-desc='member-photo']/preceding-sibling::android.widget.TextView[2]") + super().__init__(driver, prefix=parent_locator, + xpath="//*[@content-desc='member-photo']/preceding-sibling::android.widget.TextView[2]") return PreviewMessage.return_element_or_empty(PreviewTitle(self.driver, self.locator)) @@ -429,7 +447,8 @@ class PreviewMessage(ChatElementByText): def preview_subtitle(self): class PreviewSubTitle(SilentButton): def __init__(self, driver, parent_locator: str): - super().__init__(driver, prefix=parent_locator, xpath="//*[@content-desc='member-photo']/preceding-sibling::android.widget.TextView[3]") + super().__init__(driver, prefix=parent_locator, + xpath="//*[@content-desc='member-photo']/preceding-sibling::android.widget.TextView[3]") return PreviewMessage.return_element_or_empty(PreviewSubTitle(self.driver, self.locator)) @@ -592,13 +611,19 @@ class PinnedMessagesList(BaseElement): def __init__(self, driver): super().__init__(driver, xpath="//*[@content-desc='pinned-messages-list']") + def get_pinned_messages_number(self): + self.driver.info("Getting number of pinned messages inside pinned messages list element") + element = BaseElement(self.driver, prefix=self.locator, xpath="//*[@content-desc='message-sent']") + return len(element.find_elements()) + def message_element_by_text(self, text): message_element = Text(self.driver, prefix=self.locator, xpath="//*[starts-with(@text,'%s')]" % text) self.driver.info("Looking for a pinned message by text: %s" % message_element.exclude_emoji(text)) return message_element def get_message_pinned_by_text(self, text): - xpath = "//*[starts-with(@text,'%s')]/../../../*[@content-desc='pinned-by']/android.widget.TextView" % text + xpath = "//*[starts-with(@text,'%s')]/ancestor::*[@content-desc='message-sent']/" % text + \ + "preceding-sibling::*[@content-desc='pinned-by']/android.widget.TextView" pinned_by_element = Text(self.driver, prefix=self.locator, xpath=xpath) self.driver.info("Looking for a pinned by message with text: %s" % text) return pinned_by_element @@ -716,6 +741,7 @@ class ChatView(BaseView): self.profile_mute_contact = Button(self.driver, accessibility_id="Mute-item-button") self.profile_unmute_contact = Button(self.driver, accessibility_id="Unmute-item-button") self.profile_add_to_contacts = Button(self.driver, accessibility_id="Add to contacts-item-button") + self.profile_remove_from_contacts = Button(self.driver, accessibility_id="Remove from contacts-item-button") self.profile_details = Button(self.driver, accessibility_id="share-button") self.profile_nickname = Text(self.driver, xpath="//*[@content-desc='profile-nickname-item']/android.widget.TextView[2]") @@ -748,6 +774,7 @@ class ChatView(BaseView): self.pin_limit_popover = BaseElement(self.driver, translation_id="pin-limit-reached") self.view_pinned_messages_button = Button(self.driver, accessibility_id="pinned-banner") + def get_outgoing_transaction(self, account=None, transaction_value=None) -> object: if account is None: account = self.status_account_name @@ -871,13 +898,15 @@ class ChatView(BaseView): def pin_message(self, message, action="pin"): self.driver.info("Looking for message '%s' pin" % message) - self.element_by_text_part(message).long_press_element() - self.element_by_translation_id(action).click() + element = self.element_by_translation_id(action) + self.chat_element_by_text(message).long_press_until_element_is_shown(element) + element.click_until_absense_of_element(element) 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) - self.element_by_text_part(message_to_edit).long_press_element() - self.element_by_translation_id("edit-message").click() + element = self.element_by_translation_id("edit-message") + self.element_by_text_part(message_to_edit).long_press_until_element_is_shown(element) + element.click() self.chat_message_input.clear() self.chat_message_input.send_keys(message_to_update) self.send_message_button.click() @@ -896,7 +925,7 @@ class ChatView(BaseView): def quote_message(self, message=str): self.driver.info("Quoting '%s' message" % message) - self.element_by_text_part(message).long_press_element() + self.element_by_text_part(message).long_press_until_element_is_shown(self.reply_message_button) self.reply_message_button.click() def set_reaction(self, message: str, emoji: str = 'thumbs-up', emoji_message=False): @@ -904,16 +933,16 @@ class ChatView(BaseView): key = emojis[emoji] # Audio message is obvious should be tapped not on audio-scroll-line # so we tap on its below element as exception here (not the case for link/tag message!) + element = Button(self.driver, accessibility_id='emoji-picker-%s' % key) if message == 'audio': self.audio_message_in_chat_timer.long_press_element() else: if not emoji_message: - self.chat_element_by_text(message).long_press_element() + self.chat_element_by_text(message).long_press_until_element_is_shown(element) else: - self.element_by_text_part(message).long_press_element() + self.element_by_text_part(message).long_press_until_element_is_shown(element) # old UI # element = Button(self.driver, accessibility_id='pick-emoji-%s' % key) - element = Button(self.driver, accessibility_id='emoji-picker-%s' % key) element.click() element.wait_for_invisibility_of_element() diff --git a/test/appium/views/home_view.py b/test/appium/views/home_view.py index 3567c1d122..8a83f405fc 100644 --- a/test/appium/views/home_view.py +++ b/test/appium/views/home_view.py @@ -17,11 +17,16 @@ class ChatButton(Button): class ChatElement(SilentButton): - def __init__(self, driver, username_part, community=False): + def __init__(self, driver, username_part, community=False, community_channel=False): self.username = username_part self.community = community - super().__init__(driver, - xpath="//*[@content-desc='chat-name-text'][starts-with(@text,'%s')]/.." % username_part) + self.community_channel = community_channel + if self.community_channel is True: + super().__init__(driver, + xpath="//*[@content-desc='chat-name-text']//*[starts-with(@text,'# %s')]/../.." % username_part) + else: + super().__init__(driver, + xpath="//*[@content-desc='chat-name-text'][starts-with(@text,'%s')]/.." % username_part) def navigate(self): if self.community: @@ -34,7 +39,7 @@ class ChatElement(SilentButton): def click(self): if self.community: from views.chat_view import CommunityView - desired_element = CommunityView(self.driver).community_options_button + desired_element = CommunityView(self.driver).community_description_text else: from views.chat_view import ChatView desired_element = ChatView(self.driver).chat_message_input @@ -124,102 +129,6 @@ class ActivityCenterElement(SilentButton): decline_element.click() -# Old UI -# def __init__(self, driver, chat_name): -# self.chat_name = chat_name -# super().__init__(driver, -# xpath="//*[@content-desc='chat-name-or-sender-text'][starts-with(@text,'%s')]/../.." % chat_name) - -# def navigate(self): -# from views.chat_view import ChatView -# return ChatView(self.driver) -# -# def click(self): -# from views.chat_view import ChatView -# desired_element = ChatView(self.driver).chat_message_input -# self.click_until_presence_of_element(desired_element=desired_element) -# -# return self.navigate() -# -# @property -# def chat_image(self): -# class ChatImage(BaseElement): -# def __init__(self, driver, parent_locator: str): -# super().__init__(driver, xpath="%s//*[@content-desc='current-account-photo']" % parent_locator) -# -# return ChatImage(self.driver, self.locator) -# -# @property -# def chat_message_preview(self): -# class ChatMessagePreview(BaseElement): -# def __init__(self, driver, parent_locator: str): -# super().__init__(driver, xpath="%s//*[@content-desc='chat-message-text']" % parent_locator) -# -# return ChatMessagePreview(self.driver, self.locator).text -# -# @property -# def chat_name_indicator_text(self): -# class ChatNameIndicatorText(BaseElement): -# def __init__(self, driver, parent_locator: str): -# super().__init__(driver, -# xpath="(%s//*[@content-desc='chat-name-container']//android.widget.TextView)[last()]" % parent_locator) -# -# try: -# return ChatNameIndicatorText(self.driver, self.locator).text -# except NoSuchElementException: -# return '' -# -# def accept_contact_request(self): -# try: -# accept_element = Button(self.driver, xpath=self.locator + '/*[@content-desc="accept-cr"]').find_element() -# except NoSuchElementException: -# return '' -# if accept_element: -# accept_element.click() -# -# def decline_contact_request(self): -# try: -# decline_element = Button(self.driver, xpath=self.locator + '/*[@content-desc="decline-cr"]').find_element() -# except NoSuchElementException: -# return '' -# if decline_element: -# decline_element.click() -# -# -# class PushNotificationElement(SilentButton): -# def __init__(self, driver, pn_text): -# self.pn_text = pn_text -# super().__init__(driver, xpath="//*[@text='%s']" % pn_text) -# -# @property -# def icon(self): -# class PnIconElement(BaseElement): -# def __init__(self, driver, parent_locator): -# super().__init__(driver, -# xpath="%s/../../../../*/*[@resource-id='android:id/message_icon']" % parent_locator) -# -# return PnIconElement(self.driver, self.locator) -# -# @property -# def username(self): -# class PnUsername(BaseElement): -# def __init__(self, driver, parent_locator): -# super().__init__(driver, -# xpath="%s/../../*[@resource-id='android:id/message_name']" % parent_locator) -# -# return PnUsername(self.driver, self.locator).text -# -# @property -# def group_chat_icon(self): -# class GroupChatIconElement(BaseElement): -# def __init__(self, driver, parent_locator): -# super().__init__(driver, -# xpath="%s/../../../../*[@resource-id='android:id/right_icon_container']" % parent_locator) -# -# return GroupChatIconElement(self.driver, self.locator) - - - class PushNotificationElement(SilentButton): def __init__(self, driver, pn_text): self.pn_text = pn_text @@ -334,10 +243,13 @@ class HomeView(BaseView): except TimeoutException: break - def get_chat(self, username, community=False, wait_time=10): - self.driver.info("Looking for chat: '%s'" % username) - chat_element = ChatElement(self.driver, username[:25], community=community) - if not chat_element.is_element_displayed(wait_time): + def get_chat(self, username, community=False, community_channel=False, wait_time=10): + if community: + self.driver.info("Looking for community: '%s'" % username) + else: + self.driver.info("Looking for chat: '%s'" % username) + chat_element = ChatElement(self.driver, username[:25], community=community, community_channel=community_channel) + if not chat_element.is_element_displayed(wait_time) and community is False and community_channel is False: if self.notifications_unread_badge.is_element_displayed(30): chat_in_ac = ActivityCenterElement(self.driver, username[:25]) self.open_activity_center_button.click_until_presence_of_element(chat_in_ac)