Skip to content

Commit

Permalink
e2e: android14
Browse files Browse the repository at this point in the history
  • Loading branch information
yevh-berdnyk committed Dec 19, 2023
1 parent 602b271 commit 711e64b
Show file tree
Hide file tree
Showing 16 changed files with 82 additions and 88 deletions.
26 changes: 13 additions & 13 deletions test/appium/tests/activity_center/test_activity_center.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,11 +27,12 @@ def prepare_devices(self):

@marks.testrail_id(702850)
def test_activity_center_contact_request_decline(self):
app_package = self.device_1.driver.current_package
self.device_1.put_app_to_background()
self.device_2.just_fyi('Device2 sends a contact request to Device1 via Paste button and check user details')
self.home_2.driver.set_clipboard_text(self.public_key_1)
self.home_2.new_chat_button.click_until_presence_of_element(self.home_2.add_a_contact_chat_bottom_sheet_button)
self.home_2.add_a_contact_chat_bottom_sheet_button.click()
self.home_2.driver.set_clipboard_text(self.public_key_1)
self.home_2.element_by_translation_id("paste").click()
self.home_2.element_by_translation_id("user-found").wait_for_visibility_of_element(10)
if self.home_2.user_name_text.is_element_displayed(30):
Expand All @@ -52,7 +53,8 @@ def test_activity_center_contact_request_decline(self):
self.device_1.open_notification_bar()
if self.home_1.element_by_text_part("Please add me to your contacts").is_element_displayed():
self.errors.append("Push notification with text was received for new message in activity centre")
self.device_1.click_system_back_button(2)
self.device_1.click_system_back_button()
self.device_1.driver.activate_app(app_package)

self.device_1.just_fyi('Device1 verifies pending contact request')
self.home_1.contacts_tab.click()
Expand Down Expand Up @@ -93,10 +95,10 @@ def test_activity_center_contact_request_accept_swipe_mark_all_as_read(self):
self.device_2.create_user(username=new_username, first_user=False)

self.device_2.just_fyi('Device2 sends a contact request to Device1 via Paste button and check user details')
self.home_2.driver.set_clipboard_text(self.public_key_1)
self.home_2.chats_tab.click()
self.home_2.new_chat_button.click_until_presence_of_element(self.home_2.add_a_contact_chat_bottom_sheet_button)
self.home_2.add_a_contact_chat_bottom_sheet_button.click()
self.home_2.driver.set_clipboard_text(self.public_key_1)
self.home_2.element_by_translation_id("paste").click()
self.home_2.element_by_translation_id("user-found").wait_for_visibility_of_element(10)
chat = self.home_2.get_chat_view()
Expand All @@ -119,7 +121,7 @@ def test_activity_center_contact_request_accept_swipe_mark_all_as_read(self):

self.home_1.just_fyi("Check that can accept contact request from read notifications")
self.home_1.activity_unread_filter_button.click()
cr_element.swipe_right_on_element()
cr_element.message_body.swipe_right_on_element()
self.home_1.activity_notification_swipe_button.click_inside_element_by_coordinate(rel_x=0.5, rel_y=0.5)
self.home_1.close_activity_centre.click()
self.home_1.contacts_tab.click()
Expand All @@ -145,10 +147,10 @@ def test_add_contact_field_validation(self):
self.device_2.create_user(username=new_username_2, first_user=False)

self.device_2.just_fyi('Device2 sends a contact request to Device1 using his profile link')
self.home_2.driver.set_clipboard_text("https://status.app/u#" + self.public_key_1)
self.home_2.chats_tab.click()
self.home_2.new_chat_button.click_until_presence_of_element(self.home_2.add_a_contact_chat_bottom_sheet_button)
self.home_2.add_a_contact_chat_bottom_sheet_button.click()
self.home_2.driver.set_clipboard_text("https://status.app/u#" + self.public_key_1)
self.home_2.element_by_translation_id("paste").click()
self.home_2.element_by_translation_id("user-found").wait_for_visibility_of_element(10)
if self.home_2.user_name_text.is_element_displayed(30):
Expand All @@ -168,9 +170,9 @@ def test_add_contact_field_validation(self):

