2021-01-25 16:35:40 +00:00
|
|
|
from views.base_element import Button, Text, EditBox, SilentButton
|
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")
|
|
|
|
|
|
|
|
# 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-06-29 15:55:55 +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):
|
|
|
|
self.driver.info("**Enter default pin 1111 1111 1111**")
|
|
|
|
[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-01-25 16:35:40 +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)
|
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()
|
|
|
|
for i in range(0,12):
|
|
|
|
word = self.get_recovery_word(i)
|
|
|
|
recovery_phrase[str(i+1)] = word
|
2020-04-30 11:39:21 +00:00
|
|
|
return recovery_phrase
|
|
|
|
|
|
|
|
def backup_seed_phrase(self):
|
2021-01-25 16:35:40 +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()
|
|
|
|
self.connect_card_button.click()
|
|
|
|
self.enter_default_pin()
|
2021-05-25 06:55:54 +00:00
|
|
|
self.enter_default_pin()
|