2019-07-23 23:10:55 +00:00
|
|
|
from appium.webdriver.common.touch_action import TouchAction
|
2018-07-11 14:14:39 +00:00
|
|
|
from selenium.common.exceptions import NoSuchElementException
|
|
|
|
|
2019-07-22 23:19:30 +00:00
|
|
|
from tests import common_password
|
|
|
|
from views.base_element import BaseButton, BaseEditBox, BaseText
|
2018-01-03 09:34:40 +00:00
|
|
|
from views.base_view import BaseView
|
2018-03-31 20:05:11 +00:00
|
|
|
|
2019-07-22 23:19:30 +00:00
|
|
|
class MultiAccountButton(BaseButton):
|
|
|
|
class Username(BaseText):
|
|
|
|
def __init__(self, driver, locator_value):
|
|
|
|
super(MultiAccountButton.Username, self).__init__(driver)
|
2020-01-29 07:29:56 +00:00
|
|
|
self.locator = self.Locator.xpath_selector(locator_value + '/android.view.ViewGroup/android.widget.TextView[1]')
|
2019-07-22 23:19:30 +00:00
|
|
|
|
2020-01-29 07:29:56 +00:00
|
|
|
def __init__(self, driver, position=1):
|
2019-07-22 23:19:30 +00:00
|
|
|
super(MultiAccountButton, self).__init__(driver)
|
2020-01-29 07:29:56 +00:00
|
|
|
self.locator = self.Locator.xpath_selector("//*[@content-desc='select-account-button-%s']" % position)
|
2019-07-22 23:19:30 +00:00
|
|
|
self.username = self.Username(driver, self.locator.value)
|
2017-09-21 17:01:04 +00:00
|
|
|
|
|
|
|
|
2020-01-29 07:29:56 +00:00
|
|
|
class MultiAccountOnLoginButton(BaseButton):
|
|
|
|
def __init__(self, driver, position=1):
|
|
|
|
super(MultiAccountOnLoginButton, self).__init__(driver)
|
|
|
|
self.locator = self.Locator.xpath_selector("(//*[@content-desc='chat-icon'])[%s]/.." % position)
|
|
|
|
|
|
|
|
|
2017-09-21 17:01:04 +00:00
|
|
|
class PasswordInput(BaseEditBox):
|
|
|
|
def __init__(self, driver):
|
|
|
|
super(PasswordInput, self).__init__(driver)
|
2019-07-09 11:37:18 +00:00
|
|
|
self.locator = self.Locator.accessibility_id("password-input")
|
|
|
|
|
|
|
|
|
|
|
|
class RecoverAccountPasswordInput(BaseEditBox):
|
|
|
|
def __init__(self, driver):
|
|
|
|
super(RecoverAccountPasswordInput, self).__init__(driver)
|
2018-03-01 13:22:01 +00:00
|
|
|
self.locator = self.Locator.xpath_selector("//android.widget.TextView[@text='Password']"
|
|
|
|
"/following-sibling::android.view.ViewGroup/android.widget.EditText")
|
2017-09-21 17:01:04 +00:00
|
|
|
|
|
|
|
|
2019-05-13 07:58:41 +00:00
|
|
|
class CreatePasswordInput(BaseEditBox):
|
|
|
|
def __init__(self, driver):
|
|
|
|
super(CreatePasswordInput, self).__init__(driver)
|
2019-08-01 15:49:33 +00:00
|
|
|
self.locator = self.Locator.xpath_selector("//android.widget.TextView[@text='Create a password']/.."
|
|
|
|
"//android.widget.EditText")
|
2019-05-13 07:58:41 +00:00
|
|
|
|
|
|
|
|
|
|
|
class ConfirmYourPasswordInput(BaseEditBox):
|
|
|
|
def __init__(self, driver):
|
|
|
|
super(ConfirmYourPasswordInput, self).__init__(driver)
|
2019-08-01 15:49:33 +00:00
|
|
|
self.locator = self.Locator.xpath_selector("//android.widget.TextView[@text='Confirm your password']/.."
|
|
|
|
"//android.widget.EditText")
|
2019-05-13 07:58:41 +00:00
|
|
|
|
|
|
|
|
2017-09-21 17:01:04 +00:00
|
|
|
class SignInButton(BaseButton):
|
|
|
|
|
|
|
|
def __init__(self, driver):
|
|
|
|
super(SignInButton, self).__init__(driver)
|
2019-07-09 11:37:18 +00:00
|
|
|
self.locator = self.Locator.xpath_selector("//android.widget.TextView[@text='Sign in' or @text='Submit']")
|
2017-09-21 17:01:04 +00:00
|
|
|
|
2018-01-14 17:43:36 +00:00
|
|
|
def navigate(self):
|
|
|
|
from views.home_view import HomeView
|
|
|
|
return HomeView(self.driver)
|
|
|
|
|
2020-02-12 10:10:19 +00:00
|
|
|
|
2019-11-25 10:32:30 +00:00
|
|
|
class LetsGoButton(BaseButton):
|
2019-11-18 09:38:34 +00:00
|
|
|
def __init__(self, driver):
|
|
|
|
super(LetsGoButton, self).__init__(driver)
|
|
|
|
self.locator = self.Locator.accessibility_id('lets-go-button')
|
|
|
|
|
2017-09-21 17:01:04 +00:00
|
|
|
|
2017-09-26 10:50:34 +00:00
|
|
|
class RecoverAccessButton(BaseButton):
|
|
|
|
|
|
|
|
def __init__(self, driver):
|
|
|
|
super(RecoverAccessButton, self).__init__(driver)
|
|
|
|
self.locator = self.Locator.xpath_selector("//android.widget.TextView[@text='Recover access']")
|
|
|
|
|
2018-01-03 09:34:40 +00:00
|
|
|
def navigate(self):
|
|
|
|
from views.recover_access_view import RecoverAccessView
|
|
|
|
return RecoverAccessView(self.driver)
|
2017-09-26 10:50:34 +00:00
|
|
|
|
2020-04-03 14:45:45 +00:00
|
|
|
class KeycardKeyStorageButton(BaseButton):
|
|
|
|
|
|
|
|
def __init__(self, driver):
|
|
|
|
super(KeycardKeyStorageButton, self).__init__(driver)
|
|
|
|
self.locator = self.Locator.accessibility_id("select-storage-:advanced")
|
|
|
|
|
|
|
|
def navigate(self):
|
|
|
|
from views.keycard_view import KeycardView
|
|
|
|
return KeycardView(self.driver)
|
|
|
|
|
|
|
|
def click(self):
|
|
|
|
self.scroll_to_element().click()
|
|
|
|
return self.navigate()
|
|
|
|
|
|
|
|
|
2017-09-26 10:50:34 +00:00
|
|
|
|
2019-07-03 14:29:01 +00:00
|
|
|
class CreateMultiaccountButton(BaseButton):
|
2018-03-01 13:22:01 +00:00
|
|
|
def __init__(self, driver):
|
2019-07-03 14:29:01 +00:00
|
|
|
super(CreateMultiaccountButton, self).__init__(driver)
|
2019-07-22 23:19:30 +00:00
|
|
|
self.locator = self.Locator.xpath_selector(
|
|
|
|
"//*[@text='Create multiaccount' or @text='Create new multiaccount']")
|
2018-03-01 13:22:01 +00:00
|
|
|
|
|
|
|
|
2020-01-28 12:00:05 +00:00
|
|
|
class YourKeysMoreIcon(BaseButton):
|
|
|
|
def __init__(self, driver):
|
|
|
|
super(YourKeysMoreIcon, self).__init__(driver)
|
|
|
|
self.locator = self.Locator.accessibility_id("your-keys-more-icon")
|
|
|
|
|
|
|
|
|
2019-05-13 07:58:41 +00:00
|
|
|
class GenerateKeyButton(BaseButton):
|
|
|
|
def __init__(self, driver):
|
|
|
|
super(GenerateKeyButton, self).__init__(driver)
|
2019-12-21 15:55:19 +00:00
|
|
|
self.locator = self.Locator.xpath_selector("//*[@text='Generate keys']")
|
2019-05-13 07:58:41 +00:00
|
|
|
|
|
|
|
|
2019-07-09 11:37:18 +00:00
|
|
|
class GenerateNewKeyButton(BaseButton):
|
|
|
|
def __init__(self, driver):
|
|
|
|
super(GenerateNewKeyButton, self).__init__(driver)
|
2020-01-28 12:00:05 +00:00
|
|
|
self.locator = self.Locator.accessibility_id('generate-a-new-key')
|
2019-07-09 11:37:18 +00:00
|
|
|
|
|
|
|
|
2019-07-03 14:29:01 +00:00
|
|
|
class IHaveMultiaccountButton(RecoverAccessButton):
|
2018-03-01 13:22:01 +00:00
|
|
|
def __init__(self, driver):
|
2019-07-03 14:29:01 +00:00
|
|
|
super(IHaveMultiaccountButton, self).__init__(driver)
|
|
|
|
self.locator = self.Locator.xpath_selector("//*[@text='I already have a multiaccount']")
|
2018-03-01 13:22:01 +00:00
|
|
|
|
|
|
|
|
2019-05-13 07:58:41 +00:00
|
|
|
class AccessKeyButton(RecoverAccessButton):
|
|
|
|
def __init__(self, driver):
|
|
|
|
super(AccessKeyButton, self).__init__(driver)
|
2020-01-28 12:00:05 +00:00
|
|
|
self.locator = self.Locator.xpath_selector("//*[@text='Access key']")
|
2019-05-13 07:58:41 +00:00
|
|
|
|
|
|
|
|
|
|
|
class MaybeLaterButton(BaseButton):
|
|
|
|
def __init__(self, driver):
|
|
|
|
super(MaybeLaterButton, self).__init__(driver)
|
|
|
|
self.locator = self.Locator.xpath_selector("//*[@text='Maybe later']")
|
|
|
|
|
|
|
|
|
2019-07-03 14:29:01 +00:00
|
|
|
class AddExistingMultiaccountButton(RecoverAccessButton):
|
2018-03-01 13:22:01 +00:00
|
|
|
def __init__(self, driver):
|
2019-07-03 14:29:01 +00:00
|
|
|
super(AddExistingMultiaccountButton, self).__init__(driver)
|
|
|
|
self.locator = self.Locator.xpath_selector("//*[@text='Add existing multiaccount']")
|
2018-03-01 13:22:01 +00:00
|
|
|
|
|
|
|
|
|
|
|
class ConfirmPasswordInput(BaseEditBox):
|
|
|
|
def __init__(self, driver):
|
|
|
|
super(ConfirmPasswordInput, self).__init__(driver)
|
2018-11-30 11:42:48 +00:00
|
|
|
self.locator = self.Locator.xpath_selector("//android.widget.TextView[@text='Confirm']"
|
|
|
|
"/following-sibling::android.view.ViewGroup/android.widget.EditText")
|
2018-03-01 13:22:01 +00:00
|
|
|
|
|
|
|
|
|
|
|
class NameInput(BaseEditBox):
|
|
|
|
def __init__(self, driver):
|
|
|
|
super(NameInput, self).__init__(driver)
|
2018-05-02 16:01:17 +00:00
|
|
|
self.locator = self.Locator.xpath_selector("//android.widget.EditText")
|
2018-03-01 13:22:01 +00:00
|
|
|
|
|
|
|
|
2019-07-03 14:29:01 +00:00
|
|
|
class OtherMultiAccountsButton(BaseButton):
|
2018-07-17 16:27:00 +00:00
|
|
|
|
|
|
|
def __init__(self, driver):
|
2019-07-03 14:29:01 +00:00
|
|
|
super(OtherMultiAccountsButton, self).__init__(driver)
|
|
|
|
self.locator = self.Locator.text_selector('Other multiaccounts')
|
2018-07-17 16:27:00 +00:00
|
|
|
|
|
|
|
|
2018-09-05 19:50:48 +00:00
|
|
|
class PrivacyPolicyLink(BaseButton):
|
|
|
|
def __init__(self, driver):
|
|
|
|
super(PrivacyPolicyLink, self).__init__(driver)
|
2019-07-11 15:44:12 +00:00
|
|
|
self.locator = self.Locator.text_part_selector('privacy policy')
|
2018-09-05 19:50:48 +00:00
|
|
|
|
2019-07-23 23:10:55 +00:00
|
|
|
def click(self):
|
|
|
|
element = self.find_element()
|
|
|
|
location = element.location
|
|
|
|
size = element.size
|
2020-01-16 15:47:04 +00:00
|
|
|
x = int(location['x'] + size['width'] * 0.9)
|
|
|
|
y = int(location['y'] + size['height'] * 0.8)
|
2019-07-23 23:10:55 +00:00
|
|
|
TouchAction(self.driver).tap(None, x, y).perform()
|
|
|
|
self.driver.info('Tap on %s' % self.name)
|
|
|
|
return self.navigate()
|
|
|
|
|
2018-09-05 19:50:48 +00:00
|
|
|
def navigate(self):
|
|
|
|
from views.web_views.base_web_view import BaseWebView
|
|
|
|
return BaseWebView(self.driver)
|
|
|
|
|
|
|
|
|
2018-01-03 09:34:40 +00:00
|
|
|
class SignInView(BaseView):
|
2017-09-21 17:01:04 +00:00
|
|
|
|
2018-08-10 10:09:19 +00:00
|
|
|
def __init__(self, driver, skip_popups=True):
|
2018-01-03 09:34:40 +00:00
|
|
|
super(SignInView, self).__init__(driver)
|
2017-09-21 17:01:04 +00:00
|
|
|
self.driver = driver
|
2018-08-10 10:09:19 +00:00
|
|
|
if skip_popups:
|
|
|
|
self.accept_agreements()
|
2017-09-21 17:01:04 +00:00
|
|
|
|
|
|
|
self.password_input = PasswordInput(self.driver)
|
2019-07-09 11:37:18 +00:00
|
|
|
self.recover_account_password_input = RecoverAccountPasswordInput(self.driver)
|
|
|
|
|
2017-09-21 17:01:04 +00:00
|
|
|
self.sign_in_button = SignInButton(self.driver)
|
2017-09-26 10:50:34 +00:00
|
|
|
self.recover_access_button = RecoverAccessButton(self.driver)
|
2018-03-01 13:22:01 +00:00
|
|
|
|
|
|
|
# new design
|
2019-07-03 14:29:01 +00:00
|
|
|
self.create_multiaccount_button = CreateMultiaccountButton(self.driver)
|
|
|
|
self.i_have_multiaccount_button = IHaveMultiaccountButton(self.driver)
|
2019-05-13 07:58:41 +00:00
|
|
|
self.access_key_button = AccessKeyButton(self.driver)
|
|
|
|
self.generate_key_button = GenerateKeyButton(self.driver)
|
2020-01-28 12:00:05 +00:00
|
|
|
self.your_keys_more_icon = YourKeysMoreIcon(self.driver)
|
2019-07-09 11:37:18 +00:00
|
|
|
self.generate_new_key_button = GenerateNewKeyButton(self.driver)
|
2019-07-03 14:29:01 +00:00
|
|
|
self.add_existing_multiaccount_button = AddExistingMultiaccountButton(self.driver)
|
2018-03-01 13:22:01 +00:00
|
|
|
self.confirm_password_input = ConfirmPasswordInput(self.driver)
|
2019-05-13 07:58:41 +00:00
|
|
|
self.create_password_input = CreatePasswordInput(self.driver)
|
|
|
|
self.confirm_your_password_input = ConfirmYourPasswordInput(self.driver)
|
|
|
|
self.maybe_later_button = MaybeLaterButton(self.driver)
|
2018-03-01 13:22:01 +00:00
|
|
|
self.name_input = NameInput(self.driver)
|
2019-07-03 14:29:01 +00:00
|
|
|
self.other_multiaccounts_button = OtherMultiAccountsButton(self.driver)
|
2020-01-29 07:29:56 +00:00
|
|
|
self.multiaccount_button = MultiAccountButton(self.driver)
|
|
|
|
self.multi_account_on_login_button = MultiAccountOnLoginButton(self.driver)
|
2018-09-05 19:50:48 +00:00
|
|
|
self.privacy_policy_link = PrivacyPolicyLink(self.driver)
|
2019-11-18 09:38:34 +00:00
|
|
|
self.lets_go_button = LetsGoButton(self.driver)
|
2020-04-03 14:45:45 +00:00
|
|
|
self.keycard_storage_button = KeycardKeyStorageButton(self.driver)
|
2018-03-01 13:22:01 +00:00
|
|
|
|
2020-04-03 14:45:45 +00:00
|
|
|
def create_user(self, password=common_password, keycard=False):
|
2019-05-13 07:58:41 +00:00
|
|
|
self.get_started_button.click()
|
|
|
|
self.generate_key_button.click()
|
|
|
|
self.next_button.click()
|
2020-04-03 14:45:45 +00:00
|
|
|
if keycard:
|
|
|
|
keycard_flow = self.keycard_storage_button.click()
|
|
|
|
self.next_button.click()
|
|
|
|
keycard_flow.begin_setup_button.click()
|
|
|
|
keycard_flow.connect_card_button.click()
|
|
|
|
keycard_flow.enter_default_pin()
|
|
|
|
keycard_flow.enter_default_pin()
|
|
|
|
self.next_button.scroll_to_element()
|
|
|
|
self.next_button.wait_for_visibility_of_element(20)
|
|
|
|
self.next_button.click()
|
|
|
|
self.yes_button.click()
|
|
|
|
keycard_flow.backup_seed_phrase()
|
|
|
|
else:
|
|
|
|
self.next_button.click()
|
|
|
|
self.create_password_input.set_value(password)
|
|
|
|
self.next_button.click()
|
|
|
|
self.confirm_your_password_input.set_value(password)
|
|
|
|
self.next_button.click()
|
2019-11-25 14:37:20 +00:00
|
|
|
self.lets_go_button.wait_for_visibility_of_element(30)
|
2019-11-25 10:32:30 +00:00
|
|
|
self.lets_go_button.click_until_absense_of_element(self.lets_go_button)
|
2019-10-30 18:21:21 +00:00
|
|
|
self.profile_button.wait_for_visibility_of_element(30)
|
2018-06-28 18:46:51 +00:00
|
|
|
return self.get_home_view()
|
2018-03-01 13:22:01 +00:00
|
|
|
|
2018-09-17 08:50:01 +00:00
|
|
|
def recover_access(self, passphrase: str, password: str = common_password):
|
2020-01-28 12:00:05 +00:00
|
|
|
recover_access_view = self.access_key_button.click()
|
2019-08-01 15:49:33 +00:00
|
|
|
recover_access_view.enter_seed_phrase_button.click()
|
2020-02-12 10:10:19 +00:00
|
|
|
recover_access_view.seedphrase_input.click()
|
|
|
|
recover_access_view.seedphrase_input.set_value(passphrase)
|
2019-08-01 15:49:33 +00:00
|
|
|
recover_access_view.next_button.click()
|
|
|
|
recover_access_view.reencrypt_your_key_button.click()
|
|
|
|
recover_access_view.next_button.click()
|
|
|
|
recover_access_view.create_password_input.set_value(password)
|
|
|
|
recover_access_view.next_button.click()
|
|
|
|
recover_access_view.confirm_your_password_input.set_value(password)
|
2019-11-18 09:38:34 +00:00
|
|
|
recover_access_view.next_button.click_until_presence_of_element(self.lets_go_button)
|
|
|
|
self.lets_go_button.click()
|
|
|
|
self.profile_button.wait_for_visibility_of_element(30)
|
2018-06-28 18:46:51 +00:00
|
|
|
return self.get_home_view()
|
2018-05-02 16:01:17 +00:00
|
|
|
|
2020-04-03 14:45:45 +00:00
|
|
|
def sign_in(self, password=common_password, keycard=False):
|
2020-03-17 17:27:10 +00:00
|
|
|
self.multi_account_on_login_button.wait_for_visibility_of_element(5)
|
2020-01-29 07:29:56 +00:00
|
|
|
self.multi_account_on_login_button.click()
|
2020-04-03 14:45:45 +00:00
|
|
|
if keycard:
|
|
|
|
from views.keycard_view import KeycardView
|
|
|
|
keycard_view = KeycardView(self.driver)
|
|
|
|
keycard_view.enter_default_pin()
|
|
|
|
keycard_view.connect_card_button.click()
|
|
|
|
else:
|
|
|
|
self.password_input.set_value(password)
|
|
|
|
self.sign_in_button.click()
|
2019-10-30 18:21:21 +00:00
|
|
|
return self.get_home_view()
|
2018-04-26 06:22:11 +00:00
|
|
|
|
2019-07-22 23:19:30 +00:00
|
|
|
def get_account_by_position(self, position: int):
|
|
|
|
account_button = MultiAccountButton(self.driver, position)
|
|
|
|
if account_button.is_element_displayed():
|
|
|
|
return account_button
|
|
|
|
else:
|
2018-08-15 12:51:52 +00:00
|
|
|
raise NoSuchElementException(
|
2019-07-03 14:29:01 +00:00
|
|
|
'Device %s: Unable to find multiaccount by position %s' % (self.driver.number, position)) from None
|
2019-04-02 15:16:08 +00:00
|
|
|
|
|
|
|
def open_weblink_and_login(self, url_weblink):
|
|
|
|
self.open_universal_web_link(url_weblink)
|
2020-03-26 11:36:41 +00:00
|
|
|
self.rooted_device_continue()
|
2019-04-02 15:16:08 +00:00
|
|
|
self.sign_in()
|