2022-01-14 16:51:54 +00:00
|
|
|
from views.base_element import Button, Text, EditBox, SilentButton, CheckBox
|
2020-04-03 14:45:45 +00:00
|
|
|
from views.base_view import BaseView
|
|
|
|
|
|
|
|
|
|
|
|
class KeycardView(BaseView):
|
|
|
|
def __init__(self, driver):
|
2021-01-25 16:35:40 +00:00
|
|
|
super().__init__(driver)
|
|
|
|
self.begin_setup_button = Button(self.driver, translation_id="begin-set-up")
|
|
|
|
self.connect_card_button = Button(self.driver, accessibility_id="connect-card")
|
|
|
|
self.disconnect_card_button = Button(self.driver, accessibility_id="disconnect-card")
|
|
|
|
self.reset_card_state_button = Button(self.driver, accessibility_id="keycard-reset-state")
|
|
|
|
self.connect_selected_card_button = Button(self.driver, accessibility_id="connect-selected-card")
|
|
|
|
self.pair_code_text = Text(self.driver, accessibility_id="pair-code")
|
|
|
|
self.pair_code_input = EditBox(self.driver, xpath="//android.widget.EditText")
|
|
|
|
self.pair_to_this_device_button = Button(self.driver, translation_id="pair-card")
|
|
|
|
self.connect_pairing_card_button = Button(self.driver, accessibility_id="connect-pairing-card")
|
2022-01-14 16:51:54 +00:00
|
|
|
self.return_card_to_factory_settings_checkbox = CheckBox(self.driver, accessibility_id=":checkbox-off")
|
2021-01-25 16:35:40 +00:00
|
|
|
|
|
|
|
# Keyboard
|
2021-07-20 15:23:13 +00:00
|
|
|
self.zero_button = SilentButton(self.driver, accessibility_id="numpad-button-0")
|
2021-07-15 11:12:38 +00:00
|
|
|
self.one_button = SilentButton(self.driver, accessibility_id="numpad-button-1")
|
|
|
|
self.two_button = SilentButton(self.driver, accessibility_id="numpad-button-2")
|
2021-01-25 16:35:40 +00:00
|
|
|
|
|
|
|
# Backup seed phrase
|
|
|
|
self.confirm_seed_phrase_edit_box = EditBox(self.driver, accessibility_id="enter-word")
|
2020-04-03 14:45:45 +00:00
|
|
|
|
|
|
|
def enter_default_pin(self):
|
2021-10-25 16:05:22 +00:00
|
|
|
self.driver.info("Enter default pin 111111")
|
2021-07-20 15:23:13 +00:00
|
|
|
[self.one_button.click() for _ in range(6)]
|
|
|
|
|
|
|
|
def enter_default_puk(self):
|
2021-10-25 16:05:22 +00:00
|
|
|
self.driver.info("Enter default pin 1111 1111 1111")
|
2021-07-20 15:23:13 +00:00
|
|
|
[self.one_button.click() for _ in range(12)]
|
2020-04-03 14:45:45 +00:00
|
|
|
|
2020-04-30 11:39:21 +00:00
|
|
|
def enter_another_pin(self):
|
2021-10-25 16:05:22 +00:00
|
|
|
self.driver.info("Enter not-default pin 222222")
|
2020-04-30 11:39:21 +00:00
|
|
|
for _ in range(6):
|
|
|
|
self.two_button.click()
|
|
|
|
|
2020-04-03 14:45:45 +00:00
|
|
|
def get_recovery_word(self, word_id):
|
2021-01-25 16:35:40 +00:00
|
|
|
word_element = SilentButton(self.driver, accessibility_id="word%s" % word_id)
|
2021-12-21 13:57:13 +00:00
|
|
|
word_element.wait_for_visibility_of_element()
|
2020-04-03 14:45:45 +00:00
|
|
|
return word_element.text
|
|
|
|
|
|
|
|
def get_required_word_number(self):
|
2021-01-25 16:35:40 +00:00
|
|
|
description = SilentButton(self.driver, accessibility_id="word-number")
|
2020-04-03 14:45:45 +00:00
|
|
|
full_text = description.text
|
2020-04-06 16:21:23 +00:00
|
|
|
word_number = ''.join(i for i in full_text if i.isdigit())
|
2020-04-03 14:45:45 +00:00
|
|
|
return word_number
|
|
|
|
|
2020-04-30 11:39:21 +00:00
|
|
|
def get_seed_phrase(self):
|
2020-04-03 14:45:45 +00:00
|
|
|
recovery_phrase = dict()
|
2021-11-18 15:16:48 +00:00
|
|
|
for i in range(0, 12):
|
2020-04-03 14:45:45 +00:00
|
|
|
word = self.get_recovery_word(i)
|
2021-11-18 15:16:48 +00:00
|
|
|
recovery_phrase[str(i + 1)] = word
|
2020-04-30 11:39:21 +00:00
|
|
|
return recovery_phrase
|
|
|
|
|
|
|
|
def backup_seed_phrase(self):
|
2021-10-25 16:05:22 +00:00
|
|
|
self.driver.info("Backing up seed phrase for keycard")
|
2020-04-30 11:39:21 +00:00
|
|
|
recovery_phrase = self.get_seed_phrase()
|
2020-04-03 14:45:45 +00:00
|
|
|
self.confirm_button.click()
|
|
|
|
self.yes_button.click()
|
|
|
|
for _ in range(2):
|
|
|
|
number = self.get_required_word_number()
|
|
|
|
self.confirm_seed_phrase_edit_box.set_value(recovery_phrase[number])
|
|
|
|
self.next_button.click()
|
2021-03-15 09:50:47 +00:00
|
|
|
return ' '.join(recovery_phrase.values())
|
2020-04-28 14:40:41 +00:00
|
|
|
|
|
|
|
def confirm_pin_and_proceed(self):
|
|
|
|
self.next_button.click()
|
|
|
|
self.begin_setup_button.click()
|
2021-12-06 16:55:33 +00:00
|
|
|
self.connect_card_button.wait_and_click()
|
2020-04-28 14:40:41 +00:00
|
|
|
self.enter_default_pin()
|
2021-11-18 15:16:48 +00:00
|
|
|
self.enter_default_pin()
|