self.home_2.just_fyi("Device 2 checks that can find already added contact using public key")
self.home_2.navigate_back_to_home_view()
self.home_2.driver.set_clipboard_text(self.public_key_1)
self.home_2.new_chat_button.click_until_presence_of_element(self.home_2.add_a_contact_chat_bottom_sheet_button)
self.home_2.add_a_contact_chat_bottom_sheet_button.click()
self.home_2.driver.set_clipboard_text(self.public_key_1)
self.home_2.element_by_translation_id("paste").click()
self.home_2.element_by_translation_id("user-found").wait_for_visibility_of_element(10)
if self.home_2.user_name_text.is_element_displayed(30):
Expand Down Expand Up @@ -251,17 +253,15 @@ def prepare_devices(self):
@marks.testrail_id(702936)
def test_navigation_jump_to(self):
self.community_1.just_fyi("Check Jump to screen and redirect on tap")
self.community_1.jump_to_button.click()
self.community_1.click_on_floating_jump_to()
for card in (self.community_name, self.username_2):
if not self.community_1.element_by_text_part(card).is_element_displayed(20):
self.errors.append("Card %s is not shown on Jump to screen!" % card)
self.community_1.element_by_translation_id("community-channel").click()
if not self.channel_1.chat_element_by_text(self.text_message).is_element_displayed(20):
self.errors.append("User was not redirected to community channel after tapping on community channel card!")
element = self.channel_1.jump_to_button.find_element()
self.channel_1.click_system_back_button()
self.channel_1.wait_for_staleness_of_element(element)
self.community_1.jump_to_button.click()
self.community_1.click_on_floating_jump_to()
self.community_1.element_by_text_part(self.username_2).click()
if not self.chat_1.chat_element_by_text(self.one_to_one_message).is_element_displayed(20):
self.errors.append("User was not redirected to 1-1 chat after tapping card!")
Expand Down Expand Up @@ -315,7 +315,7 @@ def test_activity_center_reply_read_unread_delete_filter_swipe(self):
self.home_2.chats_tab.is_element_displayed() # just saving device 2 session from expiration

self.home_1.just_fyi("Mark it as read and check filter")
reply_element.swipe_right_on_element()
reply_element.title.swipe_right_on_element(width_percentage=6)
self.home_1.activity_notification_swipe_button.click()
if reply_element.is_element_displayed(2):
self.errors.append("Message is not marked as read!")
Expand All @@ -326,7 +326,7 @@ def test_activity_center_reply_read_unread_delete_filter_swipe(self):
self.home_2.chats_tab.is_element_displayed() # just saving device 2 session from expiration

self.home_1.just_fyi("Mark it as unread and check filter via right swipe")
reply_element.swipe_right_on_element()
reply_element.title.swipe_right_on_element(width_percentage=6)
self.home_1.activity_notification_swipe_button.click()
if not reply_element.unread_indicator.is_element_displayed():
self.errors.append("No unread dot is shown on activity center element after marking it as unread!")
Expand Down Expand Up @@ -462,7 +462,7 @@ def test_activity_center_admin_notification_accept_swipe(self):
self.errors.append("Expected title is not shown, '%s' is instead!" % reply_element.title)
if not reply_element.unread_indicator.is_element_displayed():
self.errors.append("No unread dot is shown on activity center element!")
reply_element.swipe_right_on_element()
reply_element.title.swipe_right_on_element(width_percentage=2.5)
self.home_1.activity_notification_swipe_button.click()
self.home_1.close_activity_centre.click()

Expand Down
4 changes: 2 additions & 2 deletions test/appium/tests/base_test_case.py
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ def get_capabilities_sauce_lab():
caps['appium:app'] = 'sauce-storage:' + test_suite_data.apk_name
caps['appium:deviceName'] = 'Android GoogleAPI Emulator'
caps['appium:deviceOrientation'] = 'portrait'
caps['appium:platformVersion'] = '10.0'
caps['appium:platformVersion'] = '14.0'
caps['appium:automationName'] = 'UiAutomator2'
caps['appium:newCommandTimeout'] = 600
caps['appium:idleTimeout'] = 1000
Expand Down Expand Up @@ -319,7 +319,7 @@ def create_shared_drivers(quantity):
test_suite_data.current_test.testruns[-1].error = "Not all %s drivers are created" % quantity
return drivers, loop
except (MaxRetryError, AttributeError) as e:
test_suite_data.current_test.testruns[-1].error += str(e)
test_suite_data.current_test.testruns[-1].error = str(e)
raise e


