e2e: txs fix + color match

Signed-off-by: Churikova Tetiana <churikova.tm@gmail.com>
This commit is contained in:
Churikova Tetiana 2021-06-08 12:58:26 +02:00
parent ffb5fac6f7
commit 63290fd019
No known key found for this signature in database
GPG Key ID: 0D4EA7B33B47E6D8
16 changed files with 66 additions and 54 deletions

View File

@ -64,15 +64,12 @@ class NetworkApi(object):
method = self.network_url + 'module=proxy&action=eth_blockNumber'
return int(requests.request('GET', url=method).json()['result'], 0)
def find_transaction_by_hash(self, address: str, transaction_hash: str):
transactions = self.get_transactions(address=address)
for transaction in transactions:
if transaction['hash'] == transaction_hash:
logging.info('Transaction is found in Ropsten network')
return
pytest.fail('Transaction is not found in Ropsten network')
def find_transaction_by_hash(self,transaction_hash: str):
transaction = w3.transaction_status(transaction_hash)
if not transaction['blockHash']:
self.log("TX %s is still pending" %transaction_hash)
def find_transaction_by_unique_amount(self, address, amount, token=False, decimals=18, wait_time=600):
def find_transaction_by_unique_amount(self, address, amount, token=False, decimals=18, wait_time=300):
additional_info = 'token transactions' if token else 'ETH transactions'
counter = 0
while True:
@ -84,13 +81,14 @@ class NetworkApi(object):
'Transaction with amount %s is not found in list of %s, address is %s during %ss' %
(amount, additional_info, address, wait_time))
else:
counter += 30
time.sleep(30)
self.log("Finding tx in %s, attempt #%s" % (additional_info, str(int(counter / 30)+1)))
try:
if token:
transactions = self.get_token_transactions(address)
else:
transactions = self.get_transactions(address)
counter += 30
time.sleep(30)
except JSONDecodeError as e:
self.log("No valid JSON response from Etherscan: %s " % str(e))
continue
@ -101,16 +99,15 @@ class NetworkApi(object):
except TypeError as e:
self.log("Failed iterate transactions: " + str(e))
pytest.fail("No valid JSON response from Etherscan: %s " % str(e))
# continue
def wait_for_confirmation_of_transaction(self, address, amount, confirmations=12, token=False):
def wait_for_confirmation_of_transaction(self, address, amount, confirmations=3, token=False):
start_time = time.time()
if token:
token_info = "token transaction"
else:
token_info = "ETH transaction"
self.log('Waiting %s %s for %s to have %s confirmations' % (amount, token_info, address, confirmations))
while round(time.time() - start_time, ndigits=2) < 900: # should be < idleTimeout capability
while round(time.time() - start_time, ndigits=2) < 600: # should be < idleTimeout capability
transaction = self.find_transaction_by_unique_amount(address, amount, token)
self.log(
'Expected amount of confirmations is %s, in fact %s' % (confirmations, transaction['confirmations']))

View File

@ -74,8 +74,7 @@ def balance_of_address(address):
return w3.eth.getBalance(to_checksum_address(address))
def transaction_status(hash):
return w3.eth.getTransaction(transaction_hash=hash)
return w3.eth.getTransaction(hash)
def to_checksumed_address(address):
return to_checksum_address(address)

View File

@ -389,6 +389,7 @@ class TestCreateAccount(SingleDeviceTestCase):
sign_in.just_fyi('Send transaction from added account and log out')
transaction_amount_added = wallet_view.get_unique_amount()
wallet_view.send_transaction(amount=transaction_amount_added, recipient=recipient, sign_transaction=True)
wallet_view.accounts_status_account.click()
wallet_view.profile_button.click()
profile_view.logout()

View File

@ -696,6 +696,7 @@ class TestProfileMultipleDevice(MultipleDeviceTestCase):
profile_2.home_button.click(desired_view='home')
if not home_2.get_chat(default_username_1).chat_image.is_element_image_similar_to_template('sauce_logo.png'):
self.errors.append('User profile picture is not returned to default after user removed from Contacts')
self.errors.verify_no_errors()
@marks.testrail_id(5432)
@marks.medium

View File

