From b7f675aa5cc0308d3c041663cfd3cab2abc3460a Mon Sep 17 00:00:00 2001 From: Yevheniia Berdnyk Date: Wed, 29 Nov 2023 18:03:07 +0200 Subject: [PATCH] e2e: fix for deep links test --- .../tests/critical/test_deep_and_universal_links.py | 11 ++++++----- test/appium/views/base_view.py | 6 ++++-- 2 files changed, 10 insertions(+), 7 deletions(-) diff --git a/test/appium/tests/critical/test_deep_and_universal_links.py b/test/appium/tests/critical/test_deep_and_universal_links.py index dacb43f189..f6be00812a 100644 --- a/test/appium/tests/critical/test_deep_and_universal_links.py +++ b/test/appium/tests/critical/test_deep_and_universal_links.py @@ -68,7 +68,8 @@ class TestDeepLinksOneDevice(MultipleSharedDeviceTestCase): for link, text in profile_links.items(): self.browser_view.open_url(link) if text: - name_is_shown = self.profile_view.default_username_text.text == text + name_is_shown = self.profile_view.default_username_text.text == text \ + or self.profile_view.default_username_text.text.endswith(link[-6:]) else: name_is_shown = self.profile_view.default_username_text.text.endswith(link[-6:]) if not self.channel.profile_add_to_contacts_button.is_element_displayed(10) or not name_is_shown: @@ -92,19 +93,19 @@ class TestDeepLinksOneDevice(MultipleSharedDeviceTestCase): @marks.testrail_id(704614) def test_links_open_universal_links_from_other_apps(self): + app_package = self.driver.current_package self.home.just_fyi("Opening a profile URL from google search bar when user is still logged in") profile_url = "https://status.app/u#zQ3shVVxZMwLVEQvuu1KF6h4D2mzVyCC4F4mHLZm5dz5XU1aa" self.home.click_system_home_button() - self.home.open_link_from_google_search_app(profile_url) + self.home.open_link_from_google_search_app(profile_url, app_package) if not self.channel.profile_add_to_contacts_button.is_element_displayed( 10) or not self.profile_view.default_username_text.text.endswith(profile_url[-6:]): self.errors.append("Profile was not opened by the url %s when user is logged in" % profile_url) self.home.just_fyi("Opening a community URL from google search bar when user is logged out") - app_package = self.driver.current_package self.driver.terminate_app(app_package) community_url = "https://status.app/c/Ow==#zQ3shbmfT3hvh4mKa1v6uAjjyztQEroh8Mfn6Ckegjd7LT3XK" - self.home.open_link_from_google_search_app(community_url) + self.home.open_link_from_google_search_app(community_url, app_package) self.sign_in.sign_in() if not self.home.element_by_translation_id( "community-admins-will-review-your-request").is_element_displayed(10): @@ -114,7 +115,7 @@ class TestDeepLinksOneDevice(MultipleSharedDeviceTestCase): self.driver.reset() self.home.click_system_home_button() channel_url = "https://status.app/cc/Ow==#zQ3shbmfT3hvh4mKa1v6uAjjyztQEroh8Mfn6Ckegjd7LT3XK" - self.home.open_link_from_google_search_app(channel_url) + self.home.open_link_from_google_search_app(channel_url, app_package) self.sign_in.create_user() if not self.home.element_by_translation_id( "community-admins-will-review-your-request").is_element_displayed(10): diff --git a/test/appium/views/base_view.py b/test/appium/views/base_view.py index 10cfdfc3f5..8008145c6a 100644 --- a/test/appium/views/base_view.py +++ b/test/appium/views/base_view.py @@ -842,9 +842,11 @@ class BaseView(object): raise TimeoutException( "Device %s: expected element is not stale after %s seconds" % (self.driver.number, seconds)) from None - def open_link_from_google_search_app(self, link_text: str): + def open_link_from_google_search_app(self, link_text: str, app_package: str): Button(self.driver, xpath="//*[contains(@resource-id,'search_container_all_apps')]").click() EditBox(self.driver, xpath="//android.widget.EditText").send_keys(link_text) self.driver.press_keycode(66) - Button(self.driver, xpath="//*[@resource-id='android:id/resolver_list']//*[@text='Status']").click_if_shown() + text_to_click = "Status PR" if app_package.endswith(".pr") else "Status" + Button(self.driver, + xpath="//*[@resource-id='android:id/resolver_list']//*[@text='%s']" % text_to_click).click_if_shown() Button(self.driver, xpath="//*[@resource-id='android:id/button_once']").click()