e2e: fix ens and tx tests

This commit is contained in:
Churikova Tetiana 2022-02-11 16:17:54 +01:00
parent 52afbf46ee
commit d77701537a
No known key found for this signature in database
GPG Key ID: 0D4EA7B33B47E6D8
9 changed files with 79 additions and 77 deletions

View File

@ -45,7 +45,6 @@ selenium==3.14.1
six==1.11.0
urllib3==1.26.3
yarl==1.6.3
zbarlight==3.0
docker==4.4.0
influxdb==5.3.1
web3==5.25.0

View File

@ -29,27 +29,31 @@ class NetworkApi(object):
def get_transactions(self, address: str) -> List[dict]:
method = self.network_url + 'module=account&action=txlist&address=0x%s&sort=desc&apikey=%s' % (address, self.api_key)
try:
transactions_response = requests.request('GET', url=method, headers=self.headers).json()
if transactions_response:
return transactions_response['result']
except TypeError as e:
self.log("Check response from etherscan API. Returned values do not match expected. %s" % e)
except JSONDecodeError as e:
self.log("No valid JSON response from Etherscan: %s " % str(e))
pass
for attempt in range(3):
try:
transactions_response = requests.request('GET', url=method, headers=self.headers).json()
if transactions_response:
return transactions_response['result']
except TypeError as e:
self.log("Check response from etherscan API. Returned values do not match expected. %s" % e)
except JSONDecodeError as e:
self.log("No valid JSON response from Etherscan: %s " % str(e))
pass
time.sleep(30)
def get_token_transactions(self, address: str) -> List[dict]:
method = self.network_url + 'module=account&action=tokentx&address=0x%s&sort=desc&apikey=%s' % (address, self.api_key)
try:
transactions_response = requests.request('GET', url=method, headers=self.headers).json()
if transactions_response:
return transactions_response['result']
except TypeError as e:
self.log("Check response from etherscan API. Returned values do not match expected. %s" % str(e))
except JSONDecodeError as e:
self.log("No valid JSON response from Etherscan: %s " % str(e))
pass
for attempt in range(3):
try:
transactions_response = requests.request('GET', url=method, headers=self.headers).json()
if transactions_response:
return transactions_response['result']
except TypeError as e:
self.log("Check response from etherscan API. Returned values do not match expected. %s" % str(e))
except JSONDecodeError as e:
self.log("No valid JSON response from Etherscan: %s " % str(e))
pass
time.sleep(30)
def is_transaction_successful(self, transaction_hash: str) -> int:
method = self.network_url + 'module=transaction&action=getstatus&txhash=%s' % transaction_hash
@ -98,8 +102,8 @@ class NetworkApi(object):
if float(int(transaction['value']) / 10 ** decimals) == float(amount):
return transaction
except TypeError as e:
self.log("Failed iterate transactions: " + str(e))
pytest.fail("No valid JSON response from Etherscan: %s " % str(e))
self.log("Failed iterate transactions(Etherscan unexpected error): " + str(e))
continue
def wait_for_confirmation_of_transaction(self, address, amount, confirmations=6, token=False):
start_time = time.time()

View File