@ -68,7 +68,7 @@ class TestCommandsMultipleDevices(MultipleDeviceTestCase):
time.sleep(20)
send_bottom_sheet = sender_message.sign_and_send.click()
send_bottom_sheet.next_button.click()
send_bottom_sheet.sign_transaction(default_gas_price=False)
send_bottom_sheet.sign_transaction()
updated_timestamp_sender = sender_message.timestamp_message.text
if updated_timestamp_sender == timestamp_sender:
self.errors.append("Timestamp of message is not updated after signing transaction")
@ -147,11 +147,11 @@ class TestCommandsMultipleDevices(MultipleDeviceTestCase):
chat_2_sender_message.transaction_status.wait_for_element_text(chat_2_sender_message.address_received)
send_message = chat_2_sender_message.sign_and_send.click()
send_message.next_button.click()
send_message.sign_transaction(default_gas_price=False)
send_message.sign_transaction()
home_2.just_fyi('Check that transaction message is updated with new status after offline')
chat_2.toggle_airplane_mode()
self.network_api.wait_for_confirmation_of_transaction(sender['address'], amount, confirmations=12, token=True)
self.network_api.wait_for_confirmation_of_transaction(sender['address'], amount, token=True)
chat_2.toggle_airplane_mode()
[message.transaction_status.wait_for_element_text(message.confirmed, wait_time=60) for message in
(chat_2_sender_message, chat_1_request_message)]
@ -218,6 +218,9 @@ class TestCommandsMultipleDevices(MultipleDeviceTestCase):
device_1_sign_in.recover_access(passphrase=sender['passphrase'])
device_2_sign_in.create_user()
home_1, home_2 = device_1_sign_in.get_home_view(), device_2_sign_in.get_home_view()
wallet_1 = home_1.wallet_button.click()
wallet_1.set_up_wallet()
wallet_1.home_button.click()
profile_2 = home_2.profile_button.click()
device_2_username = profile_2.default_username_text.text
profile_2.switch_network()
@ -245,7 +248,7 @@ class TestCommandsMultipleDevices(MultipleDeviceTestCase):
send_message = chat_1_sender_message.sign_and_send.click()
send_message.next_button.click()
send_message.sign_transaction()
self.network_api.wait_for_confirmation_of_transaction(sender['address'], amount, confirmations=15)
self.network_api.wait_for_confirmation_of_transaction(sender['address'], amount)
chat_1_sender_message.transaction_status.wait_for_element_text(chat_1_sender_message.confirmed)
wallet_2 = chat_2.wallet_button.click()
wallet_2.set_up_wallet()
@ -277,7 +280,7 @@ class TestCommandsSingleDevices(SingleDeviceTestCase):
from views.send_transaction_view import SendTransactionView
send_transaction = SendTransactionView(self.driver)
send_transaction.ok_got_it_button.click()
send_transaction.sign_transaction(default_gas_price=False)
send_transaction.sign_transaction()
chat_sender_message = chat.get_outgoing_transaction()
self.network_api.wait_for_confirmation_of_transaction(sender['address'], amount, confirmations=15)
self.network_api.wait_for_confirmation_of_transaction(sender['address'], amount)
chat_sender_message.transaction_status.wait_for_element_text(chat_sender_message.confirmed)

View File

@ -63,7 +63,7 @@ class TestCommandsMultipleDevices(MultipleDeviceTestCase):
time.sleep(20)
send_message = sender_message.sign_and_send.click()
send_message.next_button.click()
send_message.sign_transaction(keycard=True, default_gas_price=False)
send_message.sign_transaction(keycard=True)
updated_timestamp_sender = sender_message.timestamp_message.text
if updated_timestamp_sender == timestamp_sender:
self.errors.append("Timestamp of message is not updated after signing transaction")
@ -142,7 +142,7 @@ class TestCommandsMultipleDevices(MultipleDeviceTestCase):
chat_2_sender_message.transaction_status.wait_for_element_text(chat_2_sender_message.address_received)
send_message = chat_2_sender_message.sign_and_send.click()
send_message.next_button.click()
send_message.sign_transaction(keycard=True, default_gas_price=False)
send_message.sign_transaction(keycard=True)
home_2.just_fyi('Check that transaction message is updated with new status after offline')
chat_2.toggle_airplane_mode()
@ -162,6 +162,10 @@ class TestCommandsSingleDevices(SingleDeviceTestCase):
sign_in = SignInView(self.driver)
sender = transaction_senders['E']
home = sign_in.recover_access(sender['passphrase'], keycard=True)
wallet = home.wallet_button.click()
wallet.set_up_wallet()
wallet.home_button.click()
chat = home.add_contact(ens_user_ropsten['ens'])
chat.commands_button.click()
amount = chat.get_unique_amount()
@ -175,5 +179,5 @@ class TestCommandsSingleDevices(SingleDeviceTestCase):
send_transaction = SendTransactionView(self.driver)
send_transaction.sign_transaction(keycard=True)
chat_sender_message = chat.get_outgoing_transaction()
self.network_api.wait_for_confirmation_of_transaction(sender['address'], amount, confirmations=15)
self.network_api.wait_for_confirmation_of_transaction(sender['address'], amount)
chat_sender_message.transaction_status.wait_for_element_text(chat_sender_message.confirmed)

