2018-01-26 11:07:09 +00:00
|
|
|
from tests import info
|
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
|
|
|
|
|
|
|
|
|
|
|
class SendButton(BaseButton):
|
|
|
|
|
|
|
|
def __init__(self, driver):
|
|
|
|
super(SendButton, 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
|
|
|
|
|
|
|
|
2017-12-13 13:12:46 +00:00
|
|
|
class RequestButton(BaseButton):
|
|
|
|
|
|
|
|
def __init__(self, driver):
|
|
|
|
super(RequestButton, 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
|
|
|
|
|
|
|
|
2017-10-23 20:46:49 +00:00
|
|
|
class TransactionsButton(BaseButton):
|
2017-10-19 13:49:20 +00:00
|
|
|
|
|
|
|
def __init__(self, driver):
|
2017-10-23 20:46:49 +00:00
|
|
|
super(TransactionsButton, 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)
|
|
|
|
self.locator = self.Locator.xpath_selector("//*[@text='ETH']/../android.widget.TextView[1]")
|
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)
|
|
|
|
self.locator = self.Locator.xpath_selector("//*[@text='USD']/../android.widget.TextView[1]")
|
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
|
|
|
|
|
|
|
|
|
|
|
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-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
|
|
|
|
|
|
|
|
self.send_button = SendButton(self.driver)
|
2017-10-23 20:46:49 +00:00
|
|
|
self.transactions_button = TransactionsButton(self.driver)
|
|
|
|
self.eth_asset = EthAssetText(self.driver)
|
|
|
|
self.usd_total_value = UsdTotalValueText(self.driver)
|
2018-02-09 15:16:07 +00:00
|
|
|
|
|
|
|
self.send_transaction_request = SendTransactionRequestButton(self.driver)
|
2017-12-13 13:12:46 +00:00
|
|
|
self.request_button = RequestButton(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)
|
|
|
|
|
2017-10-23 20:46:49 +00:00
|
|
|
def get_usd_total_value(self):
|
|
|
|
return float(self.usd_total_value.text)
|
|
|
|
|
|
|
|
def get_eth_value(self):
|
|
|
|
return float(self.eth_asset.text)
|
|
|
|
|
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-01-26 11:07:09 +00:00
|
|
|
info('Current USD balance %s is ok' % usd)
|