Expand Down
34 changes: 13 additions & 21 deletions test/appium/tests/critical/chats/test_1_1_public_chats.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import emoji
import pytest
from _pytest.outcomes import Failed
from appium.webdriver.connectiontype import ConnectionType
from selenium.common.exceptions import TimeoutException, NoSuchElementException

from tests import marks, run_in_parallel, transl
Expand Down Expand Up @@ -268,7 +269,7 @@ def test_1_1_chat_pin_messages(self):
def test_1_1_chat_non_latin_messages_stack_update_profile_photo(self):
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.edit_profile_picture(image_index=2)
self.profile_1.navigate_back_to_home_view()
self.profile_1.chats_tab.click()

Expand Down Expand Up @@ -321,6 +322,7 @@ def test_1_1_chat_push_emoji(self):
self.home_1.chats_tab.click()

self.device_2.just_fyi("Device 2 puts app on background being on Profile view to receive PN with text")
app_package = self.device_2.driver.current_package
self.device_2.put_app_to_background()
self.device_2.open_notification_bar()
if not self.chat_1.chat_message_input.is_element_displayed():
Expand All @@ -334,7 +336,7 @@ def test_1_1_chat_push_emoji(self):
self.device_2.just_fyi("Check text push notification and tap it")
if not self.home_2.get_pn(message):
self.device_2.click_system_back_button()
self.device_2.status_in_background_button.click()
self.device_2.driver.activate_app(app_package)
self.device_2.driver.fail("Push notification with text was not received")
chat_2 = self.device_2.click_upon_push_notification_by_text(message)

Expand All @@ -348,7 +350,7 @@ def test_1_1_chat_push_emoji(self):
self.device_1.just_fyi("Device 1 checks PN with emoji")
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()
self.device_2.driver.activate_app(app_package)
self.device_1.driver.fail("Push notification with emoji was not received")
chat_1 = self.device_1.click_upon_push_notification_by_text(emoji_unicode)

Expand Down Expand Up @@ -416,9 +418,9 @@ def test_1_1_chat_send_image_save_and_share(self):
chat.hide_keyboard_if_shown()
chat.chat_element_by_text(image_description).image_in_message.click()
chat.share_image_icon_button.click()
chat.element_starts_with_text("Gmail").click()
chat.element_starts_with_text("Drive").click()
try:
chat.wait_for_current_package_to_be('com.google.android.gm')
chat.wait_for_current_package_to_be('com.google.android.apps.docs')
except TimeoutException:
self.errors.append(
"%s can't share an image via Gmail." % ("Sender" if chat is self.chat_1 else "Receiver"))
Expand All @@ -444,7 +446,7 @@ def test_1_1_chat_send_image_save_and_share(self):
for chat in self.chat_1, self.chat_2:
chat.just_fyi("Check that image is saved in gallery")
chat.show_images_button.click()
chat.allow_button.click_if_shown()
chat.allow_all_button.click_if_shown()
if not chat.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 %s." % ("sender" if chat is self.chat_1 else "receiver"))
Expand All @@ -458,6 +460,7 @@ def test_1_1_chat_text_message_delete_push_disappear(self):
self.chat_2.jump_to_card_by_text(self.username_1)
if not self.chat_1.chat_message_input.is_element_displayed():
self.chat_1.jump_to_card_by_text(self.username_2)
app_package = self.chat_1.driver.current_package

self.device_2.just_fyi("Verify Device1 can not edit and delete received message from Device2")
message_after_edit_1_1 = 'smth I should edit'
Expand Down Expand Up @@ -504,15 +507,13 @@ def test_1_1_chat_text_message_delete_push_disappear(self):
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()
self.device_2.driver.activate_app(app_package)
self.errors.append("Push notification doesn't appear")
self.chat_2.delete_message_in_chat(message_to_delete)
pn_to_disappear = self.home_1.get_pn(message_to_delete)
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")
self.device_1.navigate_back_to_home_view()
self.device_2.navigate_back_to_home_view()
self.errors.verify_no_errors()


Expand Down Expand Up @@ -573,12 +574,8 @@ def test_1_1_chat_is_shown_message_sent_delivered_from_offline(self):
# self.chat_2.jump_to_card_by_text(self.username_1)
# self.chat_1.jump_to_card_by_text(self.username_2)
self.home_1.just_fyi('Turn on airplane mode and check that offline status is shown on home view')
app_package = self.home_1.driver.current_package
for home in self.homes:
home.toggle_airplane_mode()
if not home.chats_tab.is_element_displayed() and not home.chat_floating_screen.is_element_displayed():
home.driver.activate_app(app_package)
SignInView(home.driver).sign_in()
home.driver.set_network_connection(ConnectionType.AIRPLANE_MODE)

