e2e: geth log in failed tests + new checks for PNs

Signed-off-by: Churikova Tetiana <churikova.tm@gmail.com>
This commit is contained in:
Churikova Tetiana 2021-11-11 12:40:31 +01:00
parent 7754f0b6a5
commit 97a106a025
No known key found for this signature in database
GPG Key ID: 0D4EA7B33B47E6D8
14 changed files with 110 additions and 49 deletions

View File

@ -28,11 +28,19 @@ class BaseTestReport:
file_name = "%s.json" % test_name
return os.path.join(self.TEST_REPORT_DIR, file_name)
def save_test(self, test):
def save_test(self, test, geth: dict):
file_path = self.get_test_report_file_path(test.name)
geth_paths = {}
for log in geth.keys():
geth_path = os.path.join(self.TEST_REPORT_DIR, log)
result = open(geth_path, 'wb')
result.write(geth[log])
result.close()
geth_paths[log] = geth_path
test_dict = {
'testrail_case_id': test.testrail_case_id,
'name': test.name,
'geth_paths': geth_paths,
'testruns': list()
}
for testrun in test.testruns:
@ -41,15 +49,19 @@ class BaseTestReport:
def get_all_tests(self):
tests = list()
file_list = [f for f in os.listdir(self.TEST_REPORT_DIR)]
file_list = [f for f in os.listdir(self.TEST_REPORT_DIR) if f.endswith('json')]
for file_name in file_list:
file_path = os.path.join(self.TEST_REPORT_DIR, file_name)
test_data = json.load(open(file_path))
testruns = list()
for testrun_data in test_data['testruns']:
testruns.append(SingleTestData.TestRunData(
steps=testrun_data['steps'], jobs=testrun_data['jobs'], error=testrun_data['error']))
tests.append(SingleTestData(name=test_data['name'], testruns=testruns,
steps=testrun_data['steps'],
jobs=testrun_data['jobs'],
error=testrun_data['error']))
tests.append(SingleTestData(name=test_data['name'],
geth_paths=test_data['geth_paths'],
testruns=testruns,
testrail_case_id=test_data['testrail_case_id']))
return tests

View File

@ -1,10 +1,11 @@
class SingleTestData(object):
def __init__(self, name, testruns, testrail_case_id):
def __init__(self, name, testruns, testrail_case_id, geth_paths):
self.testrail_case_id = testrail_case_id
self.name = name
self.testruns = testruns
self.geth_paths = geth_paths
class TestRunData(object):
def __init__(self, steps, jobs, error):
@ -27,6 +28,6 @@ class TestSuiteData(object):
if existing_test:
self.current_test = existing_test
else:
test = SingleTestData(test_name, list(), testrail_case_id)
test = SingleTestData(test_name, list(), testrail_case_id, list())
self.tests.append(test)
self.current_test = test

View File

@ -43,6 +43,12 @@ class TestrailReport(BaseTestReport):
data = bytes(json.dumps(data), 'utf-8')
return requests.post(self.api_url + method, data=data, headers=self.headers).json()
def add_attachment(self, method, path):
files = {'attachment': (open(path, 'rb'))}
result = requests.post(self.api_url + method, headers={'Authorization': self.headers['Authorization']}, files=files)
files['attachment'].close()
return result.json()
def get_suites(self):
return self.get('get_suites/%s' % self.project_id)
@ -119,7 +125,10 @@ class TestrailReport(BaseTestReport):
data = {'status_id': self.outcomes['undefined_fail'] if last_testrun.error else self.outcomes['passed'],
'comment': '%s' % ('# Error: \n %s \n' % emoji.demojize(last_testrun.error)) + devices + test_steps if last_testrun.error
else devices + test_steps}
self.post(method, data=data)
result_id =self.post(method, data=data)['id']
if last_testrun.error:
for geth in test.geth_paths.keys():
self.add_attachment(method='add_attachment_to_result/%s' % str(result_id), path=test.geth_paths[geth])
self.change_test_run_description()
def change_test_run_description(self):

View File

@ -44,8 +44,6 @@ staging_fleet = 'eth.staging'
prod_fleet = 'eth.prod'
# This fleet is used in the tests
used_fleet = staging_fleet
app_path = '/storage/emulated/0/Android/data/im.status.ethereum/files/Download/'
geth_log_emulator_path = app_path + 'geth.log'
mailserver_ams = 'mail-01.do-ams3'
mailserver_hk = 'mail-01.ac-cn-hongkong-c'

View File

