2018-05-16 07:22:02 +00:00
|
|
|
|
import time
|
2018-01-03 09:34:40 +00:00
|
|
|
|
from views.base_view import BaseView
|
2018-01-14 17:43:36 +00:00
|
|
|
|
from views.base_element import BaseButton, BaseText
|
2017-10-19 13:49:20 +00:00
|
|
|
|
|
|
|
|
|
|
2018-06-29 17:27:30 +00:00
|
|
|
|
class SendTransactionButton(BaseButton):
|
2017-10-19 13:49:20 +00:00
|
|
|
|
|
|
|
|
|
def __init__(self, driver):
|
2018-06-29 17:27:30 +00:00
|
|
|
|
super(SendTransactionButton, self).__init__(driver)
|
2018-03-15 20:01:08 +00:00
|
|
|
|
self.locator = self.Locator.accessibility_id('send-transaction-button')
|
2018-01-14 17:43:36 +00:00
|
|
|
|
|
|
|
|
|
def navigate(self):
|
|
|
|
|
from views.send_transaction_view import SendTransactionView
|
|
|
|
|
return SendTransactionView(self.driver)
|
2017-10-19 13:49:20 +00:00
|
|
|
|
|
|
|
|
|
|
2018-06-29 17:27:30 +00:00
|
|
|
|
class ReceiveTransactionButton(BaseButton):
|
2017-12-13 13:12:46 +00:00
|
|
|
|
|
|
|
|
|
def __init__(self, driver):
|
2018-06-29 17:27:30 +00:00
|
|
|
|
super(ReceiveTransactionButton, self).__init__(driver)
|
2018-03-15 20:01:08 +00:00
|
|
|
|
self.locator = self.Locator.accessibility_id('receive-transaction-button')
|
2017-12-13 13:12:46 +00:00
|
|
|
|
|
2018-01-03 09:34:40 +00:00
|
|
|
|
def navigate(self):
|
2018-01-14 17:43:36 +00:00
|
|
|
|
from views.send_transaction_view import SendTransactionView
|
|
|
|
|
return SendTransactionView(self.driver)
|
2018-01-03 09:34:40 +00:00
|
|
|
|
|
2017-12-13 13:12:46 +00:00
|
|
|
|
|
|
|
|
|
class SendRequestButton(BaseButton):
|
|
|
|
|
|
|
|
|
|
def __init__(self, driver):
|
|
|
|
|
super(SendRequestButton, self).__init__(driver)
|
2018-03-15 20:01:08 +00:00
|
|
|
|
self.locator = self.Locator.accessibility_id('sent-request-button')
|
2017-12-13 13:12:46 +00:00
|
|
|
|
|
|
|
|
|
|
2017-10-19 13:49:20 +00:00
|
|
|
|
class ChooseRecipientButton(BaseButton):
|
|
|
|
|
|
|
|
|
|
def __init__(self, driver):
|
|
|
|
|
super(ChooseRecipientButton, self).__init__(driver)
|
2018-03-15 20:01:08 +00:00
|
|
|
|
self.locator = self.Locator.accessibility_id('choose-recipient-button')
|
2017-10-19 13:49:20 +00:00
|
|
|
|
|
|
|
|
|
|
2018-06-29 17:27:30 +00:00
|
|
|
|
class TransactionHistoryButton(BaseButton):
|
2017-10-19 13:49:20 +00:00
|
|
|
|
|
|
|
|
|
def __init__(self, driver):
|
2018-06-29 17:27:30 +00:00
|
|
|
|
super(TransactionHistoryButton, self).__init__(driver)
|
2018-03-15 20:01:08 +00:00
|
|
|
|
self.locator = self.Locator.accessibility_id('transaction-history-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
|
|
|
|
|
|
|
|
|
|
2017-10-23 20:46:49 +00:00
|
|
|
|
class ChooseFromContactsButton(BaseButton):
|
2017-10-19 13:49:20 +00:00
|
|
|
|
def __init__(self, driver):
|
2017-10-23 20:46:49 +00:00
|
|
|
|
super(ChooseFromContactsButton, self).__init__(driver)
|
|
|
|
|
self.locator = self.Locator.xpath_selector("//*[@text='Choose From Contacts']")
|
2017-10-19 13:49:20 +00:00
|
|
|
|
|
|
|
|
|
|
2017-10-23 20:46:49 +00:00
|
|
|
|
class EthAssetText(BaseText):
|
|
|
|
|
def __init__(self, driver):
|
|
|
|
|
super(EthAssetText, self).__init__(driver)
|
2018-07-20 08:27:33 +00:00
|
|
|
|
self.locator = self.Locator.accessibility_id('eth-asset-value-text')
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
class STTAssetText(BaseText):
|
|
|
|
|
def __init__(self, driver):
|
|
|
|
|
super(STTAssetText, self).__init__(driver)
|
|
|
|
|
self.locator = self.Locator.accessibility_id('stt-asset-value-text')
|
2017-10-19 13:49:20 +00:00
|
|
|
|
|
|
|
|
|
|
2017-10-23 20:46:49 +00:00
|
|
|
|
class UsdTotalValueText(BaseText):
|
2017-10-19 13:49:20 +00:00
|
|
|
|
def __init__(self, driver):
|
2017-10-23 20:46:49 +00:00
|
|
|
|
super(UsdTotalValueText, self).__init__(driver)
|
2018-08-01 00:16:33 +00:00
|
|
|
|
self.locator = self.Locator.accessibility_id('total-amount-value-text')
|
2017-10-19 13:49:20 +00:00
|
|
|
|
|
|
|
|
|
|
2018-02-09 15:16:07 +00:00
|
|
|
|
class SendTransactionRequestButton(BaseButton):
|
|
|
|
|
def __init__(self, driver):
|
|
|
|
|
super(SendTransactionRequestButton, self).__init__(driver)
|
2018-03-15 20:01:08 +00:00
|
|
|
|
self.locator = self.Locator.accessibility_id('sent-transaction-request-button')
|
2018-02-09 15:16:07 +00:00
|
|
|
|
|
2018-11-13 08:25:55 +00:00
|
|
|
|
def navigate(self):
|
|
|
|
|
from views.send_transaction_view import SendTransactionView
|
|
|
|
|
return SendTransactionView(self.driver)
|
|
|
|
|
|
2018-02-09 15:16:07 +00:00
|
|
|
|
|
|
|
|
|
class OptionsButton(BaseButton):
|
|
|
|
|
def __init__(self, driver):
|
|
|
|
|
super(OptionsButton, self).__init__(driver)
|
2018-03-15 20:01:08 +00:00
|
|
|
|
self.locator = self.Locator.accessibility_id('options-menu-button')
|
2018-02-09 15:16:07 +00:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
class ManageAssetsButton(BaseButton):
|
|
|
|
|
def __init__(self, driver):
|
|
|
|
|
super(ManageAssetsButton, self).__init__(driver)
|
|
|
|
|
self.locator = self.Locator.xpath_selector("//*[@text='Manage Assets']")
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
class STTCheckBox(BaseButton):
|
|
|
|
|
def __init__(self, driver):
|
|
|
|
|
super(STTCheckBox, self).__init__(driver)
|
2018-03-15 20:01:08 +00:00
|
|
|
|
self.locator = self.Locator.xpath_selector("//*[@text='STT']/../android.widget.CheckBox")
|
2018-02-09 15:16:07 +00:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
class DoneButton(BaseButton):
|
|
|
|
|
def __init__(self, driver):
|
|
|
|
|
super(DoneButton, self).__init__(driver)
|
2018-03-15 20:01:08 +00:00
|
|
|
|
self.locator = self.Locator.accessibility_id('done-button')
|
2018-02-09 15:16:07 +00:00
|
|
|
|
|
|
|
|
|
|
2018-05-02 16:01:17 +00:00
|
|
|
|
class QRCodeImage(BaseButton):
|
|
|
|
|
def __init__(self, driver):
|
|
|
|
|
super(QRCodeImage, self).__init__(driver)
|
|
|
|
|
self.locator = self.Locator.accessibility_id('qr-code-image')
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
class AddressText(BaseButton):
|
|
|
|
|
def __init__(self, driver):
|
|
|
|
|
super(AddressText, self).__init__(driver)
|
|
|
|
|
self.locator = self.Locator.accessibility_id('address-text')
|
|
|
|
|
|
|
|
|
|
|
2018-05-11 19:15:39 +00:00
|
|
|
|
class SetUpButton(BaseButton):
|
|
|
|
|
def __init__(self, driver):
|
|
|
|
|
super(SetUpButton, self).__init__(driver)
|
|
|
|
|
self.locator = self.Locator.text_selector("LET’S GET SET UP")
|
|
|
|
|
|
|
|
|
|
|
2018-05-16 19:59:36 +00:00
|
|
|
|
class SignInPhraseText(BaseText):
|
|
|
|
|
def __init__(self, driver):
|
|
|
|
|
super(SignInPhraseText, self).__init__(driver)
|
2018-11-14 17:18:57 +00:00
|
|
|
|
self.locator = self.Locator.xpath_selector('//*[@content-desc="signing-phrase"]//android.widget.TextView')
|
2018-05-16 19:59:36 +00:00
|
|
|
|
|
2018-06-29 17:27:30 +00:00
|
|
|
|
@property
|
|
|
|
|
def list(self):
|
|
|
|
|
return [element.text for element in self.find_elements()]
|
|
|
|
|
|
|
|
|
|
@property
|
|
|
|
|
def string(self):
|
|
|
|
|
return ' '.join(self.list)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
class AssetTextElement(BaseText):
|
|
|
|
|
def __init__(self, driver, asset_name):
|
|
|
|
|
super(AssetTextElement, self).__init__(driver)
|
|
|
|
|
self.locator = self.Locator.accessibility_id('%s-asset-value-text' % asset_name.lower())
|
|
|
|
|
|
|
|
|
|
|
2018-11-09 12:36:21 +00:00
|
|
|
|
class CollectibleTextElement(BaseText):
|
|
|
|
|
def __init__(self, driver, collectible_name):
|
|
|
|
|
super().__init__(driver)
|
|
|
|
|
self.locator = self.Locator.accessibility_id('%s-collectible-value-text' % collectible_name.lower())
|
|
|
|
|
|
|
|
|
|
|
2018-06-29 17:27:30 +00:00
|
|
|
|
class AssetCheckBox(BaseButton):
|
|
|
|
|
def __init__(self, driver, asset_name):
|
|
|
|
|
super(AssetCheckBox, self).__init__(driver)
|
2018-07-19 09:57:45 +00:00
|
|
|
|
self.asset_name = asset_name
|
|
|
|
|
self.locator = self.Locator.xpath_selector("//*[@text='%s']/../android.widget.CheckBox" % self.asset_name)
|
|
|
|
|
|
|
|
|
|
def click(self):
|
|
|
|
|
self.scroll_to_element().click()
|
2018-08-15 12:51:52 +00:00
|
|
|
|
self.driver.info('Click %s asset checkbox' % self.asset_name)
|
2018-06-29 17:27:30 +00:00
|
|
|
|
|
2018-05-16 19:59:36 +00:00
|
|
|
|
|
2018-07-03 12:40:44 +00:00
|
|
|
|
class TotalAmountText(BaseText):
|
|
|
|
|
|
|
|
|
|
def __init__(self, driver):
|
|
|
|
|
super(TotalAmountText, self).__init__(driver)
|
|
|
|
|
self.locator = self.Locator.accessibility_id('total-amount-value-text')
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
class CurrencyText(BaseText):
|
|
|
|
|
|
|
|
|
|
def __init__(self, driver):
|
|
|
|
|
super(CurrencyText, self).__init__(driver)
|
|
|
|
|
self.locator = self.Locator.accessibility_id('total-amount-currency-text')
|
|
|
|
|
|
|
|
|
|
|
2018-07-16 12:57:01 +00:00
|
|
|
|
class BackupRecoveryPhrase(BaseButton):
|
2018-07-06 11:10:48 +00:00
|
|
|
|
def __init__(self, driver):
|
2018-07-16 12:57:01 +00:00
|
|
|
|
super(BackupRecoveryPhrase, self).__init__(driver)
|
2018-08-08 15:30:48 +00:00
|
|
|
|
self.locator = self.Locator.text_selector('Backup your recovery phrase')
|
2018-07-06 11:10:48 +00:00
|
|
|
|
|
|
|
|
|
def navigate(self):
|
|
|
|
|
from views.profile_view import ProfileView
|
|
|
|
|
return ProfileView(self.driver)
|
|
|
|
|
|
|
|
|
|
|
2018-01-03 09:34:40 +00:00
|
|
|
|
class WalletView(BaseView):
|
2017-10-19 13:49:20 +00:00
|
|
|
|
def __init__(self, driver):
|
2018-01-03 09:34:40 +00:00
|
|
|
|
super(WalletView, self).__init__(driver)
|
2017-10-19 13:49:20 +00:00
|
|
|
|
self.driver = driver
|
|
|
|
|
|
2018-06-29 17:27:30 +00:00
|
|
|
|
self.send_transaction_button = SendTransactionButton(self.driver)
|
|
|
|
|
self.transaction_history_button = TransactionHistoryButton(self.driver)
|
2018-07-20 08:27:33 +00:00
|
|
|
|
self.eth_asset_value = EthAssetText(self.driver)
|
|
|
|
|
self.stt_asset_value = STTAssetText(self.driver)
|
2017-10-23 20:46:49 +00:00
|
|
|
|
self.usd_total_value = UsdTotalValueText(self.driver)
|
2018-02-09 15:16:07 +00:00
|
|
|
|
|
|
|
|
|
self.send_transaction_request = SendTransactionRequestButton(self.driver)
|
2018-06-29 17:27:30 +00:00
|
|
|
|
self.receive_transaction_button = ReceiveTransactionButton(self.driver)
|
2018-01-03 09:34:40 +00:00
|
|
|
|
|
2017-12-13 13:12:46 +00:00
|
|
|
|
self.send_request_button = SendRequestButton(self.driver)
|
2018-02-09 15:16:07 +00:00
|
|
|
|
self.options_button = OptionsButton(self.driver)
|
|
|
|
|
self.manage_assets_button = ManageAssetsButton(self.driver)
|
|
|
|
|
self.stt_check_box = STTCheckBox(self.driver)
|
|
|
|
|
self.done_button = DoneButton(self.driver)
|
2017-10-23 20:46:49 +00:00
|
|
|
|
|
2018-05-02 16:01:17 +00:00
|
|
|
|
self.qr_code_image = QRCodeImage(self.driver)
|
|
|
|
|
self.address_text = AddressText(self.driver)
|
|
|
|
|
|
2018-05-11 19:15:39 +00:00
|
|
|
|
self.set_up_button = SetUpButton(self.driver)
|
2018-05-16 19:59:36 +00:00
|
|
|
|
self.sign_in_phrase = SignInPhraseText(self.driver)
|
2018-05-11 19:15:39 +00:00
|
|
|
|
|
2018-07-03 12:40:44 +00:00
|
|
|
|
self.total_amount_text = TotalAmountText(self.driver)
|
|
|
|
|
self.currency_text = CurrencyText(self.driver)
|
2018-07-16 12:57:01 +00:00
|
|
|
|
self.backup_recovery_phrase = BackupRecoveryPhrase(self.driver)
|
2018-07-03 12:40:44 +00:00
|
|
|
|
|
2017-10-23 20:46:49 +00:00
|
|
|
|
def get_usd_total_value(self):
|
2018-05-29 14:06:32 +00:00
|
|
|
|
import re
|
2018-08-16 16:47:13 +00:00
|
|
|
|
return float(re.sub('[~,]', '', self.usd_total_value.text))
|
2017-10-23 20:46:49 +00:00
|
|
|
|
|
|
|
|
|
def get_eth_value(self):
|
2018-07-20 08:27:33 +00:00
|
|
|
|
return float(self.eth_asset_value.text)
|
|
|
|
|
|
|
|
|
|
def get_stt_value(self):
|
2018-08-16 16:47:13 +00:00
|
|
|
|
self.stt_asset_value.scroll_to_element()
|
2018-07-20 08:27:33 +00:00
|
|
|
|
return float(self.stt_asset_value.text)
|
2017-10-23 20:46:49 +00:00
|
|
|
|
|
2017-12-27 18:03:57 +00:00
|
|
|
|
def verify_currency_balance(self, expected_rate: int, errors: list):
|
2017-10-23 20:46:49 +00:00
|
|
|
|
usd = self.get_usd_total_value()
|
|
|
|
|
eth = self.get_eth_value()
|
2017-12-27 18:03:57 +00:00
|
|
|
|
expected_usd = round(eth * expected_rate, 2)
|
2017-12-27 18:03:57 +00:00
|
|
|
|
percentage_diff = abs((usd - expected_usd) / ((usd + expected_usd) / 2)) * 100
|
|
|
|
|
if percentage_diff > 2:
|
|
|
|
|
errors.append('Difference between current (%s) and expected (%s) USD balance > 2%%!!' % (usd, expected_usd))
|
2018-01-14 17:43:36 +00:00
|
|
|
|
else:
|
2018-08-15 12:51:52 +00:00
|
|
|
|
self.driver.info('Current USD balance %s is ok' % usd)
|
2018-05-11 19:15:39 +00:00
|
|
|
|
|
2018-06-28 18:46:51 +00:00
|
|
|
|
def wait_balance_changed_on_wallet_screen(self, expected_balance=0.1, wait_time=300):
|
2018-05-16 07:22:02 +00:00
|
|
|
|
counter = 0
|
|
|
|
|
while True:
|
|
|
|
|
if counter >= wait_time:
|
2018-08-15 12:51:52 +00:00
|
|
|
|
self.driver.info('Balance is not changed during %s seconds!' % wait_time)
|
2018-06-29 17:27:30 +00:00
|
|
|
|
return
|
2018-06-28 18:46:51 +00:00
|
|
|
|
elif self.get_eth_value() != 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()
|
2018-08-15 12:51:52 +00:00
|
|
|
|
self.driver.info('Waiting %s seconds for ETH update' % counter)
|
2018-05-16 07:22:02 +00:00
|
|
|
|
else:
|
2018-08-15 12:51:52 +00:00
|
|
|
|
self.driver.info('Transaction received, balance updated!')
|
2018-05-16 07:22:02 +00:00
|
|
|
|
return
|
|
|
|
|
|
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()])
|
|
|
|
|
|
2018-05-11 19:15:39 +00:00
|
|
|
|
def set_up_wallet(self):
|
|
|
|
|
self.set_up_button.click()
|
2018-06-29 17:27:30 +00:00
|
|
|
|
phrase = self.sign_in_phrase.string
|
2018-05-11 19:15:39 +00:00
|
|
|
|
self.done_button.click()
|
|
|
|
|
self.yes_button.click()
|
2018-05-16 19:59:36 +00:00
|
|
|
|
return phrase
|
2018-06-29 17:27:30 +00:00
|
|
|
|
|
|
|
|
|
def get_wallet_address(self):
|
|
|
|
|
self.receive_transaction_button.click()
|
|
|
|
|
address = self.address_text.text
|
|
|
|
|
self.back_button.click()
|
|
|
|
|
return address
|
|
|
|
|
|
|
|
|
|
def asset_by_name(self, asset_name):
|
|
|
|
|
return AssetTextElement(self.driver, asset_name)
|
|
|
|
|
|
|
|
|
|
def asset_checkbox_by_name(self, asset_name):
|
|
|
|
|
return AssetCheckBox(self.driver, asset_name)
|
2018-11-13 08:25:55 +00:00
|
|
|
|
|
|
|
|
|
def send_transaction(self, **kwargs):
|
|
|
|
|
send_transaction_view = self.send_transaction_button.click()
|
|
|
|
|
send_transaction_view.select_asset_button.click()
|
2018-11-20 14:56:44 +00:00
|
|
|
|
asset_name = kwargs.get('asset_name', 'ETHro').upper()
|
2018-11-13 08:25:55 +00:00
|
|
|
|
asset_button = send_transaction_view.asset_by_name(asset_name)
|
|
|
|
|
send_transaction_view.select_asset_button.click_until_presence_of_element(asset_button)
|
|
|
|
|
asset_button.click()
|
|
|
|
|
send_transaction_view.amount_edit_box.click()
|
|
|
|
|
|
|
|
|
|
transaction_amount = str(kwargs.get('amount')) if kwargs.get('amount') else \
|
|
|
|
|
send_transaction_view.get_unique_amount()
|
|
|
|
|
|
|
|
|
|
send_transaction_view.amount_edit_box.set_value(transaction_amount)
|
|
|
|
|
send_transaction_view.confirm()
|
|
|
|
|
send_transaction_view.chose_recipient_button.click()
|
|
|
|
|
|
|
|
|
|
recipient = kwargs.get('recipient')
|
|
|
|
|
|
|
|
|
|
if '0x' in recipient:
|
|
|
|
|
send_transaction_view.enter_recipient_address_button.click()
|
|
|
|
|
send_transaction_view.enter_recipient_address_input.set_value(recipient)
|
|
|
|
|
send_transaction_view.done_button.click()
|
|
|
|
|
else:
|
|
|
|
|
send_transaction_view.recent_recipients_button.click()
|
|
|
|
|
recent_recipient = send_transaction_view.element_by_text(recipient)
|
|
|
|
|
send_transaction_view.recent_recipients_button.click_until_presence_of_element(recent_recipient)
|
|
|
|
|
recent_recipient.click()
|
|
|
|
|
send_transaction_view.sign_transaction()
|
|
|
|
|
|
|
|
|
|
def receive_transaction(self, **kwargs):
|
|
|
|
|
self.receive_transaction_button.click()
|
|
|
|
|
send_transaction_view = self.send_transaction_request.click()
|
|
|
|
|
send_transaction_view.select_asset_button.click()
|
2018-11-20 14:56:44 +00:00
|
|
|
|
asset_name = kwargs.get('asset_name', 'ETHro').upper()
|
2018-11-13 08:25:55 +00:00
|
|
|
|
asset_button = send_transaction_view.asset_by_name(asset_name)
|
|
|
|
|
send_transaction_view.select_asset_button.click_until_presence_of_element(asset_button)
|
|
|
|
|
asset_button.click()
|
|
|
|
|
send_transaction_view.amount_edit_box.click()
|
|
|
|
|
|
|
|
|
|
transaction_amount = str(kwargs.get('amount')) if kwargs.get('amount') else \
|
|
|
|
|
send_transaction_view.get_unique_amount()
|
|
|
|
|
|
|
|
|
|
send_transaction_view.amount_edit_box.set_value(transaction_amount)
|
|
|
|
|
send_transaction_view.confirm()
|
|
|
|
|
send_transaction_view.chose_recipient_button.click()
|
|
|
|
|
|
|
|
|
|
recipient = kwargs.get('recipient')
|
|
|
|
|
send_transaction_view.recent_recipients_button.click()
|
|
|
|
|
recent_recipient = send_transaction_view.element_by_text(recipient)
|
|
|
|
|
send_transaction_view.recent_recipients_button.click_until_presence_of_element(recent_recipient)
|
|
|
|
|
recent_recipient.click()
|
|
|
|
|
self.send_request_button.click()
|
2018-11-09 12:36:21 +00:00
|
|
|
|
|
|
|
|
|
def collectible_amount_by_name(self, name):
|
|
|
|
|
elm = CollectibleTextElement(self.driver, name)
|
|
|
|
|
return elm.text
|