diff --git a/test/appium/support/api/network_api.py b/test/appium/support/api/network_api.py index ba2881cc3e..aaa80af4dc 100644 --- a/test/appium/support/api/network_api.py +++ b/test/appium/support/api/network_api.py @@ -135,10 +135,20 @@ class NetworkApi(object): errors.append('Recipients balance is not updated on etherscan') def faucet(self, address): - return requests.request('GET', '%s/0x%s' % (self.faucet_url, address)).json() + try: + self.log("Trying to get funds from %s" % self.faucet_url) + return requests.request('GET', '%s/0x%s' % (self.faucet_url, address)).json() + except JSONDecodeError as e: + self.log(str(e)) + pass def faucet_backup(self, address): - return requests.request('GET', '%s/0x%s' % (self.faucet_backup_url, address)).json() + try: + self.log("Trying to get funds from %s" % self.faucet_backup_url) + return requests.request('GET', '%s/0x%s' % (self.faucet_backup_url, address)).json() + except JSONDecodeError as e: + self.log(str(e)) + pass def get_donate(self, address, external_faucet=True, wait_time=300): initial_balance = self.get_balance(address) diff --git a/test/appium/tests/atomic/account_management/test_wallet_management.py b/test/appium/tests/atomic/account_management/test_wallet_management.py index cc665c4079..acb81766df 100644 --- a/test/appium/tests/atomic/account_management/test_wallet_management.py +++ b/test/appium/tests/atomic/account_management/test_wallet_management.py @@ -208,6 +208,7 @@ class TestWalletManagement(SingleDeviceTestCase): profile = home_view.profile_button.click() wallet_view = profile.wallet_button.click() wallet_view.set_up_wallet() + wallet_view.scan_tokens() wallet_view.accounts_status_account.click() wallet_view.collectibles_button.click() if not wallet_view.element_by_text('KDO').is_element_displayed(): diff --git a/test/appium/tests/atomic/transactions/test_keycard_wallet.py b/test/appium/tests/atomic/transactions/test_keycard_wallet.py index 1944dd97b0..b31f892d6f 100644 --- a/test/appium/tests/atomic/transactions/test_keycard_wallet.py +++ b/test/appium/tests/atomic/transactions/test_keycard_wallet.py @@ -51,7 +51,7 @@ class TestTransactionWalletSingleDevice(SingleDeviceTestCase): sign_in_view.just_fyi('Go back to online and check that balance is updated') sign_in_view.toggle_airplane_mode() wallet_view.wait_balance_is_changed('ETH') - wallet_view.wait_balance_is_changed('STT') + wallet_view.scan_tokens('STT') sign_in_view.just_fyi('Send some tokens to other account') recipient = "0x" + basic_user['address'] diff --git a/test/appium/tests/atomic/transactions/test_wallet.py b/test/appium/tests/atomic/transactions/test_wallet.py index 78362a2987..e54e18e6e8 100644 --- a/test/appium/tests/atomic/transactions/test_wallet.py +++ b/test/appium/tests/atomic/transactions/test_wallet.py @@ -78,7 +78,7 @@ class TestTransactionWalletSingleDevice(SingleDeviceTestCase): sign_in_view.just_fyi('Go back to online and check that balance is updated') sign_in_view.toggle_airplane_mode() wallet_view.wait_balance_is_changed('ETH') - wallet_view.wait_balance_is_changed('STT') + wallet_view.scan_tokens('STT') sign_in_view.just_fyi('Send some tokens to other account') recipient = "0x" + basic_user['address'] diff --git a/test/appium/views/wallet_view.py b/test/appium/views/wallet_view.py index 45bc2bb2e4..3edbcf25cf 100644 --- a/test/appium/views/wallet_view.py +++ b/test/appium/views/wallet_view.py @@ -97,6 +97,12 @@ class ManageAssetsButton(BaseButton): self.locator = self.Locator.accessibility_id('wallet-manage-assets') +class ScanTokensButton(BaseButton): + def __init__(self, driver): + super(ScanTokensButton, self).__init__(driver) + self.locator = self.Locator.accessibility_id('wallet-scan-token') + + class STTCheckBox(BaseButton): def __init__(self, driver): super(STTCheckBox, self).__init__(driver) @@ -391,6 +397,7 @@ class WalletView(BaseView): self.send_request_button = SendRequestButton(self.driver) self.options_button = OptionsButton(self.driver) self.manage_assets_button = ManageAssetsButton(self.driver) + self.scan_tokens_button = ScanTokensButton(self.driver) self.stt_check_box = STTCheckBox(self.driver) self.all_assets_full_names = AssetFullNameInAssets(self.driver) self.all_assets_symbols = AssetSymbolInAssets(self.driver) @@ -445,11 +452,13 @@ class WalletView(BaseView): def get_account_options_by_name(self, account_name='Status account'): return AccountOptionsButton(self.driver, account_name) - def get_asset_amount_by_name(self, asset: str): asset_value = AssetText(self.driver, asset) asset_value.scroll_to_element() - return float(asset_value.text.split()[0]) + try: + return float(asset_value.text.split()[0]) + except ValueError: + return 0.0 def verify_currency_balance(self, expected_rate: int, errors: list): usd = self.get_usd_total_value() @@ -470,9 +479,9 @@ class WalletView(BaseView): counter += 10 time.sleep(10) self.swipe_down() - self.driver.info('Waiting %s seconds for %s balance update' % (counter,asset)) + self.driver.info('Waiting %s seconds for %s balance update to be equal to %s' % (counter,asset, expected_balance)) else: - self.driver.info('Transaction received, balance updated!') + self.driver.info('Balance for %s is equal to %s' % (asset, expected_balance)) return def wait_balance_is_changed(self, asset ='ETH', initial_balance=0, wait_time=300): @@ -528,6 +537,26 @@ class WalletView(BaseView): self.asset_checkbox_by_name(asset).click() self.cross_icon.click() + def scan_tokens(self, *args): + self.multiaccount_more_options.click() + self.scan_tokens_button.click() + counter = 0 + if args: + for asset in args: + while True: + if counter >= 20: + self.driver.fail('Balance of %s is not changed during 20 seconds!' % asset) + elif self.get_asset_amount_by_name(asset) == 0.0: + self.multiaccount_more_options.click() + self.scan_tokens_button.click() + self.driver.info('Trying to scan for tokens one more time and waiting %s seconds for %s ' + 'to update' % (counter, asset)) + time.sleep(5) + counter += 5 + else: + self.driver.info('Balance of %s is updated!' % asset) + return self + def send_transaction(self, **kwargs): send_transaction_view = self.send_transaction_button.click() send_transaction_view.select_asset_button.click()