Skip to content

Commit 2dad919

Browse files
committed
e2e: updated recovery phrase elements and flow
1 parent aa3482e commit 2dad919

File tree

7 files changed

+77
-48
lines changed

7 files changed

+77
-48
lines changed

test/appium/tests/profile/test_fallback.py

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -261,10 +261,12 @@ def test_fallback_add_key_pair(self):
261261
self.errors.append(
262262
self.profile_2,
263263
"Newly added regular account is not shown in profile as on device before importing key pair")
264-
self.profile_2.options_button.click()
265-
if not self.profile_2.import_by_entering_recovery_phrase_button.is_element_displayed():
264+
self.profile_2.get_missing_key_pair_by_name(key_pair_name=generated_key_pair_name).options_button.click()
265+
if self.profile_2.import_by_entering_recovery_phrase_button.is_element_displayed():
266+
self.profile_2.click_system_back_button(times=4)
267+
else:
266268
self.errors.append(self.profile_2, "Can not import key pair account from profile")
267-
self.profile_2.click_system_back_button(times=4)
269+
self.profile_2.click_system_back_button(times=3)
268270

269271
wallet_2.just_fyi("Device 2: import key pair")
270272
wallet_2.get_account_element(account_name=regular_account_name).swipe_left_on_element()

test/appium/tests/profile/test_profile.py

Lines changed: 27 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -26,28 +26,36 @@ def prepare_devices(self):
2626
@marks.testrail_id(741966)
2727
def test_profile_back_up_seed_phrase_validation(self):
2828
self.profile.backup_recovery_phrase_button.click()
29-
self.profile.ok_continue_button.click()
29+
for checkbox in self.profile.checkbox_button.find_elements():
30+
checkbox.click()
31+
self.profile.button_one.click()
3032
recovery_phrase = self.profile.get_recovery_phrase()
31-
self.profile.recovery_phrase_next_button.click()
33+
self.profile.button_one.click()
3234
word_number = self.profile.recovery_phrase_word_number.number
33-
incorrect_word_number = 11 if word_number == 12 else word_number + 1
34-
self.profile.recovery_phrase_word_input.send_keys(recovery_phrase[incorrect_word_number])
35-
self.profile.recovery_phrase_next_button.click()
36-
if not self.profile.element_by_translation_id('wrong-word').is_element_displayed():
35+
self.profile.get_incorrect_word_button(recovery_phrase[word_number]).click()
36+
if not self.profile.element_by_translation_id('oops-wrong-word').is_element_displayed():
3737
self.errors.append(self.profile,
38-
"Error message 'Wrong word' is not shown on the first seed phrase validation step")
39-
self.profile.recovery_phrase_word_input.send_keys(recovery_phrase[word_number])
40-
self.profile.recovery_phrase_next_button.click()
41-
word_number_1 = self.profile.recovery_phrase_word_number.number
42-
incorrect_word_number_1 = 11 if word_number_1 == 12 else word_number_1 + 1
43-
self.profile.recovery_phrase_word_input.send_keys(recovery_phrase[incorrect_word_number_1])
44-
self.profile.done_button.click()
45-
if not self.profile.element_by_translation_id('wrong-word').is_element_displayed():
46-
self.errors.append(self.profile,
47-
"Error message 'Wrong word' is not shown on the second seed phrase validation step")
48-
# self.profile.click_system_back_button() # ToDo: issue with LT emulators, needs investigation
49-
# if not self.profile.backup_recovery_phrase_button.is_element_displayed():
50-
# self.errors.append(self.profile, "Backup recovery phrase button is not shown after failed validation")
38+
"Error message 'Oops! Wrong word' is not shown on the first seed phrase validation step")
39+
self.profile.get_incorrect_word_button(recovery_phrase[word_number]).click()
40+
if not self.profile.element_by_translation_id(
41+
'do-not-cheat').is_element_displayed() or not self.profile.element_by_translation_id(
42+
'do-not-cheat-description').is_element_displayed():
43+
self.errors.append(
44+
self.profile,
45+
"Expected messages are not shown for the second attempt with incorrect recovery phrase word")
46+
self.profile.button_one.find_elements()[1].click()
47+
if not self.profile.recovery_phrase_table.is_element_displayed():
48+
self.errors.append(self.profile, "Recovery phrase is not shown after failed attempts to check it")
49+
self.errors.verify_no_errors() # the test fails if the recovery phrase is not shown on this step
50+
51+
self.profile.button_one.click()
52+
self.profile.fill_recovery_phrase_checking_words(recovery_phrase)
53+
if not self.profile.element_by_translation_id('written-seed-ready').is_element_displayed():
54+
self.errors.append(self.profile, "Can't complete backup")
55+
56+
self.profile.click_system_back_button(3)
57+
if not self.profile.backup_recovery_phrase_button.is_element_displayed():
58+
self.errors.append(self.profile, "Backup recovery phrase button is not shown after failed validation")
5159
self.profile.reopen_app(sign_in=True, user_name=self.username)
5260
self.home.profile_button.click()
5361
if not self.profile.backup_recovery_phrase_button.is_element_displayed():

