diff --git a/test/appium/tests/__init__.py b/test/appium/tests/__init__.py index 535c907555..9918ae3c31 100644 --- a/test/appium/tests/__init__.py +++ b/test/appium/tests/__init__.py @@ -15,7 +15,8 @@ def start_threads(amount, func, *args): class TestData(object): def __init__(self): - self.name = None + self.test_name = None + self.apk_name = None basic_user = {'password': "newuniquepassword12", @@ -41,4 +42,4 @@ transaction_users = { }, } -tests_data = TestData() +test_data = TestData() diff --git a/test/appium/tests/basetestcase.py b/test/appium/tests/basetestcase.py index 8d72347fa7..7c9a75fb54 100644 --- a/test/appium/tests/basetestcase.py +++ b/test/appium/tests/basetestcase.py @@ -57,9 +57,10 @@ class AbstractTestCase: @property def capabilities_sauce_lab(self): desired_caps = dict() - desired_caps['app'] = pytest.config.getoption('apk') + desired_caps['app'] = 'sauce-storage:' + test_data.apk_name + desired_caps['build'] = pytest.config.getoption('build') - desired_caps['name'] = tests_data.name + desired_caps['name'] = test_data.test_name desired_caps['platformName'] = 'Android' desired_caps['appiumVersion'] = '1.7.1' desired_caps['platformVersion'] = '6.0' diff --git a/test/appium/tests/conftest.py b/test/appium/tests/conftest.py index ea52a318dc..69e635011b 100644 --- a/test/appium/tests/conftest.py +++ b/test/appium/tests/conftest.py @@ -1,5 +1,4 @@ -from tests import tests_data -import time +from tests import test_data import requests import re from datetime import datetime @@ -19,26 +18,28 @@ def get_latest_apk(): dates.sort(key=lambda date: datetime.strptime(date, "%d-%b-%Y %H:%M"), reverse=True) return re.findall('>(.*k)\s*%s' % dates[0], raw_data)[0] -latest_apk = get_latest_apk() +latest_nightly_apk = dict() +latest_nightly_apk['name'] = get_latest_apk() +latest_nightly_apk['url'] = storage + latest_nightly_apk['name'] def pytest_addoption(parser): parser.addoption("--build", action="store", - default='build_' + time.strftime('%Y_%m_%d_%H_%M'), + default='build_' + latest_nightly_apk['name'], help="Specify build name") parser.addoption('--apk', action='store', - default='sauce-storage:' + latest_apk, - help='Please provide url or local path to apk') + default=latest_nightly_apk['url'], + help='Url or local path to apk') parser.addoption('--env', action='store', default='sauce', - help='Please specify environment: local/sauce') - - -def pytest_runtest_setup(item): - tests_data.name = item.name + '_' + latest_apk + help='Specify environment: local/sauce') + parser.addoption('--log', + action='store', + default=False, + help='Display each test step in terminal as plain text: True/False') def is_master(config): @@ -48,21 +49,31 @@ def is_master(config): def is_uploaded(): stored_files = SauceClient(sauce_username, sauce_access_key).storage.get_stored_files() for i in range(len(stored_files['files'])): - if stored_files['files'][i]['name'] == latest_apk: + if stored_files['files'][i]['name'] == test_data.apk_name: return True def pytest_configure(config): - import logging - logging.basicConfig(level=logging.INFO) + + if config.getoption('log'): + import logging + logging.basicConfig(level=logging.INFO) + + test_data.apk_name = ([i for i in [i for i in config.getoption('apk').split('/') + if '.apk' in i]])[0] + if is_master(config) and config.getoption('env') == 'sauce': if not is_uploaded(): - response = requests.get(storage + latest_apk, stream=True) + response = requests.get(config.getoption('apk'), stream=True) response.raise_for_status() file = BytesIO(response.content) del response requests.post('http://saucelabs.com/rest/v1/storage/' - + sauce_username + '/' + latest_apk + '?overwrite=true', + + sauce_username + '/' + test_data.apk_name + '?overwrite=true', auth=(sauce_username, sauce_access_key), data=file, headers={'Content-Type': 'application/octet-stream'}) + + +def pytest_runtest_setup(item): + test_data.test_name = item.name + '_' + test_data.apk_name diff --git a/test/appium/tests/test_transaction.py b/test/appium/tests/test_transaction.py index b425a30af8..f37f4fd6d4 100644 --- a/test/appium/tests/test_transaction.py +++ b/test/appium/tests/test_transaction.py @@ -4,7 +4,7 @@ from tests.basetestcase import SingleDeviceTestCase from views.home import HomeView from tests.preconditions import set_password_as_new_user, recover_access from tests import transaction_users -from selenium.common.exceptions import NoSuchElementException +from selenium.common.exceptions import TimeoutException @pytest.mark.all @@ -68,7 +68,7 @@ class TestTransactions(SingleDeviceTestCase): chats.find_full_text('0.1') try: chats.find_full_text('Sent', 10) - except NoSuchElementException: + except TimeoutException: chats.find_full_text('Delivered', 10) if test == 'group_chat': chats.find_full_text('to ' + transaction_users[recipient]['username'], 60) diff --git a/test/appium/views/chats.py b/test/appium/views/chats.py index 432e0d03cb..03cd0ea047 100644 --- a/test/appium/views/chats.py +++ b/test/appium/views/chats.py @@ -122,7 +122,7 @@ class ConfirmPublicKeyButton(BaseButton): def __init__(self, driver): super(ConfirmPublicKeyButton, self).__init__(driver) self.locator = \ - self.Locator.accessibility_id('toolbar-action') + self.Locator.xpath_selector('(//android.view.ViewGroup[@content-desc="icon"])[2]') class ChatMessageInput(BaseEditBox): diff --git a/test/appium/views/home.py b/test/appium/views/home.py index 3f208ce70d..82d516b3e4 100644 --- a/test/appium/views/home.py +++ b/test/appium/views/home.py @@ -1,7 +1,5 @@ from views.base_view import BaseViewObject from views.base_element import * -from tests import tests_data - class RequestPasswordIcon(BaseButton):