22import time
33from typing import Literal
44
5+
56import pytest
67from selenium .common import NoSuchElementException
78
@@ -94,6 +95,10 @@ def header(self):
9495 def timestamp (self ):
9596 return Text (self .driver , prefix = self .locator , xpath = "//*[@content-desc='transaction-timestamp']" ).text
9697
98+ @property
99+ def options (self ):
100+ return Button (self .driver , prefix = self .locator , xpath = "//*[@content-desc='transaction-timestamp']/following::*[@content-desc='icon'][1]" )
101+
97102 @property
98103 def amount (self ):
99104 return Text (self .driver , prefix = self .locator ,
@@ -190,6 +195,14 @@ def __init__(self, driver):
190195 self .to_data_container = ConfirmationViewInfoContainer (self .driver , label_name = 'To' )
191196 self .on_data_container = ConfirmationViewInfoContainer (self .driver , label_name = 'On' )
192197
198+ # Advanced tx settings
199+ self .advanced_tx_button = Button (self .driver , accessibility_id = 'advanced-button' )
200+ self .custom_tx_params_button = Button (self .driver , translation_id = 'custom' )
201+ self .custom_max_base_fee_button = Button (self .driver , translation_id = 'max-base-fee' )
202+ self .custom_max_prio_fee_button = Button (self .driver , translation_id = 'priority-fee' )
203+ self .custom_nonce_button = Button (self .driver , translation_id = 'nonce' )
204+ self .custom_max_gas_amount_button = Button (self .driver , translation_id = 'max-gas-amount' )
205+
193206 # Swap flow
194207 self .approve_swap_button = Button (self .driver , accessibility_id = 'Approve' )
195208 self .spending_cap_approval_info_container = BaseElement (
@@ -234,6 +247,10 @@ def __init__(self, driver):
234247 self .driver , xpath = "//*[@content-desc='expanded-collectible']//android.widget.ImageView" )
235248 self .send_from_collectible_info_button = Button (self .driver , accessibility_id = "icon, Send" )
236249
250+
251+ # Tx activity
252+ self .copy_tx_hash_button = Button (self .driver , accessibility_id = "copy-transaction-hash" )
253+
237254 # dApp adding
238255 self .add_dapp_button = Button (self .driver , accessibility_id = 'connected-dapps-add' )
239256 self .wallet_connect_button = Button (self .driver , accessibility_id = 'wc-connect' )
@@ -309,13 +326,34 @@ def set_amount(self, amount: str):
309326 for i in amount :
310327 Button (self .driver , accessibility_id = 'keyboard-key-%s' % i ).click ()
311328
312- def send_asset (self , address : str , asset_name : str , amount , network_name : str , account = 'Account 1' ):
313- self .send_button .click ()
329+ def clear_value_and_set_with_custom_keyboard (self , value : str ):
330+ self .clear_amount ()
331+ self .set_amount (value )
332+ self .button_one .click ()
333+
334+ def clear_nonce_field (self ):
335+ Button (self .driver , xpath = '//com.horcrux.svg.SvgView[@content-desc="icon"]' ).click ()
336+
337+ def clear_amount (self ):
338+ """
339+ Tap on the clear button until the amount input field is empty.
340+ """
341+ clear_button = Button (self .driver , accessibility_id = "icon-label" )
342+ edit_box = EditBox (self .driver , xpath = "//android.widget.EditText" )
343+ while edit_box .text != "" and edit_box .text != "0" :
344+ clear_button .click ()
345+
346+ def set_amount_and_address (self , address : str , asset_name : str , amount , network_name = "" ):
347+ self .send_button .click_until_presence_of_element (self .address_text_input )
314348 self .address_text_input .send_keys (address )
315349 self .continue_button .click ()
316350 self .select_asset (asset_name )
317- self .select_network (network_name )
351+ if network_name :
352+ self .select_network (network_name )
318353 self .set_amount (str (amount ))
354+
355+ def send_asset (self , address : str , asset_name : str , amount , network_name : str , account = 'Account 1' ):
356+ self .set_amount_and_address (address , asset_name , amount , network_name )
319357 self .confirm_transaction ()
320358
321359 def send_asset_from_drawer (self , address : str , asset_name : str , amount , network_name : str ):
@@ -345,6 +383,11 @@ def swap_asset_from_drawer(self, asset_name: str, amount, network_name: str, dec
345383 'est_slippage' : slippage ,
346384 'max_fees' : fees }
347385
386+ def copy_tx_hash (self ):
387+ self .get_activity_element ().options .click_until_presence_of_element (self .copy_tx_hash_button )
388+ self .copy_tx_hash_button .click ()
389+ return self .driver .get_clipboard_text ()
390+
348391 def add_regular_account (self , account_name : str ):
349392 if not self .add_account_button .is_element_displayed ():
350393 self .get_account_element ().swipe_left_on_element ()
@@ -479,7 +522,8 @@ def check_last_transaction_in_activity(self, device_time, amount,
479522 send_to_account = '' ,
480523 swap_asset_to = 'SNT' ,
481524 swap_amount_to = '0.000000000000000000' ,
482- network = 'Status Network' ):
525+ network = 'Status Network' ,
526+ navigate_to_main_screen = True ):
483527 errors = list ()
484528 current_time = datetime .datetime .strptime (device_time , "%Y-%m-%dT%H:%M:%S%z" )
485529 expected_time = "Today %s" % current_time .strftime ('%-I:%M %p' )
@@ -528,7 +572,8 @@ def check_last_transaction_in_activity(self, device_time, amount,
528572 except NoSuchElementException :
529573 errors .append ("Can't find the last transaction" )
530574 finally :
531- self .close_account_button .click_until_presence_of_element (self .show_qr_code_button )
575+ if navigate_to_main_screen :
576+ self .close_account_button .click_until_presence_of_element (self .show_qr_code_button )
532577 return errors
533578
534579 def get_balance (self , asset = 'Ether' , fiat = False ):
@@ -539,6 +584,10 @@ def get_balance(self, asset='Ether', fiat=False):
539584 def get_receive_swap_amount (self , decimals = 18 ):
540585 self .just_fyi ("Getting swap Receive amount for on review page" )
541586 return self .round_amount_float (self .swap_receive_amount_summary_text .text .split ()[0 ], decimals )
587+
588+ def get_custom_tx_element (self , text ):
589+ return Text (self .driver , xpath = "//*[@content-desc[contains(., '%s')]]" % text )
590+
542591
543592 def get_connected_dapp_element_by_name (self , dapp_name : str ):
544593 class ConnectedDAppElement (BaseElement ):
@@ -557,3 +606,5 @@ def disconnect(self):
557606 def select_account_to_connect_dapp (self , account_name : str ):
558607 self .select_account_to_connect_dapp_button .click ()
559608 Button (self .driver , xpath = "//*[@content-desc='container']/*[@text='%s']" % account_name ).click ()
609+
610+
0 commit comments