2018-02-19 11:51:53 +00:00
|
|
|
from tests import get_current_time
|
2018-01-14 17:43:36 +00:00
|
|
|
from views.base_element import BaseButton, BaseEditBox
|
2018-01-03 09:34:40 +00:00
|
|
|
from views.base_view import BaseView
|
2017-09-21 17:01:04 +00:00
|
|
|
|
|
|
|
|
2018-05-02 16:01:17 +00:00
|
|
|
class AccountButton(BaseButton):
|
2017-09-21 17:01:04 +00:00
|
|
|
|
|
|
|
def __init__(self, driver):
|
2018-05-02 16:01:17 +00:00
|
|
|
super(AccountButton, self).__init__(driver)
|
|
|
|
self.locator = self.Locator.xpath_selector("//*[contains(@text,'0x')]")
|
2017-09-21 17:01:04 +00:00
|
|
|
|
|
|
|
|
|
|
|
class PasswordInput(BaseEditBox):
|
|
|
|
|
|
|
|
def __init__(self, driver):
|
|
|
|
super(PasswordInput, 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
|
|
|
|
|
|
|
|
|
|
|
class SignInButton(BaseButton):
|
|
|
|
|
|
|
|
def __init__(self, driver):
|
|
|
|
super(SignInButton, self).__init__(driver)
|
2018-03-01 13:22:01 +00:00
|
|
|
self.locator = self.Locator.xpath_selector("//android.widget.TextView[@text='Sign in' or @text='SIGN IN']")
|
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)
|
|
|
|
|
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
|
|
|
|
|
|
|
|
2018-03-01 13:22:01 +00:00
|
|
|
class CreateAccountButton(BaseButton):
|
|
|
|
def __init__(self, driver):
|
|
|
|
super(CreateAccountButton, self).__init__(driver)
|
2018-05-02 16:01:17 +00:00
|
|
|
self.locator = self.Locator.xpath_selector(
|
|
|
|
"//android.widget.TextView[@text='CREATE ACCOUNT' or @text='CREATE NEW ACCOUNT']")
|
2018-03-01 13:22:01 +00:00
|
|
|
|
|
|
|
|
|
|
|
class IHaveAccountButton(RecoverAccessButton):
|
|
|
|
def __init__(self, driver):
|
|
|
|
super(IHaveAccountButton, self).__init__(driver)
|
|
|
|
self.locator = self.Locator.xpath_selector("//android.widget.TextView[@text='I ALREADY HAVE AN ACCOUNT']")
|
|
|
|
|
|
|
|
|
|
|
|
class AddExistingAccountButton(RecoverAccessButton):
|
|
|
|
def __init__(self, driver):
|
|
|
|
super(AddExistingAccountButton, self).__init__(driver)
|
|
|
|
self.locator = self.Locator.xpath_selector("//android.widget.TextView[@text='ADD EXISTING ACCOUNT']")
|
|
|
|
|
|
|
|
|
|
|
|
class ConfirmPasswordInput(BaseEditBox):
|
|
|
|
def __init__(self, driver):
|
|
|
|
super(ConfirmPasswordInput, self).__init__(driver)
|
|
|
|
self.locator = self.Locator.xpath_selector("//android.widget.TextView[@text='Confirm']")
|
|
|
|
|
|
|
|
|
|
|
|
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
|
|
|
|
|
|
|
|
2018-03-28 10:21:39 +00:00
|
|
|
class DonNotShare(BaseButton):
|
|
|
|
|
|
|
|
def __init__(self, driver):
|
|
|
|
super(DonNotShare, self).__init__(driver)
|
2018-05-07 08:38:01 +00:00
|
|
|
self.locator = self.Locator.xpath_selector('//*[@text="NO, I DON%sT WANT TO SHARE" '
|
|
|
|
'or @text="Do not share"]' % "'")
|
2018-03-28 10:21:39 +00:00
|
|
|
|
|
|
|
|
2018-01-03 09:34:40 +00:00
|
|
|
class SignInView(BaseView):
|
2017-09-21 17:01:04 +00:00
|
|
|
|
|
|
|
def __init__(self, driver):
|
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-05-02 16:01:17 +00:00
|
|
|
self.account_button = AccountButton(self.driver)
|
2017-09-21 17:01:04 +00:00
|
|
|
self.password_input = PasswordInput(self.driver)
|
|
|
|
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
|
|
|
|
self.create_account_button = CreateAccountButton(self.driver)
|
|
|
|
self.i_have_account_button = IHaveAccountButton(self.driver)
|
|
|
|
self.add_existing_account_button = AddExistingAccountButton(self.driver)
|
|
|
|
self.confirm_password_input = ConfirmPasswordInput(self.driver)
|
|
|
|
self.name_input = NameInput(self.driver)
|
2018-03-28 10:21:39 +00:00
|
|
|
self.do_not_share = DonNotShare(self.driver)
|
2018-03-01 13:22:01 +00:00
|
|
|
|
2018-04-30 09:58:20 +00:00
|
|
|
def create_user(self, password: str = 'qwerty1234'):
|
2018-03-01 13:22:01 +00:00
|
|
|
self.create_account_button.click()
|
2018-04-30 09:58:20 +00:00
|
|
|
self.password_input.set_value(password)
|
2018-03-01 13:22:01 +00:00
|
|
|
self.next_button.click()
|
2018-04-30 09:58:20 +00:00
|
|
|
self.confirm_password_input.set_value(password)
|
2018-03-01 13:22:01 +00:00
|
|
|
self.next_button.click()
|
2018-02-19 11:51:53 +00:00
|
|
|
self.name_input.wait_for_element(45)
|
2018-05-02 16:01:17 +00:00
|
|
|
self.name_input.send_keys('user_%s' % get_current_time())
|
2018-03-01 13:22:01 +00:00
|
|
|
self.next_button.click()
|
2018-03-28 10:21:39 +00:00
|
|
|
self.do_not_share.wait_for_element(10)
|
|
|
|
self.do_not_share.click_until_presence_of_element(self.home_button)
|
2018-03-01 13:22:01 +00:00
|
|
|
|
|
|
|
def recover_access(self, passphrase, password):
|
|
|
|
recover_access_view = self.i_have_account_button.click()
|
2018-04-26 15:05:53 +00:00
|
|
|
recover_access_view.passphrase_input.click()
|
|
|
|
recover_access_view.send_as_keyevent(passphrase)
|
2018-03-01 13:22:01 +00:00
|
|
|
recover_access_view.password_input.click()
|
2018-04-26 15:05:53 +00:00
|
|
|
recover_access_view.send_as_keyevent(password)
|
2018-03-01 13:22:01 +00:00
|
|
|
recover_access_view.sign_in_button.click()
|
2018-03-28 10:21:39 +00:00
|
|
|
self.do_not_share.wait_for_element(10)
|
|
|
|
self.do_not_share.click_until_presence_of_element(self.home_button)
|
2018-05-02 16:01:17 +00:00
|
|
|
|
2018-04-26 06:22:11 +00:00
|
|
|
def sign_in(self, password):
|
|
|
|
self.password_input.set_value(password)
|
|
|
|
self.sign_in_button.click()
|
|
|
|
|
2018-05-02 16:01:17 +00:00
|
|
|
def click_account_by_position(self, position: int):
|
2018-04-26 06:22:11 +00:00
|
|
|
self.account_button.find_elements()[position].click()
|