# Not implemented yet
# self.home_1.connection_offline_icon.wait_and_click(20)
Expand All @@ -600,13 +597,8 @@ def test_1_1_chat_is_shown_message_sent_delivered_from_offline(self):
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"')
for i, home in enumerate(self.homes):
home.toggle_airplane_mode()
if not home.chats_tab.is_element_displayed() and not home.chat_floating_screen.is_element_displayed():
home.driver.activate_app(app_package)
SignInView(home.driver).sign_in()
home.chats_tab.click()
home.get_chat(self.username_2 if i == 0 else self.username_1).click()
for home in self.homes:
home.driver.set_network_connection(ConnectionType.ALL_NETWORK_ON)

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(120):
Expand Down
20 changes: 11 additions & 9 deletions test/appium/tests/critical/chats/test_group_chat.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

import pytest
from _pytest.outcomes import Failed
from appium.webdriver.connectiontype import ConnectionType
from selenium.common.exceptions import NoSuchElementException, TimeoutException

from tests import marks, run_in_parallel, transl
Expand Down Expand Up @@ -234,9 +235,9 @@ def test_group_chat_send_image_save_and_share(self):
self.chats[0].just_fyi("Admin opens the image and shares it")
self.chats[0].chat_element_by_text(image_description).image_in_message.click()
self.chats[0].share_image_icon_button.click()
self.chats[0].element_starts_with_text("Gmail").click()
self.chats[0].element_starts_with_text("Drive").click()
try:
self.chats[0].wait_for_current_package_to_be('com.google.android.gm')
self.chats[0].wait_for_current_package_to_be('com.google.android.apps.docs')
except TimeoutException:
self.errors.append("Admin can't share an image via Gmail.")
self.chats[0].navigate_back_to_chat_view()
Expand All @@ -249,13 +250,13 @@ def test_group_chat_send_image_save_and_share(self):
self.chats[2].view_image_options_button.click()
self.chats[2].save_image_icon_button.click()
toast_element = self.chats[2].toast_content_element
if toast_element.is_element_displayed():
toast_element_text = toast_element.text
try:
toast_element_text = toast_element.wait_for_visibility_of_element().text
if toast_element_text != self.chats[2].get_translation_by_key("photo-saved"):
self.errors.append(
"Shown message '%s' doesn't match expected '%s' after saving an image for member_2." % (
toast_element_text, self.chats[2].get_translation_by_key("photo-saved")))
else:
except TimeoutException:
self.errors.append("Message about saving a photo is not shown for member_2.")
self.chats[2].navigate_back_to_chat_view()

Expand All @@ -268,7 +269,7 @@ def test_group_chat_send_image_save_and_share(self):

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()
self.chats[2].allow_all_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].navigate_back_to_chat_view()
Expand All @@ -294,12 +295,12 @@ def test_group_chat_offline_pn(self):

self.homes[0].just_fyi("Put admin device to offline and send messages from members")
app_package = self.drivers[0].current_package
self.homes[0].toggle_airplane_mode()
self.homes[0].driver.set_network_connection(ConnectionType.AIRPLANE_MODE)
self.chats[1].send_message(message_1)
self.chats[2].send_message(message_2)

self.homes[0].just_fyi("Put admin device to online and check that messages and PNs will be fetched")
self.homes[0].toggle_airplane_mode()
self.homes[0].driver.set_network_connection(ConnectionType.ALL_NETWORK_ON)
self.homes[0].connection_offline_icon.wait_for_invisibility_of_element(60)
self.homes[0].open_notification_bar()
for message in (message_1, message_2):
Expand Down Expand Up @@ -459,7 +460,8 @@ def test_group_chat_mute_chat(self):
if self.homes[1].element_starts_with_text("Muted until").is_element_displayed():
self.errors.append("Chat is still muted after timeout")
self.errors.verify_no_errors()
self.homes[1].click_system_back_button()
if self.homes[1].mute_chat_button.is_element_displayed():
self.homes[1].click_system_back_button()

unmuted_message = "Chat is unmuted now"
self.homes[2].just_fyi("Member 2 sends a message")
Expand Down
Loading

0 comments on commit 711e64b

Please sign in to comment.