diff --git a/test/appium/tests/base_test_case.py b/test/appium/tests/base_test_case.py index 238954d150..39b13c54bb 100644 --- a/test/appium/tests/base_test_case.py +++ b/test/appium/tests/base_test_case.py @@ -5,7 +5,7 @@ import subprocess import sys from abc import ABCMeta, abstractmethod from http.client import RemoteDisconnected -from re import findall +import re import pytest import requests @@ -23,13 +23,13 @@ from tests import test_suite_data, start_threads, appium_container, pytest_confi from tests import transl from tests.conftest import apibase - executor_sauce_lab = 'https://%s:%s@ondemand.%s:443/wd/hub' % (sauce_username, sauce_access_key, apibase) executor_local = 'http://localhost:4723/wd/hub' implicit_wait = 5 + def get_capabilities_local(): desired_caps = dict() if pytest_config_global['docker']: @@ -105,7 +105,7 @@ class AbstractTestCase: def app_path(self): app_folder = 'im.status.ethereum' apk = pytest_config_global['apk'] - if findall(r'pr\d\d\d\d\d', apk) or findall(r'\d\d\d\d\d.apk', apk): + if re.findall(r'pr\d\d\d\d\d', apk) or re.findall(r'\d\d\d\d\d.apk', apk): app_folder += '.pr' app_path = '/storage/emulated/0/Android/data/%s/files/Download/' % app_folder return app_path @@ -129,21 +129,23 @@ class AbstractTestCase: network_api = NetworkApi() github_report = GithubHtmlReport() - @staticmethod - def is_alert_present(driver): - try: - return driver.find_element(MobileBy.ID, 'android:id/message') - except NoSuchElementException: - return False - @staticmethod def get_alert_text(driver): - return driver.find_element(MobileBy.ID, 'android:id/message').text + try: + return driver.find_element(MobileBy.ID, 'android:id/message').text + except NoSuchElementException: + return None def add_alert_text_to_report(self, driver): - if self.is_alert_present(driver): - test_suite_data.current_test.testruns[-1].error += "; also Unexpected Alert is shown: '%s'" \ - % self.get_alert_text(driver) + try: + alert_text = self.get_alert_text(driver) + if alert_text: + test_suite_data.current_test.testruns[-1].error = "%s; also Unexpected Alert is shown: '%s'" % ( + test_suite_data.current_test.testruns[-1].error, alert_text + ) + except RemoteDisconnected: + test_suite_data.current_test.testruns[-1].error = "%s; \n RemoteDisconnected" % \ + test_suite_data.current_test.testruns[-1].error def pull_geth(self, driver): result = "" @@ -393,7 +395,8 @@ class SauceSharedMultipleDeviceTestCase(AbstractTestCase): except WebDriverException: pass if option.datacenter == 'eu-central-1': - url = 'https://eu-central-1.saucelabs.com/rest/v1/%s/jobs/%s/assets/%s' % (sauce_username, session_id, "log.json") + url = 'https://eu-central-1.saucelabs.com/rest/v1/%s/jobs/%s/assets/%s' % ( + sauce_username, session_id, "log.json") else: url = sauce.jobs.get_job_asset_url(username=sauce_username, job_id=session_id, filename="log.json") WebDriverWait(driver, 60, 2).until(lambda _: requests_session.get(url).status_code == 200) diff --git a/test/appium/tests/conftest.py b/test/appium/tests/conftest.py index 1044a51325..dc088770d2 100644 --- a/test/appium/tests/conftest.py +++ b/test/appium/tests/conftest.py @@ -9,7 +9,7 @@ import urllib.request import pytest from _pytest.runner import runtestprotocol - +from requests.exceptions import ConnectionError as c_er import tests from support.device_stats_db import DeviceStatsDB from support.test_rerun import should_rerun_test @@ -329,7 +329,7 @@ def update_sauce_jobs(test_name, job_ids, passed): for job_id in job_ids.keys(): try: sauce.jobs.update_job(username=sauce_username, job_id=job_id, name=test_name, passed=passed) - except (RemoteDisconnected, SauceException): + except (RemoteDisconnected, SauceException, c_er): pass diff --git a/test/appium/tests/medium/test_deeplink_chat_share_profile.py b/test/appium/tests/medium/test_deeplink_chat_share_profile.py index 17befb86db..b1a3a9310c 100644 --- a/test/appium/tests/medium/test_deeplink_chat_share_profile.py +++ b/test/appium/tests/medium/test_deeplink_chat_share_profile.py @@ -35,7 +35,7 @@ class TestDeeplinkChatProfileOneDevice(MultipleSharedDeviceTestCase): self.home.ens_banner_close_button.click_if_shown() @marks.testrail_id(702244) - def test_deep_link_with_invalid_user_public_key_own_profile_key(self): + def test_deep_link_with_invalid_user_public_key_own_profile_key_old(self): self.drivers[0].close_app() self.sign_in.just_fyi('Check that no error when opening invalid deep link')