test/appium/tests/wallet/test_collectibles.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -106,7 +106,7 @@ def test_wallet_send_collectible(self):
106106
self.wallet_view.continue_button.click()
107107
self.wallet_view.collectibles_tab_on_select_token_view.click()
108108
self.wallet_view.get_collectible_element('BVL').wait_and_click(20)
109-
self.wallet_view.confirm_button.click()
109+
self.wallet_view.button_one.click()
110110
data_to_find_on_review = {
111111
self.account_name: ("From", self.wallet_view.from_data_container),
112112
self.sender_short_address: ("From", self.wallet_view.from_data_container),

test/appium/tests/wallet/test_wallet_mainnet_no_send.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,7 @@ def test_wallet_send_flow_mainnet(self):
9696
self.wallet_view,
9797
"%s on %s: max fees is not shown before Review Send button is clicked" % (asset, network))
9898

99-
self.wallet_view.confirm_button.click_until_presence_of_element(self.wallet_view.slide_button_track)
99+
self.wallet_view.button_one.click_until_presence_of_element(self.wallet_view.slide_button_track)
100100
self.wallet_view.just_fyi("Checking Review Send page for %s on %s" % (asset, network))
101101

102102
sender_short_address = self.sender['wallet_address'].replace(self.sender['wallet_address'][6:-3],
@@ -299,7 +299,7 @@ def test_wallet_bridge_flow_mainnet(self):
299299
except TimeoutException:
300300
self.errors.append(self.wallet_view, "%s to %s: 'To' route is not shown" % (network_from, network_to))
301301

302-
self.wallet_view.confirm_button.click()
302+
self.wallet_view.button_one.click()
303303
self.wallet_view.just_fyi("Checking Bridge screen from %s to %s" % (network_from, network_to))
304304
containers = {'from': self.wallet_view.from_data_container, 'to': self.wallet_view.to_data_container}
305305
for name, container in containers.items():

test/appium/views/base_view.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -170,6 +170,8 @@ def __init__(self, driver):
170170
self.driver, xpath="//*[@content-desc='checkbox-off'][@resource-id='checkbox-component']")
171171
self.slide_button_track = SlideButton(self.driver)
172172

173+
self.button_one = Button(self.driver, accessibility_id='button-one')
174+
173175
# external browser
174176
self.open_in_android_button = Button(self.driver, translation_id="browsing-open-in-android-web-browser")
175177

test/appium/views/profile_view.py

Lines changed: 36 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -48,18 +48,18 @@ def click(self):
4848

4949
class RecoveryPhraseTable(Text):
5050
def __init__(self, driver):
51-
super().__init__(driver, translation_id="your-recovery-phrase",
52-
suffix="/following-sibling::android.view.ViewGroup[1]/android.widget.TextView")
51+
super().__init__(driver, translation_id="backup-recovery-phrase",
52+
suffix="/following-sibling::android.view.ViewGroup[2]//android.widget.TextView")
5353

5454

5555
class RecoveryPhraseWordNumberText(Text):
5656
def __init__(self, driver):
57-
super().__init__(driver, xpath="//*[contains(@text,'#')]")
57+
super().__init__(driver, xpath="//*[@content-desc='number-container']/android.widget.TextView")
5858

5959
@property
6060
def number(self):
6161
time.sleep(1)
62-
return int(self.find_element().text.split('#')[1])
62+
return int(self.find_element().text)
6363

6464

6565
class HelpButton(Button):
@@ -117,8 +117,6 @@ def __init__(self, driver):
117117

118118
self.recovery_phrase_table = RecoveryPhraseTable(self.driver)
119119
self.recovery_phrase_word_number = RecoveryPhraseWordNumberText(self.driver)
120-
self.recovery_phrase_next_button = Button(self.driver, accessibility_id="Next, icon")
121-
self.recovery_phrase_word_input = EditBox(self.driver, xpath="//android.widget.EditText")
122120