View File

@ -117,7 +117,7 @@ class TestTransactionDApp(SingleDeviceTestCase):
home.just_fyi("Checking deploy simple contract")
send_transaction = status_test_dapp.deploy_contract_button.click()
send_transaction.sign_transaction(default_gas_price=False)
send_transaction.sign_transaction(default_gas_price=True)
if not status_test_dapp.element_by_text('Contract deployed at: ').is_element_displayed(180):
self.errors.append('Contract was not created')
for text in ['Call contract get function',

View File

@ -98,9 +98,9 @@ class TestTransactionDApp(SingleDeviceTestCase):
wallet.just_fyi("Checking deploy simple contract")
send_transaction_view = status_test_dapp.deploy_contract_button.click()
send_transaction_view.sign_transaction(keycard=True, default_gas_price=False)
if not status_test_dapp.element_by_text('Contract deployed at: ').is_element_displayed(180):
self.errors.append('Contract was not created')
send_transaction_view.sign_transaction(keycard=True)
if not status_test_dapp.element_by_text('Contract deployed at: ').is_element_displayed(300):
self.driver.fail('Contract was not created or tx taking too long')
for text in ['Call contract get function',
'Call contract set function', 'Call function 2 times in a row']:
status_test_dapp.element_by_text(text).scroll_to_element()

View File

@ -23,15 +23,10 @@ class TestTransactionWalletSingleDevice(SingleDeviceTestCase):
sign_transaction=True,
keycard=True,
recipient='0x%s'%recipient['address'])
self.network_api.find_transaction_by_unique_amount(sender['address'], transaction_amount)
wallet_view.just_fyi('Check that transaction is appeared in transaction history')
wallet_view.find_transaction_in_history(amount=transaction_amount)
wallet_view.just_fyi('Check logcat for sensitive data')
values_in_logcat = wallet_view.find_values_in_logcat(pin=pin, puk=puk, password=pair_code)
if values_in_logcat:
self.driver.fail(values_in_logcat)
transaction = wallet_view.find_transaction_in_history(amount=transaction_amount, return_hash=True)
self.network_api.find_transaction_by_hash(transaction)
@marks.testrail_id(6290)
@ -50,7 +45,7 @@ class TestTransactionWalletSingleDevice(SingleDeviceTestCase):
sign_in_view.just_fyi('Go back to online and check that balance is updated')
sign_in_view.toggle_airplane_mode()
wallet_view.wait_balance_is_changed('ETH')
wallet_view.scan_tokens('STT')
wallet_view.wait_balance_is_changed('STT')
sign_in_view.just_fyi('Send some tokens to other account')
recipient = "0x" + basic_user['address']
@ -61,7 +56,7 @@ class TestTransactionWalletSingleDevice(SingleDeviceTestCase):
wallet_view.send_transaction(asset_name=asset, amount=sending_amount, recipient=recipient,
sign_transaction=True, keycard=True)
sign_in_view.toggle_airplane_mode()
self.network_api.wait_for_confirmation_of_transaction(basic_user['address'], sending_amount, confirmations=6, token=True)
self.network_api.wait_for_confirmation_of_transaction(basic_user['address'], sending_amount, token=True)
sign_in_view.just_fyi('Change that balance is updated and transaction is appeared in history')
@ -117,7 +112,7 @@ class TestTransactionWalletSingleDevice(SingleDeviceTestCase):
wallet_view.just_fyi("Send transaction to new account")
wallet_view.accounts_status_account.click()
transaction_amount = '0.002'
transaction_amount = '0.004'
initial_balance = self.network_api.get_balance(status_account_address)
send_transaction = wallet_view.send_transaction(account_name=account_name,
amount=transaction_amount,
@ -138,7 +133,7 @@ class TestTransactionWalletSingleDevice(SingleDeviceTestCase):
wallet_view.just_fyi("Sending eth from new account to main account")
updated_balance = self.network_api.get_balance(status_account_address)
transaction_amount_1 = round(float(transaction_amount) * 0.1, 11)
transaction_amount_1 = round(float(transaction_amount) * 0.2, 11)
wallet_view.wait_balance_is_changed()
wallet_view.get_account_by_name(account_name).click()
send_transaction = wallet_view.send_transaction(account_name=wallet_view.status_account_name,
@ -155,7 +150,7 @@ class TestTransactionWalletSingleDevice(SingleDeviceTestCase):
self.network_api.verify_balance_is_updated(updated_balance, status_account_address)
wallet_view.just_fyi("Verify total ETH on main wallet view")
self.network_api.wait_for_confirmation_of_transaction(status_account_address, transaction_amount_1, 3)
self.network_api.wait_for_confirmation_of_transaction(status_account_address, transaction_amount_1)
self.network_api.verify_balance_is_updated((updated_balance + transaction_amount_1), status_account_address)
send_transaction.back_button.click()
balance_of_sub_account = float(self.network_api.get_balance(sub_account_address)) / 1000000000000000000
@ -181,6 +176,6 @@ class TestTransactionWalletSingleDevice(SingleDeviceTestCase):
send_transaction.accounts_button.click()
send_transaction.element_by_text(wallet_view.status_account_name).click()
send_transaction.sign_transaction_button.click()
send_transaction.sign_transaction(keycard=True)
send_transaction.sign_transaction(keycard=True, default_gas_price=True)
wallet_view.element_by_text('Assets').click()
wallet_view.wait_balance_is_equal_expected_amount(asset='ETH', expected_balance=0)

View File

@ -78,7 +78,7 @@ class TestTransactionWalletSingleDevice(SingleDeviceTestCase):
wallet_view.send_transaction(asset_name=asset, amount=sending_amount, recipient=recipient,
sign_transaction=True)
sign_in_view.toggle_airplane_mode()
self.network_api.wait_for_confirmation_of_transaction(basic_user['address'], sending_amount, confirmations=6, token=True)
self.network_api.wait_for_confirmation_of_transaction(basic_user['address'], sending_amount, token=True)
sign_in_view.just_fyi('Change that balance is updated')
sign_in_view.toggle_airplane_mode()
@ -125,7 +125,8 @@ class TestTransactionWalletSingleDevice(SingleDeviceTestCase):
wallet_view.send_transaction(amount=amount,
recipient='0x%s' % recipient['address'],
asset_name='ADI')
self.network_api.find_transaction_by_unique_amount(recipient['address'], amount, token=True, decimals=7)
transaction = wallet_view.find_transaction_in_history(amount=amount, asset='ADI', return_hash=True)
self.network_api.find_transaction_by_hash(transaction)
@marks.testrail_id(5412)
@ -250,7 +251,7 @@ class TestTransactionWalletSingleDevice(SingleDeviceTestCase):
wallet_view.accounts_status_account.click()
initial_balance = self.network_api.get_balance(status_account_address)
transaction_amount = '0.000%s' % str(random.randint(10000, 99999)) + '1'
transaction_amount = '0.003%s' % str(random.randint(10000, 99999)) + '1'
wallet_view.send_transaction(account_name=account_name,
amount=transaction_amount)
self.network_api.wait_for_confirmation_of_transaction(status_account_address, transaction_amount)
@ -269,7 +270,7 @@ class TestTransactionWalletSingleDevice(SingleDeviceTestCase):
wallet_view.just_fyi("Sending eth from new account to main account")
updated_balance = self.network_api.get_balance(status_account_address)
transaction_amount_1 = round(float(transaction_amount) * 0.1, 12)
transaction_amount_1 = round(float(transaction_amount) * 0.2, 12)
send_transaction = wallet_view.send_transaction(account_name=wallet_view.status_account_name,
amount=transaction_amount_1,
default_gas_price=True)
@ -284,7 +285,7 @@ class TestTransactionWalletSingleDevice(SingleDeviceTestCase):
self.network_api.verify_balance_is_updated(updated_balance, status_account_address)
wallet_view.just_fyi("Verify total ETH on main wallet view")
self.network_api.wait_for_confirmation_of_transaction(status_account_address, transaction_amount_1, 3)
self.network_api.wait_for_confirmation_of_transaction(status_account_address, transaction_amount_1)
self.network_api.verify_balance_is_updated((updated_balance + transaction_amount_1), status_account_address)
send_transaction.back_button.click()
balance_of_sub_account = float(self.network_api.get_balance(sub_account_address)) / 1000000000000000000
@ -701,7 +702,7 @@ class TestTransactionWalletMultipleDevice(MultipleDeviceTestCase):
device_1.just_fyi("Sending token amount to device who will use Set Max option for token")
amount = '0.012345678912345678'
wallet_view_serder.accounts_status_account.click()
wallet_view_serder.send_transaction(asset_name='STT', amount=amount, recipient=receiver['address'], default_gas_price=False)
wallet_view_serder.send_transaction(asset_name='STT', amount=amount, recipient=receiver['address'])
wallet_view_receiver.wait_balance_is_changed(asset='STT', initial_balance=initial_balance, scan_tokens=True)
wallet_view_receiver.accounts_status_account.click()
@ -716,7 +717,7 @@ class TestTransactionWalletMultipleDevice(MultipleDeviceTestCase):
send_transaction_view.set_max_button.click()
send_transaction_view.set_recipient_address(sender['address'])
send_transaction_view.sign_transaction_button.click()
send_transaction_view.sign_transaction(default_gas_price=False)
send_transaction_view.sign_transaction()
wallet_view_receiver.back_button.click()
initial_balance = float(initial_balance) + float(amount)
wallet_view_receiver.wait_balance_is_changed(asset='STT', initial_balance=str(initial_balance), scan_tokens=True)

View File

@ -455,6 +455,10 @@ class BaseView(object):
from views.profile_view import ProfileView
return ProfileView(self.driver)
def get_transaction_view(self):
from views.transactions_view import TransactionsView
return TransactionsView(self.driver)
def get_wallet_view(self):
from views.wallet_view import WalletView
return WalletView(self.driver)

Binary file not shown.

Before

Width:  |  Height:  |  Size: 383 B

After

Width:  |  Height:  |  Size: 390 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 3.5 KiB

View File

@ -134,7 +134,7 @@ class SendTransactionView(BaseView):
self.enter_recipient_address_input.click()
self.done_button.click_until_absense_of_element(self.done_button)
def sign_transaction(self, sender_password: str = common_password, keycard=False, default_gas_price=True):
def sign_transaction(self, sender_password: str = common_password, keycard=False, default_gas_price=False):
self.driver.info("**Signing transaction (keycard:%s, default_gas_price:%s)**" % (str(keycard), str(default_gas_price)))
if not default_gas_price:
self.network_fee_button.click()

View File

@ -1,4 +1,3 @@
import time
from selenium.common.exceptions import NoSuchElementException
from views.base_element import BaseElement, Button, Text
from views.base_view import BaseView
@ -79,6 +78,7 @@ class TransactionTable(BaseElement):
self.driver.info('**Finding transaction by index %s**' % index)
return self.TransactionElement.by_index(self.driver, index=index)
def transaction_by_amount(self, amount: str, asset):
self.driver.info('**Finding transaction by amount %s**' % amount)
return self.TransactionElement.by_amount(self.driver, amount=amount.replace(',', '.'), asset=asset)

View File

@ -44,7 +44,8 @@ class AccountElementButton(SilentButton):
def color_matches(self, expected_color_image_name: str):
amount_text = Text(self.driver, xpath="%s//*[@content-desc='account-total-value']" % self.locator)
return amount_text.is_element_image_equals_template(expected_color_image_name)
amount_text.wait_for_element_text('0', 60)
return not amount_text.is_element_differs_from_template(expected_color_image_name)
class SendTransactionButton(Button):
@ -280,11 +281,10 @@ class WalletView(BaseView):
if kwargs.get('sign_transaction', True):
send_transaction_view.sign_transaction_button.click_until_presence_of_element(send_transaction_view.network_fee_button)
send_transaction_view.sign_transaction(keycard=kwargs.get('keycard', False),
default_gas_price=kwargs.get('default_gas_price', False),
sender_password=kwargs.get('sender_password', common_password))
return send_transaction_view
def find_transaction_in_history(self, amount, asset='ETH', account_name=None):
def find_transaction_in_history(self, amount, asset='ETH', account_name=None, return_hash=False):
if account_name == None:
account_name = self.status_account_name
self.driver.info('**Finding %s %s transaction for %s**' % (amount, asset, account_name))
@ -292,7 +292,14 @@ class WalletView(BaseView):
self.get_account_by_name(account_name).click()
self.transaction_history_button.wait_for_element()
transactions_view = self.transaction_history_button.click()
return transactions_view.transactions_table.find_transaction(amount=amount, asset=asset)
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
def set_currency(self, desired_currency='EUR'):
self.driver.info("**Setting '%s' currency**" % desired_currency)