2017-10-23 20:46:49 +00:00
|
|
|
import logging
|
|
|
|
|
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-01-14 17:43:36 +00:00
|
|
|
self.locator = self.Locator.xpath_selector("//*[@text='Send transaction']")
|
|
|
|
|
|
|
|
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-01-14 17:43:36 +00:00
|
|
|
self.locator = self.Locator.xpath_selector("//*[@text='Receive transaction']")
|
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)
|
|
|
|
self.locator = self.Locator.xpath_selector("//*[@text='SEND REQUEST']")
|
|
|
|
|
|
|
|
|
2017-10-19 13:49:20 +00:00
|
|
|
class ChooseRecipientButton(BaseButton):
|
|
|
|
|
|
|
|
def __init__(self, driver):
|
|
|
|
super(ChooseRecipientButton, self).__init__(driver)
|
|
|
|
self.locator = self.Locator.xpath_selector("//*[@text='Choose recipient...']")
|
|
|
|
|
|
|
|
|
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-01-14 17:43:36 +00:00
|
|
|
self.locator = self.Locator.xpath_selector("//*[@text='Transaction History']")
|
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-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)
|
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)
|
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:
|
|
|
|
logging.info('Current USD balance %s is ok' % usd)
|