From 7613e642ff4e6d8724bc672fd9e1560908e9954d Mon Sep 17 00:00:00 2001 From: yevh-berdnyk Date: Sat, 6 Oct 2018 15:00:30 +0300 Subject: [PATCH] Fixed username verification in public chat, added StaleElementReferenceException to rerun errors Signed-off-by: yevh-berdnyk --- test/appium/support/test_rerun.py | 5 +++-- test/appium/tests/atomic/chats/test_public.py | 11 +++++++---- test/appium/views/profile_view.py | 16 ++++++++++++---- 3 files changed, 22 insertions(+), 10 deletions(-) diff --git a/test/appium/support/test_rerun.py b/test/appium/support/test_rerun.py index dec1c79bc3..3999842d3c 100644 --- a/test/appium/support/test_rerun.py +++ b/test/appium/support/test_rerun.py @@ -18,8 +18,9 @@ RERUN_ERRORS = [ "Sauce could not start your job", "HTTP Error 303", "http.client.RemoteDisconnected: Remote end closed connection without response", - "[Errno 110] Connection timed out" - "replacement transaction underpriced" + "[Errno 110] Connection timed out", + "replacement transaction underpriced", + "StaleElementReferenceException" ] diff --git a/test/appium/tests/atomic/chats/test_public.py b/test/appium/tests/atomic/chats/test_public.py index a07df3c7e3..2c6184bc86 100644 --- a/test/appium/tests/atomic/chats/test_public.py +++ b/test/appium/tests/atomic/chats/test_public.py @@ -1,4 +1,3 @@ -import pytest from tests import marks from tests.base_test_case import MultipleDeviceTestCase, SingleDeviceTestCase from views.sign_in_view import SignInView @@ -14,6 +13,9 @@ class TestPublicChatMultipleDevice(MultipleDeviceTestCase): device_1, device_2 = SignInView(self.drivers[0]), SignInView(self.drivers[1]) username_1, username_2 = 'user_1', 'user_2' home_1, home_2 = device_1.create_user(username=username_1), device_2.create_user(username=username_2) + profile_1 = home_1.profile_button.click() + default_username_1 = profile_1.default_username_text.text + profile_1.home_button.click() public_key_2 = home_2.get_public_key() home_2.home_button.click() @@ -28,10 +30,11 @@ class TestPublicChatMultipleDevice(MultipleDeviceTestCase): chat_1.send_message_button.click() chat_2.verify_message_is_under_today_text(message, self.errors) - if chat_2.chat_element_by_text(message).username.text != username_1: - self.errors.append("Username '%s' is not shown next to the received message" % username_1) + full_username = '%s :: %s' % (username_1, default_username_1) + if chat_2.chat_element_by_text(message).username.text != full_username: + self.errors.append("Username '%s' is not shown next to the received message" % full_username) - if chat_1.element_by_text(username_1).is_element_displayed(): + if chat_1.element_by_text_part(username_1).is_element_displayed(): self.errors.append("Username '%s' is shown for the sender" % username_1) self.verify_no_errors() diff --git a/test/appium/views/profile_view.py b/test/appium/views/profile_view.py index a0c83a5bbc..7e83c03272 100644 --- a/test/appium/views/profile_view.py +++ b/test/appium/views/profile_view.py @@ -101,11 +101,18 @@ class ConfirmLogoutButton(BaseButton): self.locator = self.Locator.text_selector('LOG OUT') -class UserNameText(BaseText): +class UserNameSetByUserText(BaseText): def __init__(self, driver): - super(UserNameText, self).__init__(driver) + super(UserNameSetByUserText, self).__init__(driver) self.locator = self.Locator.xpath_selector( - '//android.widget.ImageView[@content-desc="chat-icon"]/../../android.widget.TextView') + '//android.widget.ImageView[@content-desc="chat-icon"]/../../android.widget.TextView[1]') + + +class DefaultUserNameText(BaseText): + def __init__(self, driver): + super(DefaultUserNameText, self).__init__(driver) + self.locator = self.Locator.xpath_selector( + '//android.widget.ImageView[@content-desc="chat-icon"]/../../android.widget.TextView[2]') class ShareMyProfileButton(BaseButton): @@ -417,7 +424,8 @@ class ProfileView(BaseView): self.main_currency_button = MainCurrencyButton(self.driver) - self.username_text = UserNameText(self.driver) + self.username_set_by_user_text = UserNameSetByUserText(self.driver) + self.default_username_text = DefaultUserNameText(self.driver) self.share_my_profile_button = ShareMyProfileButton(self.driver) self.edit_button = EditButton(self.driver) self.profile_picture = ProfilePictureElement(self.driver)