fix for airplane mode

This commit is contained in:
Yevheniia Berdnyk 2023-07-14 18:08:04 +03:00
parent c0e4653129
commit 1d0186a12e
No known key found for this signature in database
GPG Key ID: 0642C73C66214825
11 changed files with 270 additions and 93 deletions

View File

@ -111,12 +111,15 @@
:style {:color colors/neutral-40}} (when timestamp (datetime/to-short-str timestamp))]]]
[rn/view {:style style/top-right-buttons}
[rn/touchable-opacity
{:active-opacity 1
:on-press #(share-image messages @index)
:style (merge style/close-container {:margin-right 12})}
{:active-opacity 1
:accessibility-label :share-image
:on-press #(share-image messages @index)
:style (merge style/close-container {:margin-right 12})}
[quo/icon :share {:size 20 :color colors/white}]]
[rn/touchable-opacity
{:active-opacity 1
:on-press #(rf/dispatch [:show-bottom-sheet {:content (fn [] [drawer messages @index])}])
:style style/close-container}
{:active-opacity 1
:accessibility-label :image-options
:on-press #(rf/dispatch [:show-bottom-sheet
{:content (fn [] [drawer messages @index])}])
:style style/close-container}
[quo/icon :options {:size 20 :color colors/white}]]]]))

View File

@ -312,7 +312,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 += "%s" % e.reason
test_suite_data.current_test.testruns[-1].error += str(e)
raise e

View File

@ -1098,7 +1098,7 @@ class TestOneToOneChatMultipleSharedDevicesNewUi(MultipleSharedDeviceTestCase):
messages = ['hello', '¿Cómo estás tu año?', 'ё, доброго вечерочка', '® æ ç ♥']
[self.chat_2.send_message(message) for message in messages]
for message in messages:
if not self.chat_1.chat_element_by_text(message).is_element_displayed():
if not self.chat_1.chat_element_by_text(message).is_element_displayed(10):
self.errors.append("Message with text '%s' was not received" % message)
self.chat_2.just_fyi("Checking updated member photo, timestamp and username on message")
@ -1206,6 +1206,67 @@ class TestOneToOneChatMultipleSharedDevicesNewUi(MultipleSharedDeviceTestCase):
self.errors.append("Message reaction is not shown for the sender")
self.errors.verify_no_errors()
@marks.testrail_id(703391)
def test_1_1_chat_send_image_save_and_share(self):
if not self.chat_2.chat_message_input.is_element_displayed():
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)
self.chat_1.just_fyi("Device 1 sends an image")
image_description = "test image"
self.chat_1.send_images_with_description(description=image_description, indexes=[2])
self.chat_2.just_fyi("Device 2 checks image message")
if not self.chat_2.chat_element_by_text(image_description).is_element_displayed(30):
self.chat_2.hide_keyboard_if_shown()
self.chat_2.chat_element_by_text(image_description).wait_for_visibility_of_element(30)
if not self.chat_2.chat_element_by_text(
image_description).image_in_message.is_element_image_similar_to_template('saucelabs_sauce_chat.png'):
self.errors.append("Not expected image is shown to the receiver.")
for chat in self.chat_1, self.chat_2:
chat.just_fyi("Open the image and share it")
if not chat.chat_element_by_text(image_description).image_in_message.is_element_displayed():
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()
try:
chat.wait_for_current_package_to_be('com.google.android.gm')
except TimeoutException:
self.errors.append(
"%s can't share an image via Gmail." % ("Sender" if chat is self.chat_1 else "Receiver"))
chat.click_system_back_button_until_element_is_shown(element="chat")
for chat in self.chat_1, self.chat_2:
chat.just_fyi("Open the image and save it")
device_name = "sender" if chat is self.chat_1 else "receiver"
chat.chat_element_by_text(image_description).image_in_message.click()
chat.view_image_options_button.click()
chat.save_image_icon_button.click()
toast_element = chat.toast_content_element
if toast_element.is_element_displayed():
toast_element_text = toast_element.text
if toast_element_text != chat.get_translation_by_key("photo-saved"):
self.errors.append(
"Shown message '%s' doesn't match expected '%s' after saving an image for %s." % (
toast_element_text, chat.get_translation_by_key("photo-saved"), device_name))
else:
self.errors.append("Message about saving a photo is not shown for %s." % device_name)
chat.click_system_back_button_until_element_is_shown(element="chat")
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()
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"))
chat.click_system_back_button()
self.errors.verify_no_errors()
@marks.testrail_id(702733)
def test_1_1_chat_text_message_delete_push_disappear(self):
if not self.chat_2.chat_message_input.is_element_displayed():
@ -1272,7 +1333,11 @@ class TestOneToOneChatMultipleSharedDevicesNewUi(MultipleSharedDeviceTestCase):
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')
[home.toggle_airplane_mode() for home in self.homes]
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.launch_app()
SignInView(home.driver).sign_in()
# Not implemented yet
# self.home_1.connection_offline_icon.wait_and_click(20)
@ -1285,6 +1350,9 @@ class TestOneToOneChatMultipleSharedDevicesNewUi(MultipleSharedDeviceTestCase):
message_1 = 'test message'
self.home_2.just_fyi('Device2 checks "Sending" status when sending message from offline')
if not self.chat_2.chat_message_input.is_element_displayed():
self.home_2.chats_tab.click()
self.home_2.get_chat(self.username_1).click()
self.chat_2.send_message(message_1)
status = self.chat_2.chat_element_by_text(message_1).status
if not (status == 'Sending' or status == 'Sent'):
@ -1293,8 +1361,9 @@ class TestOneToOneChatMultipleSharedDevicesNewUi(MultipleSharedDeviceTestCase):
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 "im.status.ethereum" not in home.driver.current_activity:
home.click_system_back_button_until_element_is_shown()
if not home.chats_tab.is_element_displayed() and not home.chat_floating_screen.is_element_displayed():
home.driver.launch_app()
SignInView(home.driver).sign_in()
home.chats_tab.click()
home.get_chat(self.username_2 if i == 0 else self.username_1).click()