@ -568,7 +568,6 @@ class TestProfileSingleDevice(SingleDeviceTestCase):
class TestProfileMultipleDevice(MultipleDeviceTestCase):
@marks.testrail_id(6646)
@marks.high
def test_set_profile_picture(self):
@ -615,19 +614,21 @@ class TestProfileMultipleDevice(MultipleDeviceTestCase):
@marks.testrail_id(6636)
@marks.medium
@marks.flaky
def test_show_profile_picture_of_setting(self):
self.create_drivers(2)
home_1, home_2 = SignInView(self.drivers[0]).create_user(), SignInView(self.drivers[1]).create_user()
home_1, home_2 = SignInView(self.drivers[0]).create_user(), SignInView(self.drivers[1]).create_user(enable_notifications=True)
profile_1, profile_2 = home_1.profile_button.click(), home_2.profile_button.click()
public_key_1, default_username_1 = profile_1.get_public_key_and_username(return_username=True)
public_key_2 = profile_2.get_public_key_and_username()
public_key_2, default_username_2 = profile_2.get_public_key_and_username(return_username=True)
logo_online, logo_default, logo_chats, logo_group= 'logo_new.png', 'sauce_logo.png', 'logo_chats_view.png', 'group_logo.png'
[profile.home_button.click() for profile in (profile_1, profile_2)]
home_1.add_contact(public_key_2)
home_1.profile_button.click()
profile_1.just_fyi("Set user Profile image from Gallery")
profile_1.edit_profile_picture(file_name='sauce_logo.png')
profile_1.edit_profile_picture(file_name=logo_default)
home_1.profile_button.click()
profile_1.swipe_down()
@ -635,21 +636,21 @@ class TestProfileMultipleDevice(MultipleDeviceTestCase):
device_1_status = 'My new update!'
timeline = profile_1.status_button.click()
timeline.set_new_status(device_1_status)
if not timeline.timeline_own_account_photo.is_element_image_similar_to_template('sauce_logo.png'):
if not timeline.timeline_own_account_photo.is_element_image_similar_to_template(logo_default):
self.errors.append('Profile picture was not updated in timeline')
profile_1.just_fyi('Check profile image it is not in mentions because user not in contacts yet')
one_to_one_chat_2 = home_2.add_contact(public_key_1, add_in_contacts=False)
one_to_one_chat_2.chat_message_input.set_value('@' + default_username_1)
one_to_one_chat_2.chat_message_input.click()
if one_to_one_chat_2.user_profile_image_in_mentions_list(default_username_1).is_element_image_similar_to_template('sauce_logo.png'):
if one_to_one_chat_2.user_profile_image_in_mentions_list(default_username_1).is_element_image_similar_to_template(logo_default):
self.errors.append('Profile picture is updated in 1-1 chat mentions list of contact not in Contacts list')
profile_1.just_fyi('Check profile image is in mentions because now user was added in contacts')
one_to_one_chat_2.add_to_contacts.click()
one_to_one_chat_2.chat_message_input.set_value('@' + default_username_1)
one_to_one_chat_2.chat_message_input.click()
if not one_to_one_chat_2.user_profile_image_in_mentions_list(default_username_1).is_element_image_similar_to_template('sauce_logo.png'):
if not one_to_one_chat_2.user_profile_image_in_mentions_list(default_username_1).is_element_image_similar_to_template(logo_default):
self.errors.append('Profile picture was not updated in 1-1 chat mentions list')
one_to_one_chat_2.get_back_to_home_view()
@ -657,11 +658,12 @@ class TestProfileMultipleDevice(MultipleDeviceTestCase):
profile_2 = one_to_one_chat_2.profile_button.click()
profile_2.contacts_button.click()
profile_2.element_by_text(default_username_1).click()
if not profile_2.profile_picture.is_element_image_similar_to_template('sauce_logo.png'):
if not profile_2.profile_picture.is_element_image_similar_to_template(logo_online):
self.errors.append('Profile picture was not updated on user Profile view')
profile_2.close_button.click()
[home.home_button.click() for home in (profile_2, home_1)]
if not home_2.get_chat(default_username_1).chat_image.is_element_image_similar_to_template('sauce_logo.png'):
if not home_2.get_chat(default_username_1).chat_image.is_element_image_similar_to_template(logo_chats):
self.errors.append('User profile picture was not updated on Chats view')
profile_1.just_fyi('Check profile image updated in user profile view in Group chat views')
@ -671,17 +673,31 @@ class TestProfileMultipleDevice(MultipleDeviceTestCase):
group_chat_1 = home_1.get_chat(group_chat_name).click()
group_chat_1.join_chat_button.click()
group_chat_1.send_message(group_chat_message)
if not group_chat_2.chat_element_by_text(group_chat_message).member_photo.is_element_image_similar_to_template('sauce_logo.png'):
if not group_chat_2.chat_element_by_text(group_chat_message).member_photo.is_element_image_similar_to_template(logo_default):
self.errors.append('User profile picture was not updated in message Group chat view')
home_2.put_app_to_background()
profile_1.just_fyi('Check profile image updated in group chat invite')
home_1.get_back_to_home_view()
new_group_chat = 'new_gr'
group_chat_1 = home_1.create_group_chat(user_names_to_add=[default_username_2], group_chat_name=new_group_chat)
home_2.click_system_back_button()
home_2.open_notification_bar()
invite = group_chat_2.pn_invited_to_group_chat(default_username_1, new_group_chat)
home_2.get_pn(invite).wait_for_visibility_of_element(30)
if not home_2.get_pn(invite).group_chat_icon.is_element_image_similar_to_template(logo_group):
self.errors.append("Group chat invite is not updated with custom logo!")
home_2.get_pn(invite).click()
profile_1.just_fyi('Check profile image updated in on login view')
home_1.profile_button.click()
profile_1.logout()
sign_in_1 = home_1.get_sign_in_view()
if not sign_in_1.get_multiaccount_by_position(1).account_logo.is_element_image_similar_to_template('sauce_logo.png'):
if not sign_in_1.get_multiaccount_by_position(1).account_logo.is_element_image_similar_to_template(logo_default):
self.errors.append('User profile picture was not updated on Multiaccounts list select login view')
sign_in_1.element_by_text(default_username_1).click()
if not sign_in_1.get_multiaccount_by_position(1).account_logo.is_element_image_similar_to_template('sauce_logo.png'):
if not sign_in_1.get_multiaccount_by_position(1).account_logo.is_element_image_similar_to_template(logo_default):
self.errors.append('User profile picture was not updated on account login view')
sign_in_1.password_input.set_value(common_password)
sign_in_1.sign_in_button.click()
@ -696,7 +712,7 @@ class TestProfileMultipleDevice(MultipleDeviceTestCase):
group_chat_1.send_message(group_chat_message)
one_to_one_chat_2.close_button.click()
one_to_one_chat_2.home_button.click(desired_view='home')
if home_2.get_chat(default_username_1).chat_image.is_element_image_similar_to_template('sauce_logo.png'):
if home_2.get_chat(default_username_1).chat_image.is_element_image_similar_to_template(logo_default):
self.errors.append('User profile picture is not default to default after user removed from Contacts')
profile_2.just_fyi('Enable to see profile image from "Everyone" setting')
@ -706,7 +722,7 @@ class TestProfileMultipleDevice(MultipleDeviceTestCase):
profile_2.element_by_translation_id("everyone").click()
group_chat_1.send_message(group_chat_message)
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'):
if not home_2.get_chat(default_username_1).chat_image.is_element_image_similar_to_template(logo_chats):
self.errors.append('User profile picture is not returned to default after user removed from Contacts')
self.errors.verify_no_errors()