@ -936,23 +936,23 @@ class TestMessagesOneToOneChatSingle(SingleDeviceTestCase):
url_data = {
'ens_with_stateofus_domain_deep_link': {
'url': 'https://join.status.im/u/%s.stateofus.eth' % ens_user_ropsten['ens'],
'username': ens_user_ropsten['username']
'username': '@%s' % ens_user_ropsten['ens']
},
'ens_without_stateofus_domain_deep_link': {
'url': 'https://join.status.im/u/%s' % ens_user['ens'],
'username': ens_user['username']
'url': 'https://join.status.im/u/%s' % ens_user_ropsten['ens'],
'username': '@%s' % ens_user_ropsten['ens']
},
'ens_another_domain_deep_link': {
'url': 'status-im://u/%s' % ens_user['ens_another'],
'username': ens_user['username']
'username': '@%s' % ens_user['ens_another']
},
'own_profile_key_deep_link': {
'url': 'https://join.status.im/u/%s' % basic_user['public_key'],
'error': "That's you"
},
'other_user_profile_key_deep_link': {
'url': 'https://join.status.im/u/%s' % ens_user['public_key'],
'username': ens_user['username']
'url': 'https://join.status.im/u/%s' % transaction_senders['A']['public_key'],
'username': transaction_senders['A']['username']
},
'other_user_profile_key_deep_link_invalid': {
'url': 'https://join.status.im/u/%sinvalid' % ens_user['public_key'],
@ -967,8 +967,8 @@ class TestMessagesOneToOneChatSingle(SingleDeviceTestCase):
# 'username': ens_user['username']
# },
'other_user_profile_key': {
'url': ens_user['public_key'],
'username': ens_user['username']
'url': transaction_senders['A']['public_key'],
'username': transaction_senders['A']['username']
},
'other_user_profile_key_invalid': {
'url': '%s123' % ens_user['public_key'],
@ -1011,7 +1011,7 @@ class TestMessagesOneToOneChatSingle(SingleDeviceTestCase):
url_data = {
'ens_without_stateofus_domain_deep_link': {
'url': 'https://join.status.im/u/%s' % ens_user_ropsten['ens'],
'username': ens_user_ropsten['username']
'username': '@%s' % ens_user_ropsten['ens']
},
'other_user_profile_key_deep_link': {
@ -1026,8 +1026,8 @@ class TestMessagesOneToOneChatSingle(SingleDeviceTestCase):
'url': user['public_key'],
},
'other_user_profile_key': {
'url': ens_user['public_key'],
'username': ens_user['username']
'url': transaction_senders['A']['public_key'],
'username': transaction_senders['A']['username']
},
'wallet_validation_wrong_address_transaction': {
'url': 'ethereum:0x744d70fdbe2ba4cf95131626614a1763df805b9e@3/transfer?address=blablabla&uint256=1e10',
@ -1071,17 +1071,17 @@ class TestMessagesOneToOneChatSingle(SingleDeviceTestCase):
home.enter_qr_edit_box.scan_qr(url_data[key]['url'])
from views.chat_view import ChatView
chat = ChatView(self.driver)
if key == 'own_profile_key':
from views.profile_view import ProfileView
profile = ProfileView(self.driver)
if not profile.default_username_text.is_element_displayed():
self.errors.append('In %s case was not redirected to own profile' % key)
home.home_button.double_click()
if url_data[key].get('error'):
if not chat.element_by_text_part(url_data[key]['error']).is_element_displayed():
self.errors.append('Expected error %s is not shown' % url_data[key]['error'])
chat.ok_button.click()
if url_data[key].get('username'):
if key == 'own_profile_key':
if chat.profile_nickname.is_element_displayed():
self.errors.append('In %s case was not redirected to own profile' % key)
else:
if not chat.profile_nickname.is_element_displayed():
self.errors.append('In %s case block user button is not shown' % key)
if not chat.element_by_text(url_data[key]['username']).is_element_displayed():
self.errors.append('In %s case username not shown' % key)
if 'wallet' in key:

View File

@ -42,24 +42,25 @@ class TestDeepLinks(SingleDeviceTestCase):
@marks.testrail_id(5781)
@marks.medium
def test_deep_link_with_invalid_user_public_key_own_profile_key(self):
sign_in_view = SignInView(self.driver)
sign_in_view.recover_access(passphrase=basic_user['passphrase'])
sign_in = SignInView(self.driver)
sign_in.recover_access(passphrase=basic_user['passphrase'])
self.driver.close_app()
sign_in_view.just_fyi('Check that no error when opening invalid deep link')
sign_in.just_fyi('Check that no error when opening invalid deep link')
deep_link = 'status-im://u/%s' % basic_user['public_key'][:-10]
sign_in_view.open_weblink_and_login(deep_link)
home_view = sign_in_view.get_home_view()
home_view.plus_button.click_until_presence_of_element(home_view.start_new_chat_button)
if not home_view.start_new_chat_button.is_element_present():
sign_in.open_weblink_and_login(deep_link)
home = sign_in.get_home_view()
home.plus_button.click_until_presence_of_element(home.start_new_chat_button)
if not home.start_new_chat_button.is_element_present():
self.errors.append(
"Can't navigate to start new chat after app opened from deep link with invalid public key")
self.driver.close_app()
sign_in_view.just_fyi('Check that no error when opening invalid deep link')
sign_in.just_fyi('Check that no error when opening invalid deep link')
deep_link = 'status-im://u/%s' % basic_user['public_key']
sign_in_view.open_weblink_and_login(deep_link)
home_view.plus_button.click_until_presence_of_element(home_view.start_new_chat_button)
if not home_view.start_new_chat_button.is_element_present():
self.errors.append("Can't navigate to start new chat after app opened from deep link with own public key")
sign_in.open_weblink_and_login(deep_link)
from views.profile_view import ProfileView
profile = ProfileView(self.driver)
if not profile.default_username_text != basic_user['username']:
self.errors.append("Can't navigate to profile from deep link with own public key")
self.errors.verify_no_errors()

View File

@ -705,26 +705,31 @@ class TestTransactionWalletSingleDevice(SingleDeviceTestCase):
sign_in.wallet_button.click()
wallet.accounts_status_account.click()
send_transaction = wallet.send_transaction_button.click()
send_transaction = wallet.send_transaction_button.click_until_presence_of_element(send_transaction.amount_edit_box)
send_transaction.amount_edit_box.set_value(0)
send_transaction.set_recipient_address(ens_user_ropsten['ens'])
send_transaction.next_button.click()
send_transaction.network_fee_button.click()
send_transaction = wallet.get_send_transaction_view()
wallet.element_by_translation_id("network-fee").click()
if not wallet.element_by_translation_id("tx-fail-description2").is_element_displayed():
self.errors.append("Tx is likely to fail is not shown!")
if send_transaction.network_fee_button.is_element_displayed():
self.errors.append("Still can set tx fee when balance is not enough")
send_transaction.gas_limit_input.clear()
send_transaction.gas_limit_input.set_value(default_limit)
send_transaction.per_gas_price_limit_input.clear()
send_transaction.per_gas_price_limit_input.click()
send_transaction.per_gas_price_limit_input.send_keys('1')
if not wallet.element_by_translation_id("below-base-fee").is_element_displayed(10):
self.errors.append("Fee is below error is not shown")
send_transaction.save_fee_button.scroll_and_click()
if not wallet.element_by_translation_id("change-tip").is_element_displayed():
self.errors.append("Popup about changing fee error is not shown")
wallet.element_by_translation_id("continue-anyway").click()
if not send_transaction.element_by_text_part('0.000021 ETH').is_element_displayed():
self.driver.fail("Custom fee is not applied!")
## TODO: should be moved to another test after 8f52b9b63ccd9a52b7fe37ab4f89a2e7b6721fcd
# send_transaction = wallet.get_send_transaction_view()
# send_transaction.gas_limit_input.clear()
# send_transaction.gas_limit_input.set_value(default_limit)
# send_transaction.per_gas_price_limit_input.clear()
# send_transaction.per_gas_price_limit_input.click()
# send_transaction.per_gas_price_limit_input.send_keys('1')
# if not wallet.element_by_translation_id("below-base-fee").is_element_displayed(10):
# self.errors.append("Fee is below error is not shown")
# send_transaction.save_fee_button.scroll_and_click()
# if not wallet.element_by_translation_id("change-tip").is_element_displayed():
# self.errors.append("Popup about changing fee error is not shown")
# wallet.element_by_translation_id("continue-anyway").click()
# if not send_transaction.element_by_text_part('0.000021 ETH').is_element_displayed():
# self.driver.fail("Custom fee is not applied!")
self.errors.verify_no_errors()

View File

@ -500,6 +500,8 @@ class TestGroupChatMultipleDevice(MultipleDeviceTestCase):
public_key_3, username_3 = home_3.get_public_key_and_username(return_username=True)
device_3.home_button.click()
device_1_name, device_2_name, group_chat_name = 'creator', 'paired', 'some group chat'
home_2 = device_2.recover_access(passphrase=' '.join(recovery_phrase.values()))
device_1.just_fyi('Add contact, start group chat')
nickname = 'my_tester'
home_1.add_contact(public_key_3, nickname=nickname)
@ -509,7 +511,6 @@ class TestGroupChatMultipleDevice(MultipleDeviceTestCase):
chat_3.join_chat_button.click()
device_2.just_fyi('Go to profile > Devices, set device name, discover device 2 to device 1')
home_2 = device_2.recover_access(passphrase=' '.join(recovery_phrase.values()))
profile_2 = home_2.profile_button.click()
profile_2.discover_and_advertise_device(device_2_name)
device_1.profile_button.click()

View File

@ -4,7 +4,6 @@ import base64
import random
import re
import string
import zbarlight
from PIL import Image
from appium.webdriver.common.touch_action import TouchAction
from datetime import datetime
@ -518,13 +517,6 @@ class BaseView(object):
message = 'test message:'
return message + ''.join(random.choice(string.ascii_lowercase) for _ in range(10))
def get_text_from_qr(self):
image = Image.open(BytesIO(base64.b64decode(self.driver.get_screenshot_as_base64())))
image.load()
try:
return str(zbarlight.scan_codes('qrcode', image)[0])[2:][:132]
except IndexError:
raise BaseException('No data in QR code')
def get_back_to_home_view(self, times_to_click_on_back_btn=3):
counter = 0

View File

@ -203,7 +203,7 @@ class ProfileView(BaseView):
# ENS
self.username_in_ens_chat_settings_text = EditBox(self.driver,
xpath="//*[@content-desc='chat-icon']/../android.widget.TextView[2]")
xpath="//*[@content-desc='chat-icon']/../../android.widget.TextView[2]")
self.ens_usernames_button = ENSusernames(self.driver)
self.ens_name_in_share_chat_key_text = Text(self.driver, accessibility_id="ens-username")

View File

@ -82,7 +82,7 @@ class SendTransactionView(BaseView):
self.amount_edit_box = AmountEditBox(self.driver)
self.set_max_button = Button(self.driver, translation_id="set-max")
self.validation_error_element = Text(self.driver,
xpath="//*[@content-desc='custom-gas-fee']/../android.view.ViewGroup//*[@content-desc='icon']")
xpath="//*[@text='Network fee']/following-sibling::*[@content-desc='icon']")
# Network fee elements
self.network_fee_button = Button(self.driver, accessibility_id="custom-gas-fee")