Test opening app from deep links

Signed-off-by: Serhy <sergii@status.im>
This commit is contained in:
Serhy 2019-04-02 18:16:08 +03:00
parent 38fc712f07
commit 25c24bf716
No known key found for this signature in database
GPG Key ID: 5D7C4B9E2B6F500B
3 changed files with 89 additions and 8 deletions

View File

@ -1,10 +1,10 @@
import pytest import pytest
from selenium.common.exceptions import NoSuchElementException from selenium.common.exceptions import NoSuchElementException
from support.device_apps import start_web_browser
from tests import marks from tests import marks
from tests.base_test_case import SingleDeviceTestCase from tests.base_test_case import SingleDeviceTestCase
from views.sign_in_view import SignInView from views.sign_in_view import SignInView
from tests.users import basic_user
class TestDeepLinks(SingleDeviceTestCase): class TestDeepLinks(SingleDeviceTestCase):
@ -15,16 +15,69 @@ class TestDeepLinks(SingleDeviceTestCase):
sign_in_view = SignInView(self.driver) sign_in_view = SignInView(self.driver)
sign_in_view.create_user() sign_in_view.create_user()
self.driver.close_app() self.driver.close_app()
start_web_browser(self.driver)
chat_name = sign_in_view.get_public_chat_name() chat_name = sign_in_view.get_public_chat_name()
sign_in_view.send_as_keyevent('https://get.status.im/chat/public/%s' % chat_name) deep_link = 'https://get.status.im/chat/public/%s' % chat_name
sign_in_view.confirm() sign_in_view.open_weblink_and_login(deep_link)
open_button = sign_in_view.element_by_xpath('//*[@text="Open in Status"] | //*[@content-desc="Open in Status"]')
open_button.wait_for_visibility_of_element()
open_button.click()
sign_in_view.sign_in()
chat_view = sign_in_view.get_chat_view() chat_view = sign_in_view.get_chat_view()
try: try:
assert chat_view.user_name_text.text == '#' + chat_name assert chat_view.user_name_text.text == '#' + chat_name
except (AssertionError, NoSuchElementException): except (AssertionError, NoSuchElementException):
pytest.fail("Public chat '%s' is not opened" % chat_name) pytest.fail("Public chat '%s' is not opened" % chat_name)
@marks.testrail_id(5441)
@marks.medium
def test_open_user_profile_using_deep_link(self):
sign_in_view = SignInView(self.driver)
sign_in_view.create_user()
self.driver.close_app()
deep_link = 'https://get.status.im/user/%s' % basic_user['public_key']
sign_in_view.open_weblink_and_login(deep_link)
chat_view = sign_in_view.get_chat_view()
for text in basic_user['username'], 'Add to contacts', 'Send transaction':
if not chat_view.element_by_text(text).scroll_to_element():
pytest.fail("User profile screen is not opened")
@marks.testrail_id(5442)
@marks.medium
def test_open_dapp_using_deep_link(self):
sign_in_view = SignInView(self.driver)
sign_in_view.create_user()
self.driver.close_app()
dapp_name = 'simpledapp.eth'
dapp_deep_link = 'https://get.status.im/browse/%s' % dapp_name
sign_in_view.open_weblink_and_login(dapp_deep_link)
web_view = sign_in_view.get_chat_view()
try:
test_dapp_view = web_view.open_in_status_button.click()
test_dapp_view.allow_button.is_element_present()
except NoSuchElementException:
pytest.fail("DApp '%s' is not opened!" % dapp_name)
@marks.testrail_id(5780)
@marks.medium
def test_open_own_user_profile_using_deep_link(self):
sign_in_view = SignInView(self.driver)
sign_in_view.recover_access(passphrase=basic_user['passphrase'])
self.driver.close_app()
deep_link = 'https://get.status.im/user/%s' % basic_user['public_key']
sign_in_view.open_weblink_and_login(deep_link)
chat_view = sign_in_view.get_chat_view()
for text in basic_user['username'], 'Share my profile', 'Contacts':
if not chat_view.element_by_text(text).scroll_to_element():
pytest.fail("Own profile screen is not opened!")
@marks.testrail_id(5781)
@marks.medium
def test_deep_link_with_invalid_user_public_key(self):
sign_in_view = SignInView(self.driver)
sign_in_view.create_user()
self.driver.close_app()
deep_link = 'https://get.status.im/user/%s' % basic_user['public_key'][:-10]
sign_in_view.open_weblink_and_login(deep_link)
chat_view = sign_in_view.get_home_view()
start_new_chat_view = chat_view.plus_button.click()
try:
assert start_new_chat_view.start_new_chat_button.is_element_present()
except (AssertionError, NoSuchElementException):
pytest.fail("Can't navigate to start new chat after app opened from deep link with invalid public key")

View File

@ -12,6 +12,7 @@ from PIL import Image
from datetime import datetime from datetime import datetime
from io import BytesIO from io import BytesIO
from views.base_element import BaseButton, BaseElement, BaseEditBox, BaseText from views.base_element import BaseButton, BaseElement, BaseEditBox, BaseText
from support.device_apps import start_web_browser
class BackButton(BaseButton): class BackButton(BaseButton):
@ -282,6 +283,20 @@ class AssetButton(BaseButton):
self.driver.info('Tap on %s' % self.name) self.driver.info('Tap on %s' % self.name)
class OpenInStatusButton(BaseButton):
def __init__(self, driver):
super(OpenInStatusButton, self).__init__(driver)
self.locator = self.Locator.xpath_selector('//*[@text="Open in Status"]')
def click(self):
self.wait_for_visibility_of_element()
# 'Open in Status' button already in DOM but need to scroll down so that click action works
self.driver.swipe(500, 1000, 500, 100)
self.driver.info('Tap on %s' % self.name)
self.wait_for_element().click()
class BaseView(object): class BaseView(object):
def __init__(self, driver): def __init__(self, driver):
self.driver = driver self.driver = driver
@ -311,6 +326,9 @@ class BaseView(object):
self.show_roots_button = ShowRoots(self.driver) self.show_roots_button = ShowRoots(self.driver)
self.get_started_button = GetStartedButton(self.driver) self.get_started_button = GetStartedButton(self.driver)
# external browser
self.open_in_status_button = OpenInStatusButton(self.driver)
self.apps_button = AppsButton(self.driver) self.apps_button = AppsButton(self.driver)
self.status_app_icon = StatusAppIcon(self.driver) self.status_app_icon = StatusAppIcon(self.driver)
@ -566,3 +584,9 @@ class BaseView(object):
airplane_toggle.click() airplane_toggle.click()
# opening Status app # opening Status app
self.driver.start_activity(app_package='im.status.ethereum', app_activity='.MainActivity') self.driver.start_activity(app_package='im.status.ethereum', app_activity='.MainActivity')
def open_universal_web_link(self, deep_link):
start_web_browser(self.driver)
self.send_as_keyevent(deep_link)
self.confirm()
self.open_in_status_button.click()

View File

@ -154,3 +154,7 @@ class SignInView(BaseView):
except IndexError: except IndexError:
raise NoSuchElementException( raise NoSuchElementException(
'Device %s: Unable to find account by position %s' % (self.driver.number, position)) from None 'Device %s: Unable to find account by position %s' % (self.driver.number, position)) from None
def open_weblink_and_login(self, url_weblink):
self.open_universal_web_link(url_weblink)
self.sign_in()