2018-05-16 07:22:02 +00:00
|
|
|
import time
|
2019-08-16 10:14:23 +00:00
|
|
|
|
|
|
|
from tests import common_password
|
2021-12-16 16:25:42 +00:00
|
|
|
from views.base_element import Button, Text, EditBox, SilentButton, CheckBox
|
2018-01-03 09:34:40 +00:00
|
|
|
from views.base_view import BaseView
|
2017-10-19 13:49:20 +00:00
|
|
|
|
|
|
|
|
2021-01-25 16:35:40 +00:00
|
|
|
class TransactionHistoryButton(Button):
|
2017-10-19 13:49:20 +00:00
|
|
|
def __init__(self, driver):
|
2021-01-25 16:35:40 +00:00
|
|
|
super().__init__(driver, accessibility_id="History-item-button")
|
2017-10-19 13:49:20 +00:00
|
|
|
|
2017-10-23 20:46:49 +00:00
|
|
|
def navigate(self):
|
2018-01-03 09:34:40 +00:00
|
|
|
from views.transactions_view import TransactionsView
|
|
|
|
return TransactionsView(self.driver)
|
2017-10-19 13:49:20 +00:00
|
|
|
|
|
|
|
|
2021-12-16 16:25:42 +00:00
|
|
|
class AssetCheckBox(CheckBox):
|
2018-06-29 17:27:30 +00:00
|
|
|
def __init__(self, driver, asset_name):
|
2021-01-25 16:35:40 +00:00
|
|
|
super().__init__(driver, xpath="//*[@text='%s']" % asset_name)
|
2018-07-19 09:57:45 +00:00
|
|
|
|
2021-12-21 13:57:13 +00:00
|
|
|
def enable(self):
|
2021-12-16 16:25:42 +00:00
|
|
|
self.scroll_to_element(12)
|
2021-12-21 13:57:13 +00:00
|
|
|
super().enable()
|
2018-07-03 12:40:44 +00:00
|
|
|
|
2021-11-18 15:16:48 +00:00
|
|
|
|
2021-01-25 16:35:40 +00:00
|
|
|
class BackupRecoveryPhrase(Button):
|
2018-07-03 12:40:44 +00:00
|
|
|
def __init__(self, driver):
|
2021-01-25 16:35:40 +00:00
|
|
|
super().__init__(driver, translation_id="wallet-backup-recovery-title")
|
2018-07-06 11:10:48 +00:00
|
|
|
|
|
|
|
def navigate(self):
|
|
|
|
from views.profile_view import ProfileView
|
|
|
|
return ProfileView(self.driver)
|
|
|
|
|
2021-11-18 15:16:48 +00:00
|
|
|
|
2021-01-25 16:35:40 +00:00
|
|
|
class AccountElementButton(SilentButton):
|
2019-08-16 10:14:23 +00:00
|
|
|
def __init__(self, driver, account_name):
|
2021-01-25 16:35:40 +00:00
|
|
|
super().__init__(driver, xpath="//*[@content-desc='accountcard%s']" % account_name)
|
2019-08-16 10:14:23 +00:00
|
|
|
|
|
|
|
def color_matches(self, expected_color_image_name: str):
|
2021-01-25 16:35:40 +00:00
|
|
|
amount_text = Text(self.driver, xpath="%s//*[@content-desc='account-total-value']" % self.locator)
|
2021-06-08 10:58:26 +00:00
|
|
|
amount_text.wait_for_element_text('0', 60)
|
|
|
|
return not amount_text.is_element_differs_from_template(expected_color_image_name)
|
2019-06-24 15:53:02 +00:00
|
|
|
|
|
|
|
|
2021-01-25 16:35:40 +00:00
|
|
|
class SendTransactionButton(Button):
|
2019-06-24 15:53:02 +00:00
|
|
|
def __init__(self, driver):
|
2021-01-25 16:35:40 +00:00
|
|
|
super().__init__(driver, translation_id="wallet-send")
|
2019-06-24 15:53:02 +00:00
|
|
|
|
|
|
|
def navigate(self):
|
|
|
|
from views.send_transaction_view import SendTransactionView
|
|
|
|
return SendTransactionView(self.driver)
|
|
|
|
|
|
|
|
|
2021-11-18 15:16:48 +00:00
|
|
|
class SendTransactionFromMainButton(Button):
|
|
|
|
def __init__(self, driver):
|
|
|
|
super().__init__(driver, accessibility_id="send-transaction-button")
|
|
|
|
|
|
|
|
def navigate(self):
|
|
|
|
from views.send_transaction_view import SendTransactionView
|
|
|
|
return SendTransactionView(self.driver)
|
|
|
|
|
|
|
|
|
2021-01-25 16:35:40 +00:00
|
|
|
class ReceiveTransactionButton(Button):
|
2019-06-24 15:53:02 +00:00
|
|
|
def __init__(self, driver):
|
2021-01-25 16:35:40 +00:00
|
|
|
super().__init__(driver, translation_id="receive")
|
2019-06-24 15:53:02 +00:00
|
|
|
|
|
|
|
def navigate(self):
|
|
|
|
from views.send_transaction_view import SendTransactionView
|
|
|
|
return SendTransactionView(self.driver)
|
|
|
|
|
|
|
|
|
2021-01-25 16:35:40 +00:00
|
|
|
class AddCustomTokenButton(Button):
|
2019-08-02 21:22:23 +00:00
|
|
|
def __init__(self, driver):
|
2021-01-25 16:35:40 +00:00
|
|
|
super().__init__(driver, translation_id="add-custom-token")
|
2019-08-02 21:22:23 +00:00
|
|
|
|
|
|
|
def navigate(self):
|
|
|
|
from views.add_custom_token_view import AddCustomTokenView
|
|
|
|
return AddCustomTokenView(self.driver)
|
|
|
|
|
|
|
|
|
2021-01-25 16:35:40 +00:00
|
|
|
class AccountColorButton(Button):
|
2019-08-16 10:14:23 +00:00
|
|
|
def __init__(self, driver):
|
2021-01-25 16:35:40 +00:00
|
|
|
super().__init__(driver, translation_id="account-color", suffix="/following-sibling::android.view.ViewGroup[1]")
|
2019-08-16 10:14:23 +00:00
|
|
|
|
|
|
|
def select_color_by_position(self, position: int):
|
|
|
|
self.click()
|
|
|
|
self.driver.find_element_by_xpath(
|
2021-11-18 15:16:48 +00:00
|
|
|
"((//android.widget.ScrollView)[1]/*/*)[%s]" % str(position + 1)).click()
|
2019-08-16 10:14:23 +00:00
|
|
|
|
|
|
|
|
2018-01-03 09:34:40 +00:00
|
|
|
class WalletView(BaseView):
|
2017-10-19 13:49:20 +00:00
|
|
|
def __init__(self, driver):
|
2021-01-25 16:35:40 +00:00
|
|
|
super().__init__(driver)
|
2017-10-19 13:49:20 +00:00
|
|
|
|
2018-06-29 17:27:30 +00:00
|
|
|
self.send_transaction_button = SendTransactionButton(self.driver)
|
2021-11-18 15:16:48 +00:00
|
|
|
self.send_transaction_from_main_screen = SendTransactionFromMainButton(self.driver)
|
2018-06-29 17:27:30 +00:00
|
|
|
self.transaction_history_button = TransactionHistoryButton(self.driver)
|
2021-01-25 16:35:40 +00:00
|
|
|
self.usd_total_value = Text(self.driver, accessibility_id="total-amount-value-text")
|
2018-02-09 15:16:07 +00:00
|
|
|
|
2018-06-29 17:27:30 +00:00
|
|
|
self.receive_transaction_button = ReceiveTransactionButton(self.driver)
|
2021-01-25 16:35:40 +00:00
|
|
|
self.options_button = Button(self.driver, accessibility_id="options-menu-button")
|
|
|
|
self.manage_assets_button = Button(self.driver, accessibility_id="wallet-manage-assets")
|
2021-08-19 11:41:41 +00:00
|
|
|
self.manage_accounts_button = Button(self.driver, accessibility_id="wallet-manage-accounts")
|
2021-01-25 16:35:40 +00:00
|
|
|
self.scan_tokens_button = Button(self.driver, accessibility_id="wallet-scan-token")
|
2021-11-18 15:16:48 +00:00
|
|
|
self.all_assets_full_names = Text(self.driver,
|
2021-12-16 16:25:42 +00:00
|
|
|
xpath="//*[@content-desc='checkbox-off']/../android.widget.TextView[1]")
|
2021-11-18 15:16:48 +00:00
|
|
|
self.all_assets_symbols = Button(self.driver,
|
2021-12-16 16:25:42 +00:00
|
|
|
xpath="//*[@content-desc='checkbox-off']/../android.widget.TextView[2]")
|
2021-01-25 16:35:40 +00:00
|
|
|
self.currency_item_text = Text(self.driver, xpath="//*[@content-desc='currency-item']//android.widget.TextView")
|
2018-01-03 09:34:40 +00:00
|
|
|
|
2021-01-25 16:35:40 +00:00
|
|
|
self.address_text = Text(self.driver, accessibility_id="address-text")
|
2017-10-23 20:46:49 +00:00
|
|
|
|
2021-01-25 16:35:40 +00:00
|
|
|
self.remind_me_later_button = Button(self.driver, translation_id="remind-me-later")
|
2018-05-11 19:15:39 +00:00
|
|
|
|
2021-01-25 16:35:40 +00:00
|
|
|
self.total_amount_text = Text(self.driver, accessibility_id="total-amount-value-text")
|
|
|
|
self.currency_text = Text(self.driver, accessibility_id="total-amount-currency-text")
|
2018-07-16 12:57:01 +00:00
|
|
|
self.backup_recovery_phrase = BackupRecoveryPhrase(self.driver)
|
2021-11-18 15:16:48 +00:00
|
|
|
self.backup_recovery_phrase_warning_text = Text(self.driver,
|
|
|
|
accessibility_id="back-up-your-seed-phrase-warning")
|
2019-06-24 15:53:02 +00:00
|
|
|
|
2019-08-02 21:22:23 +00:00
|
|
|
self.add_custom_token_button = AddCustomTokenButton(self.driver)
|
|
|
|
|
2019-06-24 15:53:02 +00:00
|
|
|
# elements for multiaccount
|
2021-01-25 16:35:40 +00:00
|
|
|
self.multiaccount_more_options = Button(self.driver, accessibility_id="accounts-more-options")
|
2020-11-11 15:37:27 +00:00
|
|
|
self.accounts_status_account = AccountElementButton(self.driver, account_name=self.status_account_name)
|
2021-01-25 16:35:40 +00:00
|
|
|
self.set_currency_button = Button(self.driver, translation_id="set-currency")
|
|
|
|
self.add_account_button = Button(self.driver, accessibility_id="add-new-account")
|
|
|
|
self.generate_an_account_button = Button(self.driver, accessibility_id="add-account-sheet-generate")
|
|
|
|
self.add_watch_only_address_button = Button(self.driver, accessibility_id="add-account-sheet-watch")
|
|
|
|
self.enter_a_seed_phrase_button = Button(self.driver, accessibility_id="add-account-sheet-seed")
|
|
|
|
self.enter_a_private_key_button = Button(self.driver, accessibility_id="add-account-sheet-private-key")
|
|
|
|
self.enter_address_input = EditBox(self.driver, accessibility_id="add-account-enter-watch-address")
|
|
|
|
self.enter_seed_phrase_input = EditBox(self.driver, accessibility_id="add-account-enter-seed")
|
|
|
|
self.enter_a_private_key_input = EditBox(self.driver, accessibility_id="add-account-enter-private-key")
|
|
|
|
self.delete_account_button = Button(self.driver, translation_id="delete-account")
|
|
|
|
self.enter_your_password_input = EditBox(self.driver, accessibility_id="add-account-enter-password")
|
|
|
|
self.account_name_input = EditBox(self.driver, accessibility_id="enter-account-name")
|
2019-08-16 10:14:23 +00:00
|
|
|
self.account_color_button = AccountColorButton(self.driver)
|
2021-11-18 15:16:48 +00:00
|
|
|
self.add_account_generate_account_button = Button(self.driver,
|
|
|
|
accessibility_id="add-account-add-account-button")
|
2021-01-25 16:35:40 +00:00
|
|
|
self.status_account_total_usd_value = Text(self.driver, accessibility_id="account-total-value")
|
|
|
|
self.scan_qr_button = Button(self.driver, accessibility_id="accounts-qr-code")
|
2021-11-18 15:16:48 +00:00
|
|
|
self.close_send_transaction_view_button = Button(self.driver,
|
|
|
|
xpath="//androidx.appcompat.widget.LinearLayoutCompat")
|
2021-08-19 11:41:41 +00:00
|
|
|
self.hide_account_button = Button(self.driver, accessibility_id="hide-account-button")
|
2018-07-03 12:40:44 +00:00
|
|
|
|
2021-11-18 15:16:48 +00:00
|
|
|
# collectibles
|
2021-10-15 10:26:36 +00:00
|
|
|
self.collectibles_button = Button(self.driver, translation_id="wallet-collectibles")
|
|
|
|
self.nft_asset_button = Button(self.driver, accessibility_id="nft-asset")
|
|
|
|
self.set_collectible_as_profile_photo_button = Button(self.driver, accessibility_id="set-nft-as-pfp")
|
|
|
|
self.view_collectible_on_opensea_button = Button(self.driver, translation_id="view-on-opensea")
|
|
|
|
|
2019-10-25 14:33:56 +00:00
|
|
|
# individual account settings
|
2021-01-25 16:35:40 +00:00
|
|
|
self.account_settings_button = Button(self.driver, translation_id="account-settings")
|
|
|
|
self.apply_settings_button = Button(self.driver, translation_id="apply")
|
2021-11-18 15:16:48 +00:00
|
|
|
self.password_delete_account_input = EditBox(self.driver,
|
|
|
|
xpath='//*[@text="Password"]/following-sibling::*/android.widget.EditText')
|
2021-08-19 11:41:41 +00:00
|
|
|
self.delete_account_confirm_button = Button(self.driver, accessibility_id="delete-account-confirm")
|
2018-05-11 19:15:39 +00:00
|
|
|
|
2021-11-18 15:16:48 +00:00
|
|
|
def wait_balance_is_equal_expected_amount(self, asset='ETH', expected_balance=0.1, wait_time=300):
|
2018-05-16 07:22:02 +00:00
|
|
|
counter = 0
|
|
|
|
while True:
|
|
|
|
if counter >= wait_time:
|
2021-01-25 16:35:40 +00:00
|
|
|
self.driver.fail('**Balance is not changed during %s seconds!**' % wait_time)
|
2019-11-07 13:38:14 +00:00
|
|
|
elif self.get_asset_amount_by_name(asset) != expected_balance:
|
2018-05-16 07:22:02 +00:00
|
|
|
counter += 10
|
|
|
|
time.sleep(10)
|
2018-06-08 10:02:54 +00:00
|
|
|
self.swipe_down()
|
2021-11-18 15:16:48 +00:00
|
|
|
self.driver.info('Waiting %s seconds for %s balance update to be equal to %s' % (
|
|
|
|
counter, asset, expected_balance))
|
2018-05-16 07:22:02 +00:00
|
|
|
else:
|
2021-11-26 14:15:26 +00:00
|
|
|
self.driver.info('Balance for %s is equal to %s' % (asset, expected_balance))
|
2022-02-22 14:26:46 +00:00
|
|
|
if not self.accounts_status_account.is_element_displayed():
|
|
|
|
self.accounts_status_account.scroll_to_element(direction='up')
|
2018-05-16 07:22:02 +00:00
|
|
|
return
|
|
|
|
|
2021-11-18 15:16:48 +00:00
|
|
|
def wait_balance_is_changed(self, asset='ETH', initial_balance=0, wait_time=400, scan_tokens=False):
|
|
|
|
self.driver.info('Waiting %ss for %s updated balance' % (wait_time, asset))
|
2019-11-07 13:38:14 +00:00
|
|
|
counter = 0
|
|
|
|
while True:
|
|
|
|
if counter >= wait_time:
|
2021-11-18 15:16:48 +00:00
|
|
|
self.driver.fail(
|
|
|
|
'Balance %s %s is not changed during %s seconds!' % (asset, initial_balance, wait_time))
|
|
|
|
elif self.asset_by_name(asset).is_element_present() and self.get_asset_amount_by_name(
|
|
|
|
asset) == initial_balance:
|
2021-07-13 12:51:32 +00:00
|
|
|
if scan_tokens:
|
|
|
|
self.scan_tokens()
|
2021-11-18 15:16:48 +00:00
|
|
|
if (counter / 60).is_integer():
|
2021-06-30 13:45:15 +00:00
|
|
|
self.pull_to_refresh()
|
2021-11-18 15:16:48 +00:00
|
|
|
counter += 20
|
2019-11-07 13:38:14 +00:00
|
|
|
counter += 10
|
|
|
|
time.sleep(10)
|
2021-11-18 15:16:48 +00:00
|
|
|
self.driver.info('Waiting %ss for %s updated balance' % (counter, asset))
|
2019-11-07 13:38:14 +00:00
|
|
|
elif not self.asset_by_name(asset).is_element_present(10):
|
2021-07-12 14:44:51 +00:00
|
|
|
if scan_tokens:
|
|
|
|
self.scan_tokens()
|
2021-07-13 12:51:32 +00:00
|
|
|
self.swipe_up()
|
2019-11-07 13:38:14 +00:00
|
|
|
counter += 10
|
|
|
|
time.sleep(10)
|
2021-11-18 15:16:48 +00:00
|
|
|
self.driver.info('Waiting %s seconds for %s to display asset' % (counter, asset))
|
2019-11-07 13:38:14 +00:00
|
|
|
else:
|
2021-11-18 15:16:48 +00:00
|
|
|
self.driver.info('Balance is updated!')
|
2021-06-30 13:45:15 +00:00
|
|
|
self.wallet_button.double_click()
|
2021-05-17 14:59:43 +00:00
|
|
|
self.element_by_translation_id("wallet-total-value").scroll_to_element(direction='up')
|
2020-04-10 10:25:46 +00:00
|
|
|
return self
|
2019-11-07 13:38:14 +00:00
|
|
|
|
2018-05-16 19:59:36 +00:00
|
|
|
def get_sign_in_phrase(self):
|
|
|
|
return ' '.join([element.text for element in self.sign_in_phrase.find_elements()])
|
|
|
|
|
2021-06-14 17:52:58 +00:00
|
|
|
def set_up_wallet_when_sending_tx(self):
|
2021-11-11 11:40:31 +00:00
|
|
|
self.driver.info("Setting up wallet")
|
2021-01-25 16:35:40 +00:00
|
|
|
phrase = self.sign_in_phrase.text
|
2019-07-12 07:16:02 +00:00
|
|
|
self.ok_got_it_button.click()
|
2018-05-16 19:59:36 +00:00
|
|
|
return phrase
|
2018-06-29 17:27:30 +00:00
|
|
|
|
2020-11-11 15:37:27 +00:00
|
|
|
def get_wallet_address(self, account_name=''):
|
|
|
|
account_name = self.status_account_name if not account_name else account_name
|
2021-11-11 11:40:31 +00:00
|
|
|
self.driver.info("Getting wallet address for '%s'" % account_name)
|
2019-09-26 09:11:46 +00:00
|
|
|
self.wallet_account_by_name(account_name).click()
|
2020-09-11 14:26:46 +00:00
|
|
|
self.receive_transaction_button.click_until_presence_of_element(self.qr_code_image)
|
2018-06-29 17:27:30 +00:00
|
|
|
address = self.address_text.text
|
2020-05-01 10:33:52 +00:00
|
|
|
self.close_share_popup()
|
2018-06-29 17:27:30 +00:00
|
|
|
return address
|
|
|
|
|
2019-09-26 09:11:46 +00:00
|
|
|
def wallet_account_by_name(self, account_name):
|
2021-11-18 15:16:48 +00:00
|
|
|
self.driver.info("Getting '%s' wallet account" % account_name)
|
2019-09-26 09:11:46 +00:00
|
|
|
return AccountElementButton(self.driver, account_name)
|
|
|
|
|
2021-01-25 16:35:40 +00:00
|
|
|
def get_asset_amount_by_name(self, asset: str):
|
2021-11-11 11:40:31 +00:00
|
|
|
self.driver.info("Getting %s amount" % asset)
|
2021-01-25 16:35:40 +00:00
|
|
|
asset_value = SilentButton(self.driver, xpath="//android.view.ViewGroup[@content-desc=':%s-asset-value']"
|
2021-11-18 15:16:48 +00:00
|
|
|
"//android.widget.TextView[1]" % asset)
|
2021-11-26 14:15:26 +00:00
|
|
|
for _ in range(2):
|
|
|
|
if not asset_value.is_element_displayed():
|
|
|
|
self.element = asset_value.scroll_to_element()
|
2021-01-25 16:35:40 +00:00
|
|
|
try:
|
|
|
|
return float(asset_value.text.split()[0])
|
|
|
|
except ValueError:
|
|
|
|
return 0.0
|
|
|
|
|
2018-06-29 17:27:30 +00:00
|
|
|
def asset_by_name(self, asset_name):
|
2021-11-11 11:40:31 +00:00
|
|
|
self.driver.info("Selecting %s asset" % asset_name)
|
2021-01-25 16:35:40 +00:00
|
|
|
return SilentButton(self.driver, xpath="//*[contains(@text,'%s')]" % asset_name)
|
2018-06-29 17:27:30 +00:00
|
|
|
|
|
|
|
def asset_checkbox_by_name(self, asset_name):
|
2021-11-11 11:40:31 +00:00
|
|
|
self.driver.info("Selecting %s asset checkbox by name" % asset_name)
|
2018-06-29 17:27:30 +00:00
|
|
|
return AssetCheckBox(self.driver, asset_name)
|
2018-11-13 08:25:55 +00:00
|
|
|
|
2021-01-25 16:35:40 +00:00
|
|
|
def get_account_options_by_name(self, account_name=''):
|
|
|
|
account_name = self.status_account_name if not account_name else account_name
|
2021-11-11 11:40:31 +00:00
|
|
|
self.driver.info("Getting '%s'account options" % account_name)
|
2021-01-25 16:35:40 +00:00
|
|
|
return SilentButton(self.driver, xpath="(//*[@text='%s']/../..//*[@content-desc='icon'])[2]" % account_name)
|
2019-10-25 14:33:56 +00:00
|
|
|
|
2021-08-19 11:41:41 +00:00
|
|
|
def get_account_options_from_main_screen(self, account_name=''):
|
|
|
|
account_name = self.status_account_name if not account_name else account_name
|
2021-11-11 11:40:31 +00:00
|
|
|
self.driver.info("Getting '%s'account options from main wallet screen" % account_name)
|
2021-11-18 15:16:48 +00:00
|
|
|
return SilentButton(self.driver,
|
|
|
|
xpath="//*[@content-desc='accountcard%s']//*[@content-desc='icon']" % account_name)
|
2021-08-19 11:41:41 +00:00
|
|
|
|
|
|
|
def hidden_account_by_name_button(self, account_name=''):
|
|
|
|
return SilentButton(self.driver,
|
2021-11-18 15:16:48 +00:00
|
|
|
xpath="//*[@text='%s']/following-sibling::*[@content-desc='hide-icon']" % account_name)
|
2021-08-19 11:41:41 +00:00
|
|
|
|
|
|
|
def show_account_by_name_button(self, account_name=''):
|
|
|
|
return SilentButton(self.driver,
|
2021-11-18 15:16:48 +00:00
|
|
|
xpath="//*[@text='%s']/following-sibling::*[@content-desc='show-icon']" % account_name)
|
2021-08-19 11:41:41 +00:00
|
|
|
|
2019-05-27 16:45:20 +00:00
|
|
|
def select_asset(self, *args):
|
2021-11-11 11:40:31 +00:00
|
|
|
self.driver.info("Selecting asset(s)")
|
2019-07-03 14:29:01 +00:00
|
|
|
self.multiaccount_more_options.click()
|
2019-05-27 16:45:20 +00:00
|
|
|
self.manage_assets_button.click()
|
|
|
|
for asset in args:
|
2022-02-22 14:26:46 +00:00
|
|
|
self.element_by_text(asset).click()
|
2019-05-27 16:45:20 +00:00
|
|
|
self.cross_icon.click()
|
|
|
|
|
2020-10-07 16:07:42 +00:00
|
|
|
def scan_tokens(self, *args):
|
2021-11-11 11:40:31 +00:00
|
|
|
self.driver.info("Scanning tokens")
|
2020-10-07 16:07:42 +00:00
|
|
|
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
|
|
|
|
|
2018-11-13 08:25:55 +00:00
|
|
|
def send_transaction(self, **kwargs):
|
2021-11-11 11:40:31 +00:00
|
|
|
self.driver.info("## Sending transaction", device=False)
|
2021-11-18 15:16:48 +00:00
|
|
|
send_tx = self.send_transaction_from_main_screen.click() if kwargs.get('from_main_wallet',
|
|
|
|
True) else self.send_transaction_button.click()
|
|
|
|
send_tx.select_asset_button.click()
|
2020-04-07 14:57:31 +00:00
|
|
|
asset_name = kwargs.get('asset_name', 'ETH').upper()
|
2021-11-18 15:16:48 +00:00
|
|
|
asset_button = send_tx.asset_by_name(asset_name)
|
|
|
|
send_tx.select_asset_button.click_until_presence_of_element(
|
|
|
|
send_tx.eth_asset_in_select_asset_bottom_sheet_button)
|
2018-11-13 08:25:55 +00:00
|
|
|
asset_button.click()
|
2021-11-18 15:16:48 +00:00
|
|
|
send_tx.amount_edit_box.click()
|
2018-11-13 08:25:55 +00:00
|
|
|
|
2021-11-18 15:16:48 +00:00
|
|
|
transaction_amount = str(kwargs.get('amount', send_tx.get_unique_amount()))
|
2018-11-13 08:25:55 +00:00
|
|
|
|
2021-11-18 15:16:48 +00:00
|
|
|
send_tx.amount_edit_box.set_value(transaction_amount)
|
2020-10-28 19:39:02 +00:00
|
|
|
if kwargs.get('account_name'):
|
2021-11-18 15:16:48 +00:00
|
|
|
send_tx.chose_recipient_button.click()
|
|
|
|
send_tx.accounts_button.click()
|
|
|
|
send_tx.element_by_text(kwargs.get('account_name')).click()
|
2020-10-28 19:39:02 +00:00
|
|
|
else:
|
2021-11-18 15:16:48 +00:00
|
|
|
send_tx.set_recipient_address(kwargs.get('recipient'))
|
2018-11-26 14:06:34 +00:00
|
|
|
if kwargs.get('sign_transaction', True):
|
2021-11-18 15:16:48 +00:00
|
|
|
send_tx.sign_transaction_button.click()
|
2021-06-14 17:52:58 +00:00
|
|
|
if self.sign_in_phrase.is_element_displayed():
|
|
|
|
self.set_up_wallet_when_sending_tx()
|
2021-11-18 15:16:48 +00:00
|
|
|
send_tx.sign_transaction(keycard=kwargs.get('keycard', False),
|
|
|
|
sender_password=kwargs.get('sender_password', common_password))
|
|
|
|
return send_tx
|
2018-11-13 08:25:55 +00:00
|
|
|
|
2021-06-08 10:58:26 +00:00
|
|
|
def find_transaction_in_history(self, amount, asset='ETH', account_name=None, return_hash=False):
|
2021-09-02 16:00:55 +00:00
|
|
|
if account_name is None:
|
2021-02-04 12:51:01 +00:00
|
|
|
account_name = self.status_account_name
|
2021-10-22 17:23:27 +00:00
|
|
|
self.driver.info("Finding '%s %s' transaction for '%s'" % (amount, asset, account_name))
|
2021-02-04 12:51:01 +00:00
|
|
|
if not self.transaction_history_button.is_element_displayed():
|
|
|
|
self.get_account_by_name(account_name).click()
|
|
|
|
self.transaction_history_button.wait_for_element()
|
|
|
|
transactions_view = self.transaction_history_button.click()
|
2021-06-08 10:58:26 +00:00
|
|
|
transaction_element = transactions_view.transactions_table.find_transaction(amount=amount, asset=asset)
|
|
|
|
result = transaction_element
|
|
|
|
if return_hash:
|
|
|
|
transaction_element.click()
|
|
|
|
from views.transactions_view import TransactionTable
|
|
|
|
result = TransactionTable.TransactionElement.TransactionDetailsView(self.driver).get_transaction_hash()
|
|
|
|
return result
|
|
|
|
|
2019-06-28 14:36:24 +00:00
|
|
|
def set_currency(self, desired_currency='EUR'):
|
2021-10-25 16:05:22 +00:00
|
|
|
self.driver.info("Setting '%s' currency" % desired_currency)
|
2019-08-26 17:09:30 +00:00
|
|
|
self.multiaccount_more_options.click_until_presence_of_element(self.set_currency_button)
|
2019-06-28 14:36:24 +00:00
|
|
|
self.set_currency_button.click()
|
|
|
|
desired_currency = self.element_by_text_part(desired_currency)
|
|
|
|
desired_currency.scroll_to_element()
|
|
|
|
desired_currency.click()
|
2019-08-16 10:14:23 +00:00
|
|
|
|
|
|
|
def get_account_by_name(self, account_name: str):
|
2021-10-25 16:05:22 +00:00
|
|
|
self.driver.info("Getting account: '%s'" % account_name)
|
2019-08-16 10:14:23 +00:00
|
|
|
return AccountElementButton(self.driver, account_name)
|
|
|
|
|
2020-05-14 10:41:09 +00:00
|
|
|
def add_account(self, account_name: str, password: str = common_password, keycard=False):
|
2021-10-25 16:05:22 +00:00
|
|
|
self.driver.info("## Add account: '%s'" % account_name, device=False)
|
2019-08-16 10:14:23 +00:00
|
|
|
self.add_account_button.click()
|
2020-03-02 16:07:46 +00:00
|
|
|
self.generate_an_account_button.click()
|
2019-08-16 10:14:23 +00:00
|
|
|
self.account_name_input.send_keys(account_name)
|
2020-05-14 10:41:09 +00:00
|
|
|
if keycard:
|
|
|
|
from views.keycard_view import KeycardView
|
|
|
|
keycard_view = KeycardView(self.driver)
|
2020-08-19 15:04:21 +00:00
|
|
|
self.add_account_generate_account_button.click()
|
2020-05-14 10:41:09 +00:00
|
|
|
keycard_view.enter_default_pin()
|
|
|
|
else:
|
|
|
|
self.enter_your_password_input.send_keys(password)
|
2022-01-14 16:51:54 +00:00
|
|
|
self.add_account_generate_account_button.click_until_presence_of_element(self.accounts_status_account)
|
2021-10-25 16:05:22 +00:00
|
|
|
self.driver.info("## Account is added!", device=False)
|
2021-10-15 10:26:36 +00:00
|
|
|
|
|
|
|
def get_collectibles_amount(self, collectibles='CryptoKitties'):
|
2021-10-25 16:05:22 +00:00
|
|
|
self.driver.info("Getting '%s' Collectibles amount" % collectibles)
|
2021-11-18 15:16:48 +00:00
|
|
|
return Text(self.driver, xpath="//*[@text='%s']//following-sibling::android.widget.TextView" % collectibles)
|