paste from clipboard fix

This commit is contained in:
Yevheniia Berdnyk 2023-02-28 14:44:13 +02:00
parent fa03e91080
commit c2782a26f7
No known key found for this signature in database
GPG Key ID: 0642C73C66214825
2 changed files with 46 additions and 51 deletions

View File

@ -1,18 +1,15 @@
import random import random
import time
from datetime import timedelta from datetime import timedelta
import emoji import emoji
import pytest import pytest
from dateutil import parser from dateutil import parser
from selenium.common.exceptions import NoSuchElementException
from tests import marks, test_dapp_name, test_dapp_url, run_in_parallel from tests import marks, test_dapp_name, test_dapp_url, run_in_parallel
from tests.base_test_case import create_shared_drivers, MultipleSharedDeviceTestCase from tests.base_test_case import create_shared_drivers, MultipleSharedDeviceTestCase
from views.sign_in_view import SignInView
from views.chat_view import CommunityView from views.chat_view import CommunityView
from views.base_view import BaseView from views.sign_in_view import SignInView
from views.chat_view import ChatView
from selenium.common.exceptions import NoSuchElementException
@pytest.mark.xdist_group(name="three_1") @pytest.mark.xdist_group(name="three_1")
@ -313,7 +310,8 @@ class TestCommunityOneDeviceMerged(MultipleSharedDeviceTestCase):
self.home.communities_tab.click_until_presence_of_element(self.home.plus_button) self.home.communities_tab.click_until_presence_of_element(self.home.plus_button)
self.community_name = self.home.get_random_chat_name() self.community_name = self.home.get_random_chat_name()
self.channel_name = self.home.get_random_chat_name() self.channel_name = self.home.get_random_chat_name()
self.community = self.home.create_community(name=self.community_name, description='test description', require_approval=False) self.community = self.home.create_community(name=self.community_name, description='test description',
require_approval=False)
self.channel = self.community.add_channel(name=self.channel_name) self.channel = self.community.add_channel(name=self.channel_name)
@marks.testrail_id(702846) @marks.testrail_id(702846)
@ -328,39 +326,27 @@ class TestCommunityOneDeviceMerged(MultipleSharedDeviceTestCase):
if not self.channel.chat_element_by_text(text_message).is_element_displayed(30): if not self.channel.chat_element_by_text(text_message).is_element_displayed(30):
self.drivers[0].fail("Not navigated to channel view after reopening app") self.drivers[0].fail("Not navigated to channel view after reopening app")
# @marks.testrail_id(702847) @marks.testrail_id(702742)
# # TODO long press and assertion of text in input field is currently not working on e2e builds. needs to be investigated def test_community_copy_and_paste_message_in_chat_input(self):
# @marks.skip('needs to be refactored') message_texts = ['mmmeowesage_text', 'https://status.im']
# def test_community_copy_and_paste_message_in_chat_input(self):
# message_text = {'text_message': 'mmmeowesage_text'} message_input = self.channel.chat_message_input
# formatted_message = {'message_with_link': 'https://status.im' if not message_input.is_element_displayed():
# } self.home.communities_tab.double_click()
# message_input = self.channel.chat_message_input self.home.get_chat(self.community_name, community=True).click()
# if not message_input.is_element_displayed(): self.community.get_chat(self.channel_name).click()
# self.home.communities_tab.double_click()
# self.home.get_chat(self.community_name, community=True).click() for message in message_texts:
# self.community.get_chat(self.channel_name).click() message_input.send_keys(message)
# message_input.send_keys(message_text['text_message']) self.channel.send_message_button.click()
# self.channel.send_message_button.click()
# self.channel.copy_message_text(message)
# self.channel.copy_message_text(message_text['text_message']) message_input.paste_text_from_clipboard()
# if message_input.text != message:
# message_input.paste_text_from_clipboard() self.errors.append('Message %s text was not copied in community channel' % message)
# if message_input.text != message_text['text_message']: message_input.clear()
# self.errors.append('Message %s text was not copied in a public chat' % message_text['text_message'])
# message_input.clear() self.errors.verify_no_errors()
#
# for message in formatted_message:
# message_input.send_keys(formatted_message[message])
# self.channel.send_message_button.click()
#
# self.channel.copy_message_text(formatted_message[message])
# message_input.paste_text_from_clipboard()
# if message_input.text != formatted_message[message]:
# self.errors.append('Message %s text was not copied in community channel' % formatted_message[message])
# message_input.clear()
#
# self.errors.verify_no_errors()
@pytest.mark.xdist_group(name="two_2") @pytest.mark.xdist_group(name="two_2")
@ -403,7 +389,6 @@ class TestCommunityMultipleDeviceMerged(MultipleSharedDeviceTestCase):
community_view.get_channel(self.channel_name).click() community_view.get_channel(self.channel_name).click()
self.channel_2 = self.home_2.get_chat_view() self.channel_2 = self.home_2.get_chat_view()
@marks.testrail_id(702838) @marks.testrail_id(702838)
@marks.xfail(reason="blocked by 14797") @marks.xfail(reason="blocked by 14797")
def test_community_message_send_check_timestamps_sender_username(self): def test_community_message_send_check_timestamps_sender_username(self):
@ -443,7 +428,8 @@ class TestCommunityMultipleDeviceMerged(MultipleSharedDeviceTestCase):
if not self.channel_2.element_by_translation_id('message-deleted-for-everyone').is_element_displayed(30): 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.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.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) self.channel_2.send_message(message_to_delete_for_me)
self.channel_2.delete_message_in_chat(message_to_delete_for_me, everyone=False) self.channel_2.delete_message_in_chat(message_to_delete_for_me, everyone=False)
if not self.channel_2.chat_element_by_text(message_to_delete_for_me).is_element_disappeared(30): if not self.channel_2.chat_element_by_text(message_to_delete_for_me).is_element_disappeared(30):
@ -464,13 +450,11 @@ class TestCommunityMultipleDeviceMerged(MultipleSharedDeviceTestCase):
if not channel.chat_element_by_text(emoji_unicode).is_element_displayed(30): if not channel.chat_element_by_text(emoji_unicode).is_element_displayed(30):
self.errors.append('Message with emoji was not sent or received in community channel') self.errors.append('Message with emoji was not sent or received in community channel')
# Commented as paste_text_from_clipboard() method doesn't work any more for some reason. Needs to be investigated self.channel_1.just_fyi("Can copy and paste emojis")
# self.channel_1.just_fyi("Can copy and paste emojis") self.channel_1.copy_message_text(emoji_unicode)
# self.channel_1.copy_message_text(emoji_unicode) self.channel_1.chat_message_input.paste_text_from_clipboard()
# self.channel_1.chat_message_input.click() if self.channel_1.chat_message_input.text != emoji_unicode:
# self.channel_1.chat_message_input.paste_text_from_clipboard() self.errors.append('Emoji message was not copied')
# if self.channel_1.chat_message_input.text != emoji_unicode:
# self.errors.append('Emoji message was not copied')
self.channel_1.just_fyi("Can reply to emojis") self.channel_1.just_fyi("Can reply to emojis")
self.channel_2.quote_message(emoji_unicode) self.channel_2.quote_message(emoji_unicode)
@ -587,4 +571,3 @@ class TestCommunityMultipleDeviceMerged(MultipleSharedDeviceTestCase):
if community.is_element_displayed(): if community.is_element_displayed():
self.errors.append('Community is still shown in the list after leave') self.errors.append('Community is still shown in the list after leave')
self.errors.verify_no_errors() self.errors.verify_no_errors()