123121
# Notifications
124122
self.profile_notifications_button = Button(self.driver,
@@ -219,20 +217,35 @@ def get_recovery_phrase(self):
219217
text = [i.text for i in self.recovery_phrase_table.find_elements()]
220218
return dict(zip(map(int, text[::2]), text[1::2]))
221219

220+
def get_correct_word_button(self, word: str):
221+
return Button(self.driver, accessibility_id=word)
222+
223+
def get_incorrect_word_button(self, word: str):
224+
try:
225+
button = Button(self.driver,
226+
xpath="//*[@content-desc='%s']/following-sibling::android.view.ViewGroup" % word)
227+
button.find_element()
228+
except NoSuchElementException:
229+
button = Button(self.driver,
230+
xpath="//*[@content-desc='%s']/preceding-sibling::*/*/android.widget.TextView" % word)
231+
return button
232+
233+
def fill_recovery_phrase_checking_words(self, recovery_phrase: dict):
234+
for _ in range(4):
235+
word_number = self.recovery_phrase_word_number.number
236+
self.get_correct_word_button(recovery_phrase[word_number]).click()
237+
222238
def backup_recovery_phrase(self):
223239
self.just_fyi("Back up recovery phrase")
224240
self.backup_recovery_phrase_button.click()
225-
self.ok_continue_button.click()
241+
for checkbox in self.checkbox_button.find_elements():
242+
checkbox.click()
243+
self.button_one.click()
226244
recovery_phrase = self.get_recovery_phrase()
227-
self.recovery_phrase_next_button.click()
228-
word_number = self.recovery_phrase_word_number.number
229-
self.recovery_phrase_word_input.send_keys(recovery_phrase[word_number])
230-
self.recovery_phrase_next_button.click()
231-
word_number_1 = self.recovery_phrase_word_number.number
232-
self.recovery_phrase_word_input.send_keys(recovery_phrase[word_number_1])
233-
self.done_button.click()
234-
self.yes_button.click()
235-
self.ok_got_it_button.click()
245+
self.button_one.click()
246+
self.fill_recovery_phrase_checking_words(recovery_phrase)
247+
self.checkbox_button.click()
248+
self.button_one.find_elements()[-1].click()
236249
return ' '.join(recovery_phrase.values())
237250

238251
def edit_profile_picture(self, image_index: int, update_by="Gallery"):
@@ -342,8 +355,13 @@ def __init__(self, driver, account_name):
342355
return KeyPairAccountElement(self.driver, account_name)
343356

344357
def get_missing_key_pair_by_name(self, key_pair_name: str):
345-
return BaseElement(self.driver,
346-
xpath="//*[@content-desc='missing-keypair-item']//*[@text='%s']" % key_pair_name)
358+
class MissingKeyPairElement(BaseElement):
359+
def __init__(self, driver, key_pair_name):
360+
locator = "//*[@content-desc='missing-keypair-item']//*[@text='%s']" % key_pair_name
361+
super().__init__(driver, xpath=locator)
362+
self.options_button = Button(driver, xpath=locator + "/../..//*[@content-desc='options-button']")
363+
364+
return MissingKeyPairElement(self.driver, key_pair_name)
347365

348366
def turn_new_contact_requests_toggle(self, state: str = 'on'):
349367
self.profile_messages_button.click()

test/appium/views/wallet_view.py

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -179,7 +179,6 @@ def __init__(self, driver):
179179
self.amount_input = EditBox(self.driver, xpath="//android.widget.EditText")
180180
self.from_network_text = Text(
181181
self.driver, xpath="(//*[@content-desc='loading']/following-sibling::android.widget.TextView)[1]")
182-
self.confirm_button = Button(self.driver, accessibility_id='button-one')
183182
self.done_button = Button(self.driver, accessibility_id='done')
184183
self.amount_input_increase_button = Button(self.driver, accessibility_id='amount-input-inc-button')
185184

@@ -263,12 +262,12 @@ def slide_and_confirm_with_password(self):
263262
self.login_button.click()
264263

265264
def confirm_transaction(self):
266-
self.confirm_button.click()
265+
self.button_one.click()
267266
for _ in range(3):
268267
if self.slide_button_track.is_element_displayed():
269268
break
270269
time.sleep(5)
271-
self.confirm_button.click()
270+
self.button_one.click()
272271
self.slide_and_confirm_with_password()
273272

274273
def set_amount(self, amount: str):
@@ -301,7 +300,7 @@ def swap_asset_from_drawer(self, asset_name: str, amount, network_name: str, dec
301300
self.select_network(network_name)
302301
self.set_amount(str(amount))
303302
self.max_fees_text.wait_for_visibility_of_element(30)
304-
self.confirm_button.click_until_presence_of_element(self.swap_receive_amount_summary_text)
303+
self.button_one.click_until_presence_of_element(self.swap_receive_amount_summary_text)
305304
expected_amount = self.get_receive_swap_amount(decimals_to)
306305
est_time, slippage, fees = self.est_time_text.text, self.max_slippage_text.text, self.max_fees_text.text
307306
self.slide_and_confirm_with_password()
@@ -335,7 +334,7 @@ def remove_account(self, account_name: str, watch_only: bool = False):
335334
self.remove_account_button.click()
336335
if not watch_only:
337336
self.derivation_path_note_checkbox.click()
338-
self.confirm_button.click()
337+
self.button_one.click()
339338

340339
def get_activity_element(self, index=1):
341340
return ActivityElement(self.driver, index=index)

0 commit comments

Comments
 (0)