2023-07-24 15:25:36 +00:00
|
|
|
import base64
|
2021-04-30 09:31:39 +00:00
|
|
|
import os
|
2023-07-24 15:25:36 +00:00
|
|
|
|
|
|
|
from selenium.common.exceptions import NoSuchElementException
|
|
|
|
|
2021-11-11 11:40:31 +00:00
|
|
|
from tests import common_password, appium_root_project_path
|
2023-08-09 21:26:13 +00:00
|
|
|
from tests.base_test_case import get_app_path
|
2021-01-25 16:35:40 +00:00
|
|
|
from views.base_element import Button, EditBox, Text
|
2018-01-03 09:34:40 +00:00
|
|
|
from views.base_view import BaseView
|
2023-07-24 15:25:36 +00:00
|
|
|
|
2021-11-18 15:16:48 +00:00
|
|
|
|
2021-01-25 16:35:40 +00:00
|
|
|
class MultiAccountButton(Button):
|
|
|
|
class Username(Text):
|
2019-07-22 23:19:30 +00:00
|
|
|
def __init__(self, driver, locator_value):
|
2021-01-25 16:35:40 +00:00
|
|
|
super(MultiAccountButton.Username, self).__init__(driver,
|
|
|
|
xpath="%s//android.widget.TextView[@content-desc='username']" % locator_value)
|
2021-11-18 15:16:48 +00:00
|
|
|
|
2020-01-29 07:29:56 +00:00
|
|
|
def __init__(self, driver, position=1):
|
2021-01-25 16:35:40 +00:00
|
|
|
super(MultiAccountButton, self).__init__(driver,
|
|
|
|
xpath="//*[@content-desc='select-account-button-%s']" % position)
|
|
|
|
self.username = self.Username(driver, self.locator)
|
2017-09-21 17:01:04 +00:00
|
|
|
|
|
|
|
|
2021-01-25 16:35:40 +00:00
|
|
|
class MultiAccountOnLoginButton(Button):
|
2020-01-29 07:29:56 +00:00
|
|
|
def __init__(self, driver, position=1):
|
2021-01-25 16:35:40 +00:00
|
|
|
super(MultiAccountOnLoginButton, self).__init__(driver,
|
|
|
|
xpath="(//*[@content-desc='chat-icon'])[%s]/.." % position)
|
2020-01-29 07:29:56 +00:00
|
|
|
|
2021-03-04 09:35:48 +00:00
|
|
|
@property
|
|
|
|
def account_logo(self):
|
|
|
|
class AccountLogo(Text):
|
|
|
|
def __init__(self, driver, parent_locator: str):
|
|
|
|
super().__init__(driver, xpath="%s//*[@content-desc='chat-icon']" % parent_locator)
|
|
|
|
|
|
|
|
return AccountLogo(self.driver, self.locator)
|
|
|
|
|
|
|
|
|
2021-02-26 15:27:20 +00:00
|
|
|
class MoveAndResetButton(Button):
|
|
|
|
def __init__(self, driver):
|
|
|
|
super().__init__(driver, accessibility_id="move-and-reset-button")
|
|
|
|
|
|
|
|
def navigate(self):
|
|
|
|
from views.keycard_view import KeycardView
|
|
|
|
return KeycardView(self.driver)
|
2020-01-29 07:29:56 +00:00
|
|
|
|
2021-03-04 09:35:48 +00:00
|
|
|
|
2021-01-25 16:35:40 +00:00
|
|
|
class BeginRecoveryButton(Button):
|
2020-07-09 11:37:10 +00:00
|
|
|
def __init__(self, driver):
|
2021-02-26 15:27:20 +00:00
|
|
|
super().__init__(driver, translation_id="keycard-recovery-intro-button-text")
|
2020-07-09 11:37:10 +00:00
|
|
|
|
|
|
|
def navigate(self):
|
|
|
|
from views.keycard_view import KeycardView
|
|
|
|
return KeycardView(self.driver)
|
|
|
|
|
|
|
|
def click(self):
|
|
|
|
self.scroll_to_element().click()
|
|
|
|
return self.navigate()
|
|
|
|
|
|
|
|
|
2023-03-21 06:38:42 +00:00
|
|
|
class LogInButton(Button):
|
2017-09-21 17:01:04 +00:00
|
|
|
def __init__(self, driver):
|
2023-03-21 06:38:42 +00:00
|
|
|
super().__init__(driver, accessibility_id="login-button")
|
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
|
|
|
|
2021-01-25 16:35:40 +00:00
|
|
|
class AccessKeyButton(Button):
|
2017-09-26 10:50:34 +00:00
|
|
|
def __init__(self, driver):
|
2021-02-26 15:27:20 +00:00
|
|
|
super().__init__(driver, translation_id="access-existing-keys")
|
2017-09-26 10:50:34 +00:00
|
|
|
|
2021-01-25 16:35:40 +00:00
|
|
|
def click(self):
|
|
|
|
self.scroll_to_element().click()
|
|
|
|
return self.navigate()
|
2017-09-26 10:50:34 +00:00
|
|
|
|
2020-04-03 14:45:45 +00:00
|
|
|
|
2021-01-25 16:35:40 +00:00
|
|
|
class KeycardKeyStorageButton(Button):
|
2020-04-03 14:45:45 +00:00
|
|
|
def __init__(self, driver):
|
2021-02-26 15:27:20 +00:00
|
|
|
super().__init__(driver, accessibility_id="select-storage-:advanced")
|
2020-04-03 14:45:45 +00:00
|
|
|
|
|
|
|
def navigate(self):
|
|
|
|
from views.keycard_view import KeycardView
|
|
|
|
return KeycardView(self.driver)
|
|
|
|
|
|
|
|
def click(self):
|
|
|
|
self.scroll_to_element().click()
|
|
|
|
return self.navigate()
|
|
|
|
|
|
|
|
|
2021-01-25 16:35:40 +00:00
|
|
|
class PrivacyPolicyLink(Button):
|
2020-01-28 12:00:05 +00:00
|
|
|
def __init__(self, driver):
|
2021-07-05 19:28:55 +00:00
|
|
|
super(PrivacyPolicyLink, self).__init__(driver, accessibility_id="privacy-policy-link")
|
2018-09-05 19:50:48 +00:00
|
|
|
|
2019-07-23 23:10:55 +00:00
|
|
|
def click(self):
|
2021-07-05 19:28:55 +00:00
|
|
|
self.driver.info('Click on link %s' % self.name)
|
|
|
|
self.click_until_absense_of_element(TermsOfUseLink(self.driver))
|
|
|
|
return self.navigate()
|
|
|
|
|
|
|
|
def navigate(self):
|
|
|
|
from views.web_views.base_web_view import BaseWebView
|
|
|
|
return BaseWebView(self.driver)
|
|
|
|
|
|
|
|
|
|
|
|
class TermsOfUseLink(Button):
|
|
|
|
def __init__(self, driver):
|
|
|
|
super(TermsOfUseLink, self).__init__(driver, xpath="//*[contains(@text, 'Terms of Use')]")
|
|
|
|
|
|
|
|
def click(self):
|
|
|
|
counter = 0
|
2022-10-04 15:44:55 +00:00
|
|
|
while PrivacyPolicyLink(self.driver).is_element_displayed(1) and counter <= 5:
|
2021-07-05 19:28:55 +00:00
|
|
|
try:
|
|
|
|
self.click_inside_element_by_coordinate(times_to_click=2)
|
|
|
|
counter += 1
|
2021-11-18 15:16:48 +00:00
|
|
|
except NoSuchElementException:
|
2021-07-05 19:28:55 +00:00
|
|
|
return self.navigate()
|
2021-01-25 16:35:40 +00:00
|
|
|
self.driver.info('Click on link %s' % self.name)
|
2019-07-23 23:10:55 +00:00
|
|
|
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)
|
|
|
|
|
|
|
|
|
2023-05-04 14:26:59 +00:00
|
|
|
class UserProfileElement(Button):
|
|
|
|
def __init__(self, driver, username):
|
|
|
|
self.username = username
|
2023-07-24 15:25:36 +00:00
|
|
|
super().__init__(driver,
|
|
|
|
xpath="//*[@text='%s']//ancestor::android.view.ViewGroup[@content-desc='profile-card']" % username)
|
2023-05-04 14:26:59 +00:00
|
|
|
|
|
|
|
def open_user_options(self):
|
|
|
|
Button(self.driver, xpath='%s//*[@content-desc="profile-card-options"]' % self.locator).click()
|
|
|
|
|
|
|
|
|
2018-01-03 09:34:40 +00:00
|
|
|
class SignInView(BaseView):
|
2017-09-21 17:01:04 +00:00
|
|
|
|
2021-02-26 15:27:20 +00:00
|
|
|
def __init__(self, driver):
|
|
|
|
super().__init__(driver)
|
2017-09-21 17:01:04 +00:00
|
|
|
self.driver = driver
|
2019-07-09 11:37:18 +00:00
|
|
|
|
2023-03-06 14:42:30 +00:00
|
|
|
# intro screen
|
|
|
|
self.sign_in_intro_button = Button(self.driver, accessibility_id="already-use-status-button")
|
|
|
|
self.i_m_new_in_status_button = Button(self.driver, accessibility_id="new-to-status-button")
|
|
|
|
|
2021-07-23 11:48:14 +00:00
|
|
|
self.migration_password_input = EditBox(self.driver, accessibility_id="enter-password-input")
|
2021-01-25 16:35:40 +00:00
|
|
|
self.access_key_button = AccessKeyButton(self.driver)
|
2023-03-17 12:19:39 +00:00
|
|
|
self.generate_key_button = Button(self.driver, accessibility_id="generate-old-key")
|
2021-06-18 11:09:03 +00:00
|
|
|
self.your_keys_more_icon = Button(self.driver, xpath="//androidx.appcompat.widget.LinearLayoutCompat")
|
|
|
|
self.generate_new_key_button = Button(self.driver, accessibility_id="generate-a-new-key")
|
2021-01-25 16:35:40 +00:00
|
|
|
self.create_password_input = EditBox(self.driver,
|
|
|
|
xpath="(//android.widget.EditText[@content-desc='password-input'])[1]")
|
|
|
|
self.confirm_your_password_input = EditBox(self.driver,
|
|
|
|
xpath="(//android.widget.EditText[@content-desc='password-input'])[2]")
|
2018-09-05 19:50:48 +00:00
|
|
|
self.privacy_policy_link = PrivacyPolicyLink(self.driver)
|
2021-07-05 19:28:55 +00:00
|
|
|
self.terms_of_use_link = TermsOfUseLink(self.driver)
|
2020-04-03 14:45:45 +00:00
|
|
|
self.keycard_storage_button = KeycardKeyStorageButton(self.driver)
|
2021-01-25 16:35:40 +00:00
|
|
|
self.first_username_on_choose_chat_name = Text(self.driver,
|
|
|
|
xpath="//*[@content-desc='select-account-button-0']//android.widget.TextView[1]")
|
2021-02-26 15:27:20 +00:00
|
|
|
self.get_keycard_banner = Button(self.driver, translation_id="get-a-keycard")
|
2021-12-16 16:25:42 +00:00
|
|
|
self.accept_tos_checkbox = self.checkbox_button
|
2018-03-01 13:22:01 +00:00
|
|
|
|
2021-11-18 15:16:48 +00:00
|
|
|
# keycard recovery
|
2021-01-25 16:35:40 +00:00
|
|
|
self.recover_with_keycard_button = Button(self.driver, accessibility_id="recover-with-keycard-button")
|
2020-07-09 11:37:10 +00:00
|
|
|
self.begin_recovery_button = BeginRecoveryButton(self.driver)
|
2021-01-25 16:35:40 +00:00
|
|
|
self.pair_to_this_device_button = Button(self.driver, translation_id="pair-card")
|
2020-07-09 11:37:10 +00:00
|
|
|
|
2021-01-25 16:35:40 +00:00
|
|
|
# restore from seed phrase
|
|
|
|
self.seedphrase_input = EditBox(self.driver, xpath="//android.widget.EditText")
|
|
|
|
self.enter_seed_phrase_button = Button(self.driver, accessibility_id="enter-seed-phrase-button")
|
2021-06-14 17:52:58 +00:00
|
|
|
self.reencrypt_your_key_button = Button(self.driver, accessibility_id="onboarding-next-button")
|
2021-02-26 15:27:20 +00:00
|
|
|
|
|
|
|
# migrate multiaccount
|
2021-06-18 11:09:03 +00:00
|
|
|
self.options_button = Button(self.driver, xpath="//androidx.appcompat.widget.LinearLayoutCompat")
|
2021-02-26 15:27:20 +00:00
|
|
|
self.manage_keys_and_storage_button = Button(self.driver, accessibility_id="manage-keys-and-storage-button")
|
|
|
|
self.multi_account_on_login_button = MultiAccountOnLoginButton(self.driver)
|
2021-11-18 15:16:48 +00:00
|
|
|
self.move_keystore_file_option = Button(self.driver, accessibility_id="move-keystore-file")
|
2021-07-20 15:23:13 +00:00
|
|
|
self.reset_database_checkbox = Button(self.driver, translation_id="reset-database")
|
2021-02-26 15:27:20 +00:00
|
|
|
self.move_and_reset_button = MoveAndResetButton(self.driver)
|
|
|
|
self.choose_storage_button = Button(self.driver, translation_id="choose-storage")
|
|
|
|
self.enter_seed_phrase_next_button = Button(self.driver, translation_id="enter-seed-phrase")
|
|
|
|
self.keycard_required_option = Button(self.driver, translation_id="empty-keycard-required")
|
|
|
|
|
|
|
|
# errors
|
|
|
|
self.custom_seed_phrase_label = Text(self.driver, translation_id="custom-seed-phrase")
|
2021-01-25 16:35:40 +00:00
|
|
|
self.continue_custom_seed_phrase_button = Button(self.driver, accessibility_id="continue-custom-seed-phrase")
|
|
|
|
self.cancel_custom_seed_phrase_button = Button(self.driver, accessibility_id="cancel-custom-seed-phrase")
|
2020-07-09 11:37:10 +00:00
|
|
|
|
2023-03-30 13:14:27 +00:00
|
|
|
# New onboarding
|
2023-10-09 07:45:28 +00:00
|
|
|
self.generate_keys_button = Button(self.driver, translation_id="lets-go")
|
2023-03-30 13:14:27 +00:00
|
|
|
self.profile_your_name_edit_box = EditBox(self.driver, accessibility_id="profile-title-input")
|
|
|
|
self.profile_continue_button = Button(self.driver, accessibility_id="submit-create-profile-button")
|
|
|
|
self.profile_password_edit_box = EditBox(self.driver, translation_id="password-creation-placeholder-1")
|
|
|
|
self.profile_repeat_password_edit_box = EditBox(self.driver, translation_id="password-creation-placeholder-2")
|
|
|
|
self.profile_confirm_password_button = Button(self.driver, translation_id="password-creation-confirm")
|
|
|
|
self.enable_biometric_maybe_later_button = Button(self.driver, translation_id="maybe-later")
|
2023-04-27 04:26:32 +00:00
|
|
|
self.identifiers_button = Button(self.driver, accessibility_id="skip-identifiers")
|
2023-03-30 13:14:27 +00:00
|
|
|
self.enable_notifications_button = Button(self.driver, accessibility_id="enable-notifications-button")
|
|
|
|
self.maybe_later_button = Button(self.driver, accessibility_id="enable-notifications-later-button")
|
|
|
|
self.start_button = Button(self.driver, accessibility_id="welcome-button")
|
|
|
|
self.use_recovery_phrase_button = Button(self.driver, translation_id="use-recovery-phrase")
|
2023-05-04 14:26:59 +00:00
|
|
|
self.passphrase_edit_box = EditBox(self.driver, accessibility_id="passphrase-input")
|
2023-07-24 15:25:36 +00:00
|
|
|
self.show_profiles_button = Button(self.driver, accessibility_id="show-profiles")
|
|
|
|
self.plus_profiles_button = Button(self.driver, accessibility_id="show-new-account-options")
|
|
|
|
self.create_new_profile_button = Button(self.driver, accessibility_id="create-new-profile")
|
2023-05-04 14:26:59 +00:00
|
|
|
self.remove_profile_button = Button(self.driver, accessibility_id="remove-profile")
|
2023-03-30 13:14:27 +00:00
|
|
|
|
|
|
|
def set_password(self, password: str):
|
2023-09-06 03:07:12 +00:00
|
|
|
self.profile_password_edit_box.send_keys(password)
|
2023-03-30 13:14:27 +00:00
|
|
|
self.profile_repeat_password_edit_box.click()
|
|
|
|
self.profile_repeat_password_edit_box.send_keys(password)
|
|
|
|
self.checkbox_button.scroll_to_element()
|
2023-05-16 12:33:45 +00:00
|
|
|
self.checkbox_button.click()
|
2023-03-30 13:14:27 +00:00
|
|
|
self.profile_confirm_password_button.click()
|
|
|
|
|
|
|
|
def set_profile(self, username: str, set_image=False):
|
2023-09-06 03:07:12 +00:00
|
|
|
self.profile_your_name_edit_box.send_keys(username)
|
2023-03-30 13:14:27 +00:00
|
|
|
self.profile_continue_button.click_until_presence_of_element(self.profile_password_edit_box)
|
|
|
|
if set_image:
|
|
|
|
pass
|
|
|
|
|
2023-11-03 13:34:33 +00:00
|
|
|
def create_user(self, password=common_password, keycard=False, enable_notifications=False,
|
2023-11-06 12:12:04 +00:00
|
|
|
username="test user", first_user=True):
|
2023-03-26 18:56:29 +00:00
|
|
|
self.driver.info("## Creating new multiaccount (password:'%s', keycard:'%s', enable_notification: '%s')" %
|
|
|
|
(password, str(keycard), str(enable_notifications)), device=False)
|
2023-10-03 12:53:57 +00:00
|
|
|
if self.element_by_text('CONTINUE').is_element_displayed(5):
|
|
|
|
self.element_by_text('CONTINUE').click()
|
2023-11-06 12:12:04 +00:00
|
|
|
if first_user:
|
2023-11-03 13:34:33 +00:00
|
|
|
self.i_m_new_in_status_button.click_until_presence_of_element(self.generate_keys_button)
|
|
|
|
else:
|
2023-11-06 12:12:04 +00:00
|
|
|
if self.show_profiles_button.is_element_displayed(20):
|
|
|
|
self.show_profiles_button.click()
|
2023-10-18 22:17:11 +00:00
|
|
|
self.plus_profiles_button.click()
|
|
|
|
self.create_new_profile_button.click()
|
|
|
|
self.generate_keys_button.click_until_presence_of_element(self.profile_your_name_edit_box)
|
2023-03-30 13:14:27 +00:00
|
|
|
self.set_profile(username)
|
|
|
|
self.set_password(password)
|
2023-07-24 15:25:36 +00:00
|
|
|
if self.enable_biometric_maybe_later_button.is_element_displayed(10):
|
2023-07-24 11:06:35 +00:00
|
|
|
self.enable_biometric_maybe_later_button.click()
|
2023-03-30 13:14:27 +00:00
|
|
|
# self.next_button.click_until_absense_of_element(self.element_by_translation_id("intro-wizard-title2"))
|
|
|
|
# if keycard:
|
|
|
|
# keycard_flow = self.keycard_storage_button.click()
|
|
|
|
# keycard_flow.confirm_pin_and_proceed()
|
|
|
|
# keycard_flow.backup_seed_phrase()
|
|
|
|
# else:
|
|
|
|
# self.next_button.click()
|
2023-09-06 03:07:12 +00:00
|
|
|
# self.create_password_input.send_keys(password)
|
|
|
|
# self.confirm_your_password_input.send_keys(password)
|
2023-03-30 13:14:27 +00:00
|
|
|
# self.next_button.click()
|
2023-04-27 04:26:32 +00:00
|
|
|
self.identifiers_button.wait_and_click(30)
|
2023-03-26 18:56:29 +00:00
|
|
|
if enable_notifications:
|
|
|
|
self.enable_notifications_button.click_until_presence_of_element(self.start_button)
|
2023-12-09 00:25:19 +00:00
|
|
|
if self.allow_button.is_element_displayed():
|
|
|
|
self.allow_button.click()
|
2023-03-26 18:56:29 +00:00
|
|
|
else:
|
|
|
|
self.maybe_later_button.click_until_presence_of_element(self.start_button)
|
|
|
|
self.start_button.click()
|
2022-10-26 15:14:25 +00:00
|
|
|
self.chats_tab.wait_for_visibility_of_element(30)
|
2021-10-25 16:05:22 +00:00
|
|
|
self.driver.info("## New multiaccount is created successfully!", device=False)
|
2018-06-28 18:46:51 +00:00
|
|
|
return self.get_home_view()
|
2018-03-01 13:22:01 +00:00
|
|
|
|
2023-05-04 14:26:59 +00:00
|
|
|
def recover_access(self, passphrase: str, password: str = common_password, keycard=False,
|
2023-03-30 13:14:27 +00:00
|
|
|
enable_notifications=False, second_user=False, username='Restore user', set_image=False):
|
2021-10-25 16:05:22 +00:00
|
|
|
self.driver.info("## Recover access(password:%s, keycard:%s)" % (password, str(keycard)), device=False)
|
2023-03-30 13:14:27 +00:00
|
|
|
|
2021-06-21 08:03:27 +00:00
|
|
|
if not second_user:
|
2023-03-30 13:14:27 +00:00
|
|
|
self.i_m_new_in_status_button.click_until_presence_of_element(self.generate_keys_button)
|
2023-05-04 14:26:59 +00:00
|
|
|
else:
|
2023-07-12 09:21:39 +00:00
|
|
|
self.show_profiles_button.wait_and_click(20)
|
2023-05-04 14:26:59 +00:00
|
|
|
self.plus_profiles_button.click()
|
|
|
|
self.create_new_profile_button.click()
|
2023-03-30 13:14:27 +00:00
|
|
|
self.use_recovery_phrase_button.click()
|
2023-09-06 03:07:12 +00:00
|
|
|
self.passphrase_edit_box.send_keys(passphrase)
|
2023-03-30 13:14:27 +00:00
|
|
|
self.continue_button.click_until_presence_of_element(self.profile_your_name_edit_box)
|
|
|
|
self.set_profile(username, set_image)
|
|
|
|
self.set_password(password)
|
2023-07-24 15:25:36 +00:00
|
|
|
if self.enable_biometric_maybe_later_button.is_element_displayed(10):
|
|
|
|
self.enable_biometric_maybe_later_button.click()
|
2023-05-04 14:26:59 +00:00
|
|
|
self.identifiers_button.wait_and_click(30)
|
2020-09-02 15:57:19 +00:00
|
|
|
if enable_notifications:
|
2023-03-26 18:56:29 +00:00
|
|
|
self.enable_notifications_button.click_until_presence_of_element(self.start_button)
|
2020-09-02 15:57:19 +00:00
|
|
|
else:
|
2023-03-26 18:56:29 +00:00
|
|
|
self.maybe_later_button.click_until_presence_of_element(self.start_button)
|
|
|
|
self.start_button.click()
|
2023-03-30 13:14:27 +00:00
|
|
|
self.chats_tab.wait_for_visibility_of_element(30)
|
2021-10-25 16:05:22 +00:00
|
|
|
self.driver.info("## Multiaccount is recovered successfully!", device=False)
|
2018-06-28 18:46:51 +00:00
|
|
|
return self.get_home_view()
|
2018-05-02 16:01:17 +00:00
|
|
|
|
2023-12-26 11:52:10 +00:00
|
|
|
def sign_in(self, password=common_password):
|
|
|
|
self.driver.info("## Sign in (password: %s)" % password, device=False)
|
|
|
|
self.password_input.wait_for_visibility_of_element(10)
|
|
|
|
self.password_input.send_keys(password)
|
|
|
|
self.login_button.click()
|
2021-10-25 16:05:22 +00:00
|
|
|
self.driver.info("## Signed in successfully!", device=False)
|
2019-10-30 18:21:21 +00:00
|
|
|
return self.get_home_view()
|
2018-04-26 06:22:11 +00:00
|
|
|
|
2020-07-13 16:06:19 +00:00
|
|
|
def get_multiaccount_by_position(self, position: int, element_class=MultiAccountOnLoginButton):
|
|
|
|
account_button = element_class(self.driver, position)
|
2019-07-22 23:19:30 +00:00
|
|
|
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):
|
2021-10-25 16:05:22 +00:00
|
|
|
self.driver.info("Open weblink '%s'" % url_weblink)
|
2019-04-02 15:16:08 +00:00
|
|
|
self.open_universal_web_link(url_weblink)
|
|
|
|
self.sign_in()
|
2021-04-30 09:31:39 +00:00
|
|
|
|
2022-04-08 16:30:15 +00:00
|
|
|
def import_db(self, seed_phrase, import_db_folder_name, password=common_password):
|
2021-10-25 16:05:22 +00:00
|
|
|
self.driver.info('## Importing database', device=False)
|
2021-04-30 09:31:39 +00:00
|
|
|
import_file_name = 'export.db'
|
2022-04-08 16:30:15 +00:00
|
|
|
home = self.recover_access(passphrase=seed_phrase, password=password)
|
2021-04-30 09:31:39 +00:00
|
|
|
profile = home.profile_button.click()
|
2022-04-08 16:30:15 +00:00
|
|
|
full_path_to_file = os.path.join(appium_root_project_path, 'views/dbs/%s/%s' %
|
2021-04-30 09:31:39 +00:00
|
|
|
(import_db_folder_name, import_file_name))
|
|
|
|
profile.logout()
|
|
|
|
self.multi_account_on_login_button.wait_for_visibility_of_element(30)
|
|
|
|
self.get_multiaccount_by_position(1).click()
|
2023-09-06 03:07:12 +00:00
|
|
|
self.password_input.send_keys(password)
|
2021-11-18 15:16:48 +00:00
|
|
|
self.driver.push_file(source_path=full_path_to_file,
|
2023-08-09 21:26:13 +00:00
|
|
|
destination_path='%s%s' % (get_app_path(), import_file_name))
|
2021-04-30 09:31:39 +00:00
|
|
|
self.options_button.click()
|
|
|
|
self.element_by_text('Import unencrypted').click()
|
|
|
|
self.element_by_text('Import unencrypted').wait_for_invisibility_of_element(40)
|
|
|
|
self.sign_in_button.click()
|
|
|
|
self.home_button.wait_for_element(40)
|
2021-10-25 16:05:22 +00:00
|
|
|
self.driver.info('## Importing database is finished!', device=False)
|
2021-04-30 09:31:39 +00:00
|
|
|
return self.get_home_view()
|
2022-06-14 14:02:48 +00:00
|
|
|
|
|
|
|
def export_db(self, seed_phrase, file_to_export='export.db', password=common_password):
|
|
|
|
self.driver.info('## Export database', device=False)
|
|
|
|
home = self.recover_access(passphrase=seed_phrase, password=password)
|
|
|
|
profile = home.profile_button.click()
|
|
|
|
full_path_to_file = os.path.join(appium_root_project_path, 'views/dbs/%s' % file_to_export)
|
|
|
|
profile.logout()
|
|
|
|
self.multi_account_on_login_button.wait_for_visibility_of_element(30)
|
|
|
|
self.get_multiaccount_by_position(1).click()
|
2023-09-06 03:07:12 +00:00
|
|
|
self.password_input.send_keys(common_password)
|
2022-06-14 14:02:48 +00:00
|
|
|
self.options_button.click()
|
|
|
|
self.element_by_text('Export unencrypted').wait_and_click(40)
|
|
|
|
self.element_by_text('Export unencrypted').wait_for_invisibility_of_element(40)
|
2023-08-09 21:26:13 +00:00
|
|
|
file_base_64 = self.driver.pull_file('%s/export.db' % get_app_path())
|
2022-06-14 14:02:48 +00:00
|
|
|
try:
|
|
|
|
with open(full_path_to_file, "wb") as f:
|
|
|
|
f.write(base64.b64decode(file_base_64))
|
|
|
|
except Exception as e:
|
|
|
|
print(str(e))
|
|
|
|
self.driver.info('## Exporting database is finished!', device=False)
|
|
|
|
|
2023-05-04 14:26:59 +00:00
|
|
|
def get_user(self, username):
|
|
|
|
self.driver.info("Getting username card by '%s'" % username)
|
|
|
|
expected_element = UserProfileElement(self.driver, username)
|
|
|
|
return expected_element if expected_element.is_element_displayed(10) else self.driver.fail("User is not found!")
|