2021-01-25 16:35:40 +00:00
|
|
|
from views.web_views.base_web_view import BaseWebView, Button
|
2019-05-17 14:40:35 +00:00
|
|
|
import time
|
2018-05-14 14:56:21 +00:00
|
|
|
|
2021-01-25 16:35:40 +00:00
|
|
|
class RequestSTTButton(Button):
|
2018-05-14 14:56:21 +00:00
|
|
|
def __init__(self, driver):
|
2021-01-25 16:35:40 +00:00
|
|
|
super(RequestSTTButton, self).__init__(driver, webview="Request STT")
|
2018-06-04 10:31:45 +00:00
|
|
|
|
2021-01-25 16:35:40 +00:00
|
|
|
def navigate(self):
|
|
|
|
from views.send_transaction_view import SendTransactionView
|
|
|
|
return SendTransactionView(self.driver)
|
2018-06-04 10:31:45 +00:00
|
|
|
|
|
|
|
|
2021-01-25 16:35:40 +00:00
|
|
|
class TransactionsButton(Button):
|
2018-06-04 10:31:45 +00:00
|
|
|
def __init__(self, driver):
|
2021-01-25 16:35:40 +00:00
|
|
|
super().__init__(driver, xpath="//*[@text='Transactions']")
|
2018-06-04 10:31:45 +00:00
|
|
|
|
2021-01-25 16:35:40 +00:00
|
|
|
class SignMessageButton(Button):
|
2018-06-04 10:31:45 +00:00
|
|
|
def __init__(self, driver):
|
2021-01-25 16:35:40 +00:00
|
|
|
super().__init__(driver, xpath="//*[@text='Sign message']")
|
2018-06-04 10:31:45 +00:00
|
|
|
|
2020-05-14 10:41:09 +00:00
|
|
|
def click(self):
|
2021-01-25 16:35:40 +00:00
|
|
|
from views.base_element import Text
|
|
|
|
self.click_until_presence_of_element(Text(self.driver, translation_id="signing-phrase"))
|
2020-05-14 10:41:09 +00:00
|
|
|
return self.navigate()
|
|
|
|
|
2018-06-04 10:31:45 +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 SignTypedMessageButton(Button):
|
2019-03-26 12:09:29 +00:00
|
|
|
def __init__(self, driver):
|
2021-01-25 16:35:40 +00:00
|
|
|
super().__init__(driver, xpath="//*[@text='Sign Typed Message']")
|
2019-03-26 12:09:29 +00:00
|
|
|
|
2020-05-14 10:41:09 +00:00
|
|
|
def click(self):
|
2021-01-25 16:35:40 +00:00
|
|
|
from views.base_element import Text
|
|
|
|
self.click_until_presence_of_element(Text(self.driver, translation_id="signing-phrase"))
|
2020-05-14 10:41:09 +00:00
|
|
|
return self.navigate()
|
|
|
|
|
2019-03-26 12:09:29 +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 DeployContractButton(Button):
|
2018-07-13 10:56:36 +00:00
|
|
|
def __init__(self, driver):
|
2021-01-25 16:35:40 +00:00
|
|
|
super().__init__(driver, xpath="//*[@text='Deploy simple contract']")
|
2018-07-13 10:56:36 +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 SendTwoTxOneByOneButton(Button):
|
2019-02-18 08:12:55 +00:00
|
|
|
def __init__(self, driver):
|
2021-01-25 16:35:40 +00:00
|
|
|
super().__init__(driver, webview="Send two Txs, one after another, 0.00001 and 0.00002 ETH")
|
2019-02-18 08:12:55 +00:00
|
|
|
|
|
|
|
def navigate(self):
|
|
|
|
from views.send_transaction_view import SendTransactionView
|
|
|
|
return SendTransactionView(self.driver)
|
|
|
|
|
2019-05-07 15:21:30 +00:00
|
|
|
def click(self):
|
2019-05-17 14:40:35 +00:00
|
|
|
self.swipe_to_web_element()
|
|
|
|
time.sleep(2)
|
2019-05-08 15:40:08 +00:00
|
|
|
self.wait_for_visibility_of_element().click()
|
2019-05-07 15:21:30 +00:00
|
|
|
return self.navigate()
|
|
|
|
|
2021-01-25 16:35:40 +00:00
|
|
|
class SendTwoTxInBatchButton(Button):
|
2019-02-18 08:12:55 +00:00
|
|
|
def __init__(self, driver):
|
2021-01-25 16:35:40 +00:00
|
|
|
super().__init__(driver, xpath="//*[@text='Send two Txs in batch, 0.00001 and 0.00002 ETH']")
|
2019-02-18 08:12:55 +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 TestFiltersButton(Button):
|
2018-07-13 10:56:36 +00:00
|
|
|
def __init__(self, driver):
|
2021-01-25 16:35:40 +00:00
|
|
|
super().__init__(driver, xpath="//*[@text='Test filters']")
|
2018-05-14 14:56:21 +00:00
|
|
|
|
2018-07-26 18:58:05 +00:00
|
|
|
|
2021-01-25 16:35:40 +00:00
|
|
|
class StatusAPIButton(Button):
|
2018-07-26 18:58:05 +00:00
|
|
|
def __init__(self, driver):
|
2021-01-25 16:35:40 +00:00
|
|
|
super().__init__(driver, xpath="//*[@text='%s']")
|
2018-07-26 18:58:05 +00:00
|
|
|
|
2019-05-07 15:21:30 +00:00
|
|
|
def click(self):
|
|
|
|
self.wait_for_visibility_of_element().click()
|
|
|
|
|
2018-07-26 18:58:05 +00:00
|
|
|
|
2021-01-25 16:35:40 +00:00
|
|
|
class SendOneTransactionInBatchButton(Button):
|
2018-11-26 14:06:34 +00:00
|
|
|
def __init__(self, driver):
|
2021-01-25 16:35:40 +00:00
|
|
|
super().__init__(driver, xpath="//*[@text='Send one Tx in batch']")
|
2018-11-26 14:06:34 +00:00
|
|
|
|
|
|
|
def navigate(self):
|
|
|
|
from views.send_transaction_view import SendTransactionView
|
|
|
|
return SendTransactionView(self.driver)
|
|
|
|
|
|
|
|
|
2018-05-25 17:29:07 +00:00
|
|
|
class StatusTestDAppView(BaseWebView):
|
2018-05-14 14:56:21 +00:00
|
|
|
|
|
|
|
def __init__(self, driver):
|
2018-05-25 17:29:07 +00:00
|
|
|
super(StatusTestDAppView, self).__init__(driver)
|
2018-05-14 14:56:21 +00:00
|
|
|
self.driver = driver
|
|
|
|
|
2021-01-25 16:35:40 +00:00
|
|
|
self.assets_button = Button(self.driver, webview="Assets")
|
|
|
|
self.request_eth_button = Button(self.driver, webview="Request Ropsten ETH")
|
|
|
|
self.request_stt_button = RequestSTTButton(self.driver)
|
2018-06-04 10:31:45 +00:00
|
|
|
|
|
|
|
self.transactions_button = TransactionsButton(self.driver)
|
|
|
|
self.sign_message_button = TransactionsButton.SignMessageButton(self.driver)
|
2018-07-13 10:56:36 +00:00
|
|
|
self.deploy_contract_button = TransactionsButton.DeployContractButton(self.driver)
|
2018-11-26 14:06:34 +00:00
|
|
|
self.send_one_tx_in_batch_button = SendOneTransactionInBatchButton(self.driver)
|
2019-02-18 08:12:55 +00:00
|
|
|
self.send_two_tx_one_by_one_button = TransactionsButton.SendTwoTxOneByOneButton(self.driver)
|
|
|
|
self.send_two_tx_in_batch_button = TransactionsButton.SendTwoTxInBatchButton(self.driver)
|
2018-07-13 10:56:36 +00:00
|
|
|
self.test_filters_button = TransactionsButton.TestFiltersButton(self.driver)
|
2019-03-26 12:09:29 +00:00
|
|
|
self.sign_typed_message_button = TransactionsButton.SignTypedMessageButton(self.driver)
|
2018-07-26 18:58:05 +00:00
|
|
|
|
|
|
|
self.status_api_button = StatusAPIButton(self.driver)
|
2021-01-25 16:35:40 +00:00
|
|
|
self.request_contact_code_button = Button(self.driver, xpath="//*[contains(text(),'Request contact code']")
|
2018-11-07 13:09:23 +00:00
|
|
|
|
|
|
|
def wait_for_d_aap_to_load(self, wait_time=10):
|
2021-01-25 16:35:40 +00:00
|
|
|
self.driver.info("**Wait %ss for assets in simpledapp**" % wait_time)
|
2018-11-07 13:09:23 +00:00
|
|
|
self.assets_button.wait_for_visibility_of_element(seconds=wait_time)
|
2018-11-26 14:06:34 +00:00
|
|
|
|
|
|
|
def faucet_asset(self, asset='eth'):
|
2021-01-25 16:35:40 +00:00
|
|
|
self.driver.info("**Faucet %s in dapp**" % asset)
|
2018-11-26 14:06:34 +00:00
|
|
|
self.wait_for_d_aap_to_load()
|
|
|
|
self.assets_button.click()
|
|
|
|
if asset == 'eth':
|
|
|
|
self.request_eth_button.click()
|
|
|
|
self.element_by_text('Faucet request recieved').wait_for_visibility_of_element()
|
|
|
|
self.ok_button.click()
|
|
|
|
self.element_by_text('Faucet request recieved').wait_for_invisibility_of_element()
|
|
|
|
elif asset == 'stt':
|
|
|
|
send_transaction_view = self.request_stt_button.click()
|
|
|
|
send_transaction_view.sign_transaction()
|