View File

@ -4,6 +4,7 @@ from datetime import datetime, timedelta
from time import sleep from time import sleep
import dateutil.parser import dateutil.parser
from appium.webdriver.common.touch_action import TouchAction
from selenium.common.exceptions import NoSuchElementException, TimeoutException from selenium.common.exceptions import NoSuchElementException, TimeoutException
from tests import emojis from tests import emojis
@ -629,6 +630,18 @@ class PinnedMessagesList(BaseElement):
return pinned_by_element return pinned_by_element
class ChatMessageInput(EditBox):
def __init__(self, driver):
super().__init__(driver, accessibility_id="chat-message-input")
def paste_text_from_clipboard(self):
action = TouchAction(self.driver)
location = self.find_element().location
x, y = location['x'], location['y']
action.long_press(x=x + 250, y=y).release().perform() # long press
action.tap(x=x + 50, y=y - 50).release().perform() # tap Paste
class ChatView(BaseView): class ChatView(BaseView):
def __init__(self, driver): def __init__(self, driver):
super().__init__(driver) super().__init__(driver)
@ -657,7 +670,7 @@ class ChatView(BaseView):
xpath="//androidx.appcompat.widget.LinearLayoutCompat") xpath="//androidx.appcompat.widget.LinearLayoutCompat")
# Chat input # Chat input
self.chat_message_input = EditBox(self.driver, accessibility_id="chat-message-input") self.chat_message_input = ChatMessageInput(self.driver)
self.cancel_reply_button = Button(self.driver, accessibility_id="reply-cancel-button") self.cancel_reply_button = Button(self.driver, accessibility_id="reply-cancel-button")
self.quote_username_in_message_input = EditBox(self.driver, self.quote_username_in_message_input = EditBox(self.driver,
xpath="//*[@content-desc='reply-cancel-button']/preceding::android.widget.TextView[2]") xpath="//*[@content-desc='reply-cancel-button']/preceding::android.widget.TextView[2]")
@ -774,7 +787,6 @@ class ChatView(BaseView):
self.pin_limit_popover = BaseElement(self.driver, translation_id="pin-limit-reached") self.pin_limit_popover = BaseElement(self.driver, translation_id="pin-limit-reached")
self.view_pinned_messages_button = Button(self.driver, accessibility_id="pinned-banner") self.view_pinned_messages_button = Button(self.driver, accessibility_id="pinned-banner")
def get_outgoing_transaction(self, account=None, transaction_value=None) -> object: def get_outgoing_transaction(self, account=None, transaction_value=None) -> object:
if account is None: if account is None:
account = self.status_account_name account = self.status_account_name