View File

@ -1,6 +1,6 @@
import pytest
from _pytest.outcomes import Failed
from selenium.common.exceptions import NoSuchElementException
from selenium.common.exceptions import NoSuchElementException, TimeoutException
from tests import marks, run_in_parallel
from tests.base_test_case import MultipleSharedDeviceTestCase, create_shared_drivers
@ -278,7 +278,7 @@ class TestGroupChatMultipleDeviceMergedNewUI(MultipleSharedDeviceTestCase):
if username_shown != self.usernames[2]:
self.errors.append(
"Incorrect profile is opened from the list of reactions, username is %s but expected to be %s" % (
username_shown, self.usernames[2])
username_shown, self.usernames[2])
)
except NoSuchElementException:
self.errors.append("User profile was not opened from the list of reactions")
@ -341,6 +341,64 @@ class TestGroupChatMultipleDeviceMergedNewUI(MultipleSharedDeviceTestCase):
self.errors.verify_no_errors()
@marks.testrail_id(703297)
def test_group_chat_send_image_save_and_share(self):
[self.homes[i].click_system_back_button_until_element_is_shown() for i in range(3)]
for i in range(3):
self.homes[i].get_chat(self.chat_name).click()
self.chats[1].just_fyi("Member_1 sends an image")
image_description = "test image"
self.chats[1].send_images_with_description(description=image_description, indexes=[2])
self.chats[0].just_fyi("Admin checks image message")
self.chats[0].chat_element_by_text(image_description).wait_for_visibility_of_element(60)
if not self.chats[0].chat_element_by_text(
image_description).image_in_message.is_element_image_similar_to_template('saucelabs_sauce_chat.png'):
self.errors.append("Not expected image is shown to the admin.")
self.chats[2].just_fyi("Member_2 checks image message")
self.chats[2].chat_element_by_text(image_description).wait_for_visibility_of_element(60)
if not self.chats[2].chat_element_by_text(
image_description).image_in_message.is_element_image_similar_to_template('saucelabs_sauce_chat.png'):
self.errors.append("Not expected image is shown to the member_2.")
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()
try:
self.chats[0].wait_for_current_package_to_be('com.google.android.gm')
except TimeoutException:
self.errors.append("Admin can't share an image via Gmail.")
self.chats[0].click_system_back_button_until_element_is_shown(element="chat")
self.chats[1].click_system_back_button_until_element_is_shown()
self.chats[2].just_fyi("Member_2 opens the image and saves it")
self.chats[2].chat_element_by_text(image_description).image_in_message.click()
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
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:
self.errors.append("Message about saving a photo is not shown for member_2.")
self.chats[2].click_system_back_button_until_element_is_shown(element="chat")
self.chats[2].just_fyi("Member_2 checks that image was saved in gallery")
self.chats[2].show_images_button.click()
self.chats[2].allow_button.click_if_shown()
if not self.chats[2].get_image_by_index(0).is_element_image_similar_to_template("saucelabs_sauce_gallery.png"):
self.errors.append("Image is not saved to gallery for member_2.")
self.chats[2].click_system_back_button_until_element_is_shown(element="chat")
self.errors.verify_no_errors()
@marks.testrail_id(702808)
def test_group_chat_offline_pn(self):
self.homes[0].click_system_back_button_until_element_is_shown()

View File

@ -540,73 +540,6 @@ class TestCommunityMultipleDeviceMerged(MultipleSharedDeviceTestCase):
self.errors.append("Deleted for me message is deleted all channel members")
self.errors.verify_no_errors()
@marks.testrail_id(702859)
def test_community_one_image_send_reply(self):
self.home_1.just_fyi('Send image in 1-1 chat from Gallery')
image_description = 'description'
self.channel_1.send_images_with_description(image_description)
# self.channel_1.chat_element_by_text(image_description).image_in_message.click()
# self.channel_1.click_system_back_button_until_element_is_shown(element='chat')
# TODO: options for image are still WIP; add case with edit description of image and after 15901 fix
self.home_2.just_fyi('check image, description and options for receiver')
# self.channel_2.chat_element_by_text(image_description).image_in_message.click()
# self.home_1.just_fyi('save image')
# self.chat_1.save_image_button.click_until_presence_of_element(self.chat_1.show_images_button)
# self.chat_1.show_images_button.click_until_presence_of_element(self.chat_1.image_from_gallery_button)
# self.chat_1.image_from_gallery_button.click_until_presence_of_element(self.chat_1.recent_image_in_gallery)
# if not self.chat_1.recent_image_in_gallery.is_element_displayed():
# self.errors.append('Saved image is not shown in Recent')
# self.home_1.click_system_back_button(2)
# self.home_2.just_fyi('check share and save options on opened image')
# self.chat_2.image_message_in_chat.scroll_to_element(direction='up')
# self.chat_2.image_message_in_chat.click_until_presence_of_element(self.chat_2.share_image_icon_button)
# self.chat_2.share_image_icon_button.click()
# self.chat_2.share_via_messenger()
# if not self.chat_2.image_in_android_messenger.is_element_displayed():
# self.errors.append("Can't share image")
# self.chat_2.click_system_back_button_until_element_is_shown(element=self.chat_2.save_image_icon_button)
# self.chat_2.save_image_icon_button.click()
# self.chat_2.show_images_button.click()
# self.chat_2.allow_button.wait_and_click()
#
# if not self.chat_2.first_image_from_gallery.is_element_image_similar_to_template('saved.png'):
# self.errors.append("New picture was not saved!")
#
# self.channel_2.chat_element_by_text(image_description).image_in_message.save_new_screenshot_of_element('images_test.png')
self.channel_2.chat_element_by_text(image_description).wait_for_visibility_of_element(60)
if not self.channel_2.chat_element_by_text(
image_description).image_in_message.is_element_image_similar_to_template('image_sent_in_community.png'):
self.errors.append("Not expected image is shown to the receiver")
self.channel_2.just_fyi("Can reply to images")
self.channel_2.quote_message(image_description)
message_text = 'reply to image'
self.channel_2.chat_message_input.send_keys(message_text)
self.channel_2.send_message_button.click()
chat_element_1 = self.channel_1.chat_element_by_text(message_text)
if not chat_element_1.is_element_displayed(sec=60) or chat_element_1.replied_message_text != image_description:
self.errors.append('Reply message was not received by the sender')
self.channel_2.just_fyi("Set a reaction for the image message")
self.channel_2.set_reaction(message=image_description)
try:
self.channel_1.chat_element_by_text(image_description).emojis_below_message().wait_for_element_text(1)
except (Failed, NoSuchElementException):
self.errors.append("Image message reaction is not shown for the sender")
self.channel_1.just_fyi("Set a reaction for the message reply")
self.channel_2.set_reaction(message=image_description, emoji="love")
try:
self.channel_2.chat_element_by_text(message_text).emojis_below_message(
emoji="love").wait_for_element_text(1)
except (Failed, NoSuchElementException):
self.errors.append("Reply message reaction is not shown for the reply sender")
self.errors.verify_no_errors()
@marks.testrail_id(703194)
def test_community_several_images_send_reply(self):
self.home_1.just_fyi('Send several images in 1-1 chat from Gallery')
@ -627,6 +560,19 @@ class TestCommunityMultipleDeviceMerged(MultipleSharedDeviceTestCase):
received = False
if received:
self.channel_2.just_fyi("Checking an ability to save and share an image from gallery")
chat_element.image_container_in_message.image_by_index(1).click()
if not self.channel_2.share_image_icon_button.is_element_displayed():
self.errors.append("Can't share an image from gallery.")
if self.channel_2.view_image_options_button.is_element_displayed():
self.channel_2.view_image_options_button.click()
if not self.channel_2.save_image_icon_button.is_element_displayed():
self.errors.append("Can't save an image from gallery.")
else:
self.errors.append("Image options button is not shown for an image from gallery.")
self.channel_2.click_system_back_button_until_element_is_shown(element="chat")
self.channel_2.just_fyi("Can reply to gallery")
self.channel_2.quote_message(image_description)
message_text = 'reply to gallery'
@ -638,6 +584,79 @@ class TestCommunityMultipleDeviceMerged(MultipleSharedDeviceTestCase):
self.errors.append('Reply message was not received by the sender')
self.errors.verify_no_errors()
@marks.testrail_id(702859)
def test_community_one_image_send_reply(self):
self.home_1.just_fyi('Send image in 1-1 chat from Gallery')
image_description = 'description'
self.channel_1.send_images_with_description(image_description)
self.home_2.just_fyi('Check image, description and options for receiver')
if not self.channel_2.chat_element_by_text(image_description).is_element_displayed(60):
self.channel_2.hide_keyboard_if_shown()
self.channel_2.chat_element_by_text(image_description).wait_for_visibility_of_element(10)
if not self.channel_2.chat_element_by_text(
image_description).image_in_message.is_element_image_similar_to_template('image_sent_in_community.png'):
self.errors.append("Not expected image is shown to the receiver")
if not self.channel_1.chat_element_by_text(image_description).is_element_displayed(60):
self.channel_1.hide_keyboard_if_shown()
self.channel_1.chat_element_by_text(image_description).image_in_message.click()
self.home_1.just_fyi('Save image')
self.channel_1.view_image_options_button.click()
self.channel_1.save_image_icon_button.click()
toast_element = self.channel_1.toast_content_element
if toast_element.is_element_displayed():
toast_element_text = toast_element.text
if toast_element_text != self.channel_1.get_translation_by_key("photo-saved"):
self.errors.append(
"Shown message '%s' doesn't match expected '%s' after saving an image." % (
toast_element_text, self.channel_1.get_translation_by_key("photo-saved")))
else:
self.errors.append("Message about saving a photo is not shown.")
self.channel_1.click_system_back_button_until_element_is_shown(element="chat")
self.channel_1.just_fyi("Check that image is saved in gallery")
self.channel_1.show_images_button.click()
self.channel_1.allow_button.click_if_shown()
if not self.channel_1.get_image_by_index(0).is_element_image_similar_to_template(
"sauce_dark_image_gallery.png"):
self.errors.append('Saved image is not shown in Recent')
self.channel_1.click_system_back_button()
self.home_2.just_fyi('Check share option on opened image')
self.channel_2.chat_element_by_text(image_description).image_in_message.click()
self.channel_2.share_image_icon_button.click()
self.channel_2.element_starts_with_text("Gmail").click()
try:
self.channel_2.wait_for_current_package_to_be('com.google.android.gm')
except TimeoutException:
self.errors.append("Can't share image")
self.channel_2.click_system_back_button_until_element_is_shown(element="chat")
self.channel_2.just_fyi("Can reply to images")
self.channel_2.quote_message(image_description)
message_text = 'reply to image'
self.channel_2.chat_message_input.send_keys(message_text)
self.channel_2.send_message_button.click()
chat_element_1 = self.channel_1.chat_element_by_text(message_text)
if not chat_element_1.is_element_displayed(sec=60) or chat_element_1.replied_message_text != image_description:
self.errors.append('Reply message was not received by the sender')
self.channel_2.just_fyi("Set a reaction for the image message")
self.channel_2.set_reaction(message=image_description)
try:
self.channel_1.chat_element_by_text(image_description).emojis_below_message().wait_for_element_text(1)
except (Failed, NoSuchElementException):
self.errors.append("Image message reaction is not shown for the sender")
self.channel_1.just_fyi("Set a reaction for the message reply")
self.channel_2.set_reaction(message=image_description, emoji="love")
try:
self.channel_2.chat_element_by_text(message_text).emojis_below_message(
emoji="love").wait_for_element_text(1)
except (Failed, NoSuchElementException):
self.errors.append("Reply message reaction is not shown for the reply sender")
self.errors.verify_no_errors()
@marks.testrail_id(702840)
def test_community_emoji_send_copy_paste_reply(self):
emoji_name = random.choice(list(emoji.EMOJI_UNICODE))
@ -703,6 +722,10 @@ class TestCommunityMultipleDeviceMerged(MultipleSharedDeviceTestCase):
# 'subtitle': 'Twitter'
# }
}
for home in self.home_1, self.home_2:
if not home.chat_floating_screen.is_element_displayed():
home.click_system_back_button_until_element_is_shown()
home.get_to_community_channel_from_home(self.community_name)
for key, data in preview_urls.items():
self.home_2.just_fyi("Checking %s preview case" % key)
@ -731,6 +754,9 @@ class TestCommunityMultipleDeviceMerged(MultipleSharedDeviceTestCase):
self.channel_1.just_fyi("Set reaction and check it")
message_with_reaction = list(preview_urls.values())[-1]['url']
self.channel_1.set_reaction(message=message_with_reaction, emoji="laugh")
if not self.channel_2.chat_element_by_text(message_with_reaction).emojis_below_message(
emoji="laugh").is_element_displayed(10):
self.channel_2.hide_keyboard_if_shown()
try:
self.channel_2.chat_element_by_text(message_with_reaction).emojis_below_message(
emoji="laugh").wait_for_element_text(1)
@ -743,6 +769,9 @@ class TestCommunityMultipleDeviceMerged(MultipleSharedDeviceTestCase):
def test_community_unread_messages_badge(self):
self.channel_1.jump_to_communities_home()
message = 'test message'
if not self.home_2.chat_floating_screen.is_element_displayed():
self.home_2.jump_to_communities_home()
self.home_2.get_to_community_channel_from_home(self.community_name)
self.channel_2.send_message(message)
self.home_1.just_fyi('Check new messages badge is shown for community')
community_element_1 = self.home_1.get_chat(self.community_name, community=True)
@ -817,6 +846,7 @@ class TestCommunityMultipleDeviceMerged(MultipleSharedDeviceTestCase):
self.home_2.just_fyi("Check that can send message in community after unblock")
self.chat_2.send_message(message_unblocked)
self.home_1.jump_to_card_by_text('# %s' % self.channel_name)
self.chat_1.hide_keyboard_if_shown()
if not self.chat_1.chat_element_by_text(message_unblocked).is_element_displayed(120):
self.errors.append("%s was not received in public chat after user unblock!" % message_unblocked)
self.errors.verify_no_errors()
@ -967,6 +997,6 @@ class TestCommunityMultipleDeviceMerged(MultipleSharedDeviceTestCase):
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 community.is_element_displayed():
if not community.is_element_disappeared():
self.errors.append('Community is still shown in the list after leave')
self.errors.verify_no_errors()

View File

@ -1,11 +1,11 @@
import time
import base64
import random
import re
import string
from appium.webdriver.common.touch_action import TouchAction
import time
from datetime import datetime
from appium.webdriver.common.touch_action import TouchAction
from selenium.common.exceptions import NoSuchElementException, TimeoutException
from support.device_apps import start_web_browser
@ -130,7 +130,7 @@ class WalletButton(TabButton):
class ProfileButton(TabButton):
def __init__(self, driver):
super().__init__(driver, accessibility_id="open-profile")
super().__init__(driver, accessibility_id="open-profile")
def navigate(self):
from views.profile_view import ProfileView
@ -255,7 +255,8 @@ class BaseView(object):
# Floating screens (introduced by https://github.com/status-im/status-mobile/pull/16438)
self.chat_floating_screen = BaseElement(self.driver, accessibility_id=":chat-floating-screen")
self.community_floating_screen = BaseElement(self.driver, accessibility_id=":community-overview-floating-screen")
self.community_floating_screen = BaseElement(self.driver,
accessibility_id=":community-overview-floating-screen")
self.jump_to_button = Button(self.driver, accessibility_id="jump-to")
@ -291,6 +292,7 @@ class BaseView(object):
self.share_button = Button(self.driver, accessibility_id="share-my-contact-code-button")
self.qr_code_image = Button(self.driver, accessibility_id="qr-code-image")
self.sign_in_phrase = SignInPhraseText(self.driver)
self.toast_content_element = BaseElement(self.driver, accessibility_id="toast-content")
# checkboxes and toggles
self.checkbox_button = CheckBox(self.driver, accessibility_id="checkbox-off")
@ -303,7 +305,6 @@ class BaseView(object):
self.airplane_mode_button = AirplaneModeButton(self.driver)
self.enter_qr_edit_box = EnterQRcodeEditBox(self.driver)
self.element_types = {
'base': BaseElement,
'button': Button,
@ -782,3 +783,12 @@ class BaseView(object):
string_source = self.driver.page_source
source = open(full_path_to_file, "a+")
source.write(string_source)
def wait_for_current_package_to_be(self, expected_package_name: str, timeout: int = 10):
start_time = time.time()
while time.time() - start_time <= timeout:
package = self.driver.current_package
if package == expected_package_name:
return
time.sleep(1)
raise TimeoutException("Driver current package is '%s' after %s seconds" % (package, timeout))

View File

@ -4,7 +4,6 @@ from datetime import datetime, timedelta
from time import sleep
import dateutil.parser
from appium.webdriver.common.mobileby import MobileBy
from appium.webdriver.common.touch_action import TouchAction
from selenium.common.exceptions import NoSuchElementException, TimeoutException
@ -284,13 +283,20 @@ class ChatElementByText(Text):
except NoSuchElementException:
self.driver.fail("No image is found in message!")
class ImageContainer(Button):
def __init__(self, driver, parent_locator):
super().__init__(driver, xpath='%s//*[@content-desc="image-container"]' % parent_locator)
def image_by_index(self, index: int):
return BaseElement(self.driver, xpath="(%s//android.widget.ImageView)[%s]" % (self.locator, index))
@property
def image_container_in_message(self):
try:
self.driver.info(
"Trying to access images (image container) inside message with text '%s'" % self.message_text)
ChatElementByText(self.driver, self.message_text).wait_for_sent_state(60)
return Button(self.driver, xpath='%s//*[@content-desc="image-container"]' % self.locator)
return self.ImageContainer(self.driver, self.locator)
except NoSuchElementException:
self.driver.fail("No image container is found in message!")
@ -773,10 +779,9 @@ class ChatView(BaseView):
self.recent_image_in_gallery = Button(self.driver,
xpath="//*[contains(@resource-id,'thumbnail')]")
self.cancel_send_image_button = Button(self.driver, accessibility_id="cancel-send-image")
self.view_image_options = Button(self.driver,
xpath="//*[@content-desc='icon']/android.widget.ImageView")
self.share_image_icon_button = Button(self.driver, accessibility_id="share-button")
self.save_image_icon_button = Button(self.driver, accessibility_id="save-button")
self.share_image_icon_button = Button(self.driver, accessibility_id="share-image")
self.view_image_options_button = Button(self.driver, accessibility_id="image-options")
self.save_image_icon_button = Button(self.driver, accessibility_id="save-image")
self.image_in_android_messenger = Button(self.driver, accessibility_id="Image")
# Audio

Binary file not shown.

After

Width:  |  Height:  |  Size: 64 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 250 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 96 KiB

View File

@ -332,6 +332,8 @@ class HomeView(BaseView):
return chat_element
def handle_contact_request(self, username: str, action='accept'):
if self.toast_content_element.is_element_displayed(10):
self.toast_content_element.wait_for_invisibility_of_element()
if self.notifications_unread_badge.is_element_displayed(30):
self.open_activity_center_button.click()
chat_element = ActivityCenterElement(self.driver, username[:25])