Updated test_home_view with new onboarding flow

Signed-off-by: Serhy <sergii@status.im>
This commit is contained in:
yevh-berdnyk 2019-07-23 02:19:30 +03:00 committed by Serhy
parent f29f02d961
commit f0269bc732
No known key found for this signature in database
GPG Key ID: 5D7C4B9E2B6F500B
2 changed files with 43 additions and 33 deletions

View File

@ -1,4 +1,6 @@
import pytest import pytest
import random
from tests import marks, common_password, get_current_time, unique_password from tests import marks, common_password, get_current_time, unique_password
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
@ -57,22 +59,30 @@ class TestCreateAccount(SingleDeviceTestCase):
@marks.high @marks.high
def test_home_view(self): def test_home_view(self):
sign_in = SignInView(self.driver) sign_in = SignInView(self.driver)
sign_in.get_started_button.click()
welcome_screen = sign_in.create_user() sign_in.generate_key_button.click()
account_button = sign_in.get_account_by_position(random.randint(1, 4))
# To Do: update new onboarding flow checks username = account_button.username.text
# if not welcome_screen.welcome_image.is_element_displayed(): account_button.click()
# self.errors.append('Welcome image is not shown') sign_in.next_button.click()
# for text in ['Welcome to Status', sign_in.next_button.click()
# 'Here you can chat with people in a secure private chat, browse and interact with DApps.']: sign_in.create_password_input.set_value(common_password)
# if not welcome_screen.element_by_text(text).is_element_displayed(): sign_in.next_button.click()
# self.errors.append("'%s' text is not shown" % text) sign_in.confirm_your_password_input.set_value(common_password)
sign_in.next_button.click()
welcome_screen.get_started_button.click() sign_in.maybe_later_button.click()
sign_in.maybe_later_button.click()
home_view = sign_in.get_home_view()
text = 'There are no recent chats here yet. \nUse the (+) button to discover people \nto chat with' text = 'There are no recent chats here yet. \nUse the (+) button to discover people \nto chat with'
if not welcome_screen.element_by_text(text).is_element_displayed(): if not home_view.element_by_text(text).is_element_displayed():
self.errors.append("'%s' text is not shown" % text) self.errors.append("'%s' text is not shown" % text)
profile_view = home_view.profile_button.click()
shown_username_1 = profile_view.username_set_by_user_text.text
shown_username_2 = profile_view.default_username_text.text
if shown_username_1 != username:
self.errors.append("Profile username '%s' doesn't match '%s'" % (shown_username_1, username))
if shown_username_2 != username:
self.errors.append("Default username '%s' doesn't match '%s'" % (shown_username_2, username))
self.verify_no_errors() self.verify_no_errors()
@marks.testrail_id(5460) @marks.testrail_id(5460)

View File

@ -1,14 +1,20 @@
from selenium.common.exceptions import NoSuchElementException from selenium.common.exceptions import NoSuchElementException
from tests import get_current_time, common_password from tests import common_password
from views.base_element import BaseButton, BaseEditBox from views.base_element import BaseButton, BaseEditBox, BaseText
from views.base_view import BaseView from views.base_view import BaseView
class MultiaccountButton(BaseButton): class MultiAccountButton(BaseButton):
def __init__(self, driver): class Username(BaseText):
super(MultiaccountButton, self).__init__(driver) def __init__(self, driver, locator_value):
self.locator = self.Locator.xpath_selector("//*[contains(@text,'0x')]") super(MultiAccountButton.Username, self).__init__(driver)
self.locator = self.Locator.xpath_selector(locator_value + '/preceding-sibling::*[1]')
def __init__(self, driver, position):
super(MultiAccountButton, self).__init__(driver)
self.locator = self.Locator.xpath_selector("(//*[contains(@text,'0x')])[%s]" % position)
self.username = self.Username(driver, self.locator.value)
class PasswordInput(BaseEditBox): class PasswordInput(BaseEditBox):
@ -63,7 +69,8 @@ class RecoverAccessButton(BaseButton):
class CreateMultiaccountButton(BaseButton): class CreateMultiaccountButton(BaseButton):
def __init__(self, driver): def __init__(self, driver):
super(CreateMultiaccountButton, self).__init__(driver) super(CreateMultiaccountButton, self).__init__(driver)
self.locator = self.Locator.xpath_selector("//*[@text='Create multiaccount' or @text='Create new multiaccount']") self.locator = self.Locator.xpath_selector(
"//*[@text='Create multiaccount' or @text='Create new multiaccount']")
class GenerateKeyButton(BaseButton): class GenerateKeyButton(BaseButton):
@ -140,7 +147,6 @@ class SignInView(BaseView):
if skip_popups: if skip_popups:
self.accept_agreements() self.accept_agreements()
self.account_button = MultiaccountButton(self.driver)
self.password_input = PasswordInput(self.driver) self.password_input = PasswordInput(self.driver)
self.recover_account_password_input = RecoverAccountPasswordInput(self.driver) self.recover_account_password_input = RecoverAccountPasswordInput(self.driver)
@ -173,13 +179,6 @@ class SignInView(BaseView):
self.next_button.click() self.next_button.click()
self.maybe_later_button.click() self.maybe_later_button.click()
self.maybe_later_button.click() self.maybe_later_button.click()
# self.element_by_text_part('Display name').wait_for_element(60)
# username = username if username else 'user_%s' % get_current_time()
# self.name_input.set_value(username)
# self.next_button.click()
# self.get_started_button.click()
return self.get_home_view() return self.get_home_view()
def recover_access(self, passphrase: str, password: str = common_password): def recover_access(self, passphrase: str, password: str = common_password):
@ -200,12 +199,13 @@ class SignInView(BaseView):
self.password_input.set_value(password) self.password_input.set_value(password)
return self.sign_in_button.click() return self.sign_in_button.click()
def click_account_by_position(self, position: int): def get_account_by_position(self, position: int):
if self.ok_button.is_element_displayed(): if self.ok_button.is_element_displayed():
self.ok_button.click() self.ok_button.click()
try: account_button = MultiAccountButton(self.driver, position)
self.account_button.find_elements()[position].click() if account_button.is_element_displayed():
except IndexError: return account_button
else:
raise NoSuchElementException( raise NoSuchElementException(
'Device %s: Unable to find multiaccount by position %s' % (self.driver.number, position)) from None 'Device %s: Unable to find multiaccount by position %s' % (self.driver.number, position)) from None