View File

@ -16,6 +16,8 @@ from tests import transl
from support.api.network_api import NetworkApi
from support.github_report import GithubHtmlReport
from tests import test_suite_data, start_threads, appium_container, pytest_config_global
import base64
from re import findall
class AbstractTestCase:
__metaclass__ = ABCMeta
@ -55,6 +57,15 @@ class AbstractTestCase:
updated_capabilities.append(capabilities)
return updated_capabilities
@property
def app_path(self):
app_path='/storage/emulated/0/Android/data/im.status.ethereum.pr/files/Download/' if findall(r'pr\d\d\d\d\d', pytest_config_global['apk']) else '/storage/emulated/0/Android/data/im.status.ethereum/files/Download/'
return app_path
@property
def geth_path(self):
return self.app_path + 'geth.log'
@property
def capabilities_sauce_lab(self):
desired_caps = dict()
@ -136,6 +147,15 @@ class AbstractTestCase:
% self.get_alert_text(driver)
def pull_geth(self, driver):
result = ""
try:
result = driver.pull_file(self.geth_path)
except WebDriverException:
pass
return base64.b64decode(result)
class Driver(webdriver.Remote):
@property
@ -189,13 +209,14 @@ class SingleDeviceTestCase(AbstractTestCase):
self.print_sauce_lab_info(self.driver)
try:
self.add_alert_text_to_report(self.driver)
geth_content = self.pull_geth(self.driver)
self.driver.quit()
if pytest_config_global['docker']:
appium_container.stop_container()
except (WebDriverException, AttributeError):
pass
finally:
self.github_report.save_test(test_suite_data.current_test)
self.github_report.save_test(test_suite_data.current_test, {'%s_geth.log' % test_suite_data.current_test.name: geth_content})
class LocalMultipleDeviceTestCase(AbstractTestCase):
@ -244,15 +265,19 @@ class SauceMultipleDeviceTestCase(AbstractTestCase):
custom_implicitly_wait if custom_implicitly_wait else self.implicitly_wait)
def teardown_method(self, method):
geth_names, geth_contents = [], []
for driver in self.drivers:
try:
self.print_sauce_lab_info(self.drivers[driver])
self.add_alert_text_to_report(self.drivers[driver])
geth_names.append('%s_geth%s.log' % (test_suite_data.current_test.name, str(self.drivers[driver].number)))
geth_contents.append(self.pull_geth(self.drivers[driver]))
self.drivers[driver].quit()
except (WebDriverException, AttributeError):
pass
finally:
self.github_report.save_test(test_suite_data.current_test)
geth = {geth_names[i]: geth_contents[i] for i in range(len(geth_names))}
self.github_report.save_test(test_suite_data.current_test, geth)
@classmethod
def teardown_class(cls):

View File

@ -12,7 +12,7 @@ from io import BytesIO
from selenium.common.exceptions import NoSuchElementException, TimeoutException
from support.device_apps import start_web_browser
from tests import common_password, pytest_config_global, geth_log_emulator_path, transl
from tests import common_password, pytest_config_global, transl
from views.base_element import Button, BaseElement, EditBox, Text
@ -574,7 +574,8 @@ class BaseView(object):
return items_in_logcat
def find_values_in_geth(self, *args):
b64_log = self.driver.pull_file(geth_log_emulator_path)
from tests.base_test_case import AbstractTestCase
b64_log = self.driver.pull_file(AbstractTestCase().geth_path)
file = base64.b64decode(b64_log)
result = False
for value in args:
@ -584,7 +585,6 @@ class BaseView(object):
result = True
return result
def asset_by_name(self, asset_name):
return AssetButton(self.driver, asset_name)

Binary file not shown.

After

Width:  |  Height:  |  Size: 8.2 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 12 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 16 KiB

View File

@ -338,20 +338,21 @@ class ProfileView(BaseView):
from views.chat_view import ChatView
return ChatView(self.driver)
def add_custom_network(self):
def add_custom_network(self, rpc_url ='https://ropsten.infura.io/v3/f315575765b14720b32382a61a89341a',
name='custom_ropsten'):
self.driver.info("## Add predefined custom network", device=False)
self.advanced_button.click()
self.network_settings_button.scroll_to_element()
self.network_settings_button.click()
self.plus_button.click_until_presence_of_element(self.ropsten_chain_button)
self.custom_network_url_input.send_keys('https://ropsten.infura.io/v3/f315575765b14720b32382a61a89341a')
self.specify_name_input.send_keys('custom_ropsten')
self.custom_network_url_input.send_keys(rpc_url)
self.specify_name_input.send_keys(name)
self.ropsten_chain_button.scroll_to_element()
self.ropsten_chain_button.click()
self.ropsten_chain_button.click()
self.save_button.click()
self.element_by_text_part('custom_ropsten').scroll_to_element()
self.element_by_text_part('custom_ropsten').click_until_presence_of_element(self.connect_button)
self.element_by_text_part(name).scroll_to_element()
self.element_by_text_part(name).click_until_presence_of_element(self.connect_button)
self.connect_button.click()
self.confirm_button.click()
self.driver.info("## Custom network is added succesfully!", device=False)

View File

@ -125,7 +125,7 @@ class SendTransactionView(BaseView):
self.done_button.click_until_absense_of_element(self.done_button)
def sign_transaction(self, sender_password: str = common_password, keycard=False):
self.driver.info("## Signing transaction, (keycard: %s)" % str(keycard), device=False)
self.driver.info("Signing transaction, (keycard: %s)" % str(keycard), device=False)
if self.sign_in_phrase.is_element_displayed(30):
self.set_up_wallet_when_sending_tx()
if keycard:

View File

@ -1,7 +1,6 @@
from appium.webdriver.common.touch_action import TouchAction
from selenium.common.exceptions import NoSuchElementException
import os
from tests import common_password, appium_root_project_path, app_path
from tests import common_password, appium_root_project_path
from views.base_element import Button, EditBox, Text
from views.base_view import BaseView
@ -266,6 +265,7 @@ class SignInView(BaseView):
self.sign_in()
def import_db(self, user, import_db_folder_name):
from tests.base_test_case import AbstractTestCase
self.driver.info('## Importing database', device=False)
import_file_name = 'export.db'
home = self.recover_access(user['passphrase'])
@ -276,7 +276,7 @@ class SignInView(BaseView):
self.multi_account_on_login_button.wait_for_visibility_of_element(30)
self.get_multiaccount_by_position(1).click()
self.password_input.set_value(common_password)
self.driver.push_file(source_path=full_path_to_file, destination_path=app_path + import_file_name)
self.driver.push_file(source_path=full_path_to_file, destination_path='%s%s'% (AbstractTestCase().app_path, import_file_name))
self.options_button.click()
self.element_by_text('Import unencrypted').click()
self.element_by_text('Import unencrypted').wait_for_invisibility_of_element(40)

View File

@ -186,14 +186,14 @@ class WalletView(BaseView):
def set_up_wallet_when_sending_tx(self):
self.driver.info("**Setting up wallet**")
self.driver.info("Setting up wallet")
phrase = self.sign_in_phrase.text
self.ok_got_it_button.click()
return phrase
def get_wallet_address(self, account_name=''):
account_name = self.status_account_name if not account_name else account_name
self.driver.info("**Getting wallet address for '%s'**" % account_name)
self.driver.info("Getting wallet address for '%s'" % account_name)
self.wallet_account_by_name(account_name).click()
self.receive_transaction_button.click_until_presence_of_element(self.qr_code_image)
address = self.address_text.text
@ -206,7 +206,7 @@ class WalletView(BaseView):
def get_asset_amount_by_name(self, asset: str):
self.driver.info("*Getting %s amount*" % asset)
self.driver.info("Getting %s amount" % asset)
asset_value = SilentButton(self.driver, xpath="//android.view.ViewGroup[@content-desc=':%s-asset-value']"
"//android.widget.TextView[1]" % asset)
asset_value.scroll_to_element()
@ -216,21 +216,21 @@ class WalletView(BaseView):
return 0.0
def asset_by_name(self, asset_name):
self.driver.info("*Selecting %s asset*" % asset_name)
self.driver.info("Selecting %s asset" % asset_name)
return SilentButton(self.driver, xpath="//*[contains(@text,'%s')]" % asset_name)
def asset_checkbox_by_name(self, asset_name):
self.driver.info("*Selecting %s asset checkbox by name*" % asset_name)
self.driver.info("Selecting %s asset checkbox by name" % asset_name)
return AssetCheckBox(self.driver, asset_name)
def get_account_options_by_name(self, account_name=''):
account_name = self.status_account_name if not account_name else account_name
self.driver.info("*Getting '%s'account options*" % account_name)
self.driver.info("Getting '%s'account options" % account_name)
return SilentButton(self.driver, xpath="(//*[@text='%s']/../..//*[@content-desc='icon'])[2]" % account_name)
def get_account_options_from_main_screen(self, account_name=''):
account_name = self.status_account_name if not account_name else account_name
self.driver.info("*Getting '%s'account options from main wallet screen*" % account_name)
self.driver.info("Getting '%s'account options from main wallet screen" % account_name)
return SilentButton(self.driver, xpath="//*[@content-desc='accountcard%s']//*[@content-desc='icon']" % account_name)
def hidden_account_by_name_button(self, account_name=''):
@ -243,16 +243,15 @@ class WalletView(BaseView):
def select_asset(self, *args):
self.driver.info("## Selecting asset(s)")
self.driver.info("Selecting asset(s)")
self.multiaccount_more_options.click()
self.manage_assets_button.click()
for asset in args:
self.asset_checkbox_by_name(asset).click()
self.cross_icon.click()
self.driver.info("## Assets are selected!")
def scan_tokens(self, *args):
self.driver.info("## Scanning tokens")
self.driver.info("Scanning tokens")
self.multiaccount_more_options.click()
self.scan_tokens_button.click()
counter = 0
@ -273,7 +272,7 @@ class WalletView(BaseView):
return self
def send_transaction(self, **kwargs):
self.driver.info("## Sending transaction")
self.driver.info("## Sending transaction", device=False)
send_transaction_view = self.send_transaction_button.click()
send_transaction_view.select_asset_button.click()
asset_name = kwargs.get('asset_name', 'ETH').upper()