Compare commits
11
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
d2a2c2f48e | ||
|
|
7ebf035506 | ||
|
|
7256c66760 | ||
|
|
6a9a6fb52c | ||
|
|
de05976353 | ||
|
|
db9e3bde17 | ||
|
|
cb0e15eff0 | ||
|
|
d4c275cb09 | ||
|
|
dc781b73fa | ||
|
|
321efa053c | ||
|
|
bdbf00257a |
@@ -36,7 +36,7 @@ python-dateutil==2.8.1
|
||||
pytz==2020.4
|
||||
PyYAML==5.4
|
||||
repoze.lru==0.7
|
||||
requests==2.25.1
|
||||
requests==2.28.2
|
||||
rlp==3.0.0
|
||||
sauceclient==1.0.0
|
||||
scrypt==0.8.17
|
||||
|
||||
@@ -1,23 +1,23 @@
|
||||
import asyncio
|
||||
import logging
|
||||
from datetime import datetime
|
||||
import os
|
||||
import functools
|
||||
import json
|
||||
import logging
|
||||
import os
|
||||
from datetime import datetime
|
||||
|
||||
from support.appium_container import AppiumContainer
|
||||
from support.test_data import TestSuiteData
|
||||
import functools
|
||||
|
||||
import time
|
||||
|
||||
|
||||
async def start_threads(quantity: int, func: type, returns: dict, *args):
|
||||
loop = asyncio.get_event_loop()
|
||||
# from tests.conftest import sauce
|
||||
# for _ in range(60):
|
||||
# if 16 - len([job for job in sauce.jobs.get_user_jobs() if job['status'] == 'in progress']) < quantity:
|
||||
# time.sleep(10)
|
||||
# from tests.conftest import sauce
|
||||
# for _ in range(60):
|
||||
# if 16 - len([job for job in sauce.jobs.get_user_jobs() if job['status'] == 'in progress']) < quantity:
|
||||
# time.sleep(10)
|
||||
for i in range(quantity):
|
||||
returns[i] = loop.run_in_executor(None, func, *args)
|
||||
# returns[i] = loop.run_in_executor(None, functools.partial(func, **kwargs))
|
||||
for k in returns:
|
||||
returns[k] = await returns[k]
|
||||
return returns
|
||||
@@ -44,6 +44,7 @@ def get_current_time():
|
||||
def debug(text: str):
|
||||
logging.debug(text)
|
||||
|
||||
|
||||
appium_root_project_path = os.path.join(os.sep.join(__file__.split(os.sep)[:-1]), '../')
|
||||
|
||||
pytest_config_global = dict()
|
||||
@@ -54,7 +55,7 @@ common_password = 'qwerty1234'
|
||||
unique_password = 'unique' + get_current_time()
|
||||
pin = '121212'
|
||||
puk = '000000000000'
|
||||
pair_code= '000000'
|
||||
pair_code = '000000'
|
||||
background_service_message = 'Background service for notifications'
|
||||
|
||||
bootnode_address = "enode://a8a97f126f5e3a340cb4db28a1187c325290ec08b2c9a6b1f19845ac86c46f9fac2ba13328822590" \
|
||||
@@ -77,6 +78,5 @@ test_dapp_name = 'simpledapp.status.im'
|
||||
|
||||
emojis = {'thumbs-up': 2, 'thumbs-down': 3, 'love': 1, 'laugh': 4, 'angry': 6, 'sad': 5}
|
||||
|
||||
|
||||
with open(os.sep.join(__file__.split(os.sep)[:-1]) + '/../../../translations/en.json') as json_file:
|
||||
transl = json.load(json_file)
|
||||
|
||||
@@ -15,7 +15,6 @@ from sauceclient import SauceException
|
||||
from selenium.common.exceptions import NoSuchElementException
|
||||
from selenium.common.exceptions import WebDriverException
|
||||
from selenium.webdriver.support.wait import WebDriverWait
|
||||
from urllib3.exceptions import MaxRetryError
|
||||
|
||||
from support.api.network_api import NetworkApi
|
||||
from support.github_report import GithubHtmlReport
|
||||
@@ -70,10 +69,10 @@ def get_capabilities_sauce_lab():
|
||||
desired_caps['name'] = test_suite_data.current_test.name
|
||||
desired_caps['platformName'] = 'Android'
|
||||
desired_caps['appiumVersion'] = '1.18.1'
|
||||
desired_caps['platformVersion'] = '10.0'
|
||||
desired_caps['platformVersion'] = '12.0'
|
||||
desired_caps['deviceName'] = 'Android GoogleAPI Emulator'
|
||||
desired_caps['deviceOrientation'] = "portrait"
|
||||
desired_caps['commandTimeout'] = 600
|
||||
desired_caps['newCommandTimeout'] = 600
|
||||
desired_caps['idleTimeout'] = 1000
|
||||
desired_caps['unicodeKeyboard'] = True
|
||||
desired_caps['automationName'] = 'UiAutomator2'
|
||||
@@ -301,17 +300,21 @@ def create_shared_drivers(quantity):
|
||||
capabilities = {'maxDuration': 3600}
|
||||
print('SC Executor: %s' % executor_sauce_lab)
|
||||
try:
|
||||
# options = webdriver.webdriver.AppiumOptions()
|
||||
# for key, value in update_capabilities_sauce_lab(capabilities).items():
|
||||
# options.set_capability(key, value)
|
||||
drivers = loop.run_until_complete(start_threads(quantity,
|
||||
Driver,
|
||||
drivers,
|
||||
executor_sauce_lab,
|
||||
update_capabilities_sauce_lab(capabilities)))
|
||||
Driver,
|
||||
drivers,
|
||||
executor_sauce_lab,
|
||||
update_capabilities_sauce_lab(capabilities)))
|
||||
for i in range(quantity):
|
||||
test_suite_data.current_test.testruns[-1].jobs[drivers[i].session_id] = i + 1
|
||||
drivers[i].implicitly_wait(implicit_wait)
|
||||
return drivers, loop
|
||||
except MaxRetryError as e:
|
||||
test_suite_data.current_test.testruns[-1].error = e.reason
|
||||
except Exception as e:
|
||||
loop.close()
|
||||
raise e #from None
|
||||
|
||||
|
||||
class LocalSharedMultipleDeviceTestCase(AbstractTestCase):
|
||||
@@ -370,12 +373,14 @@ class SauceSharedMultipleDeviceTestCase(AbstractTestCase):
|
||||
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]))
|
||||
|
||||
except (WebDriverException, AttributeError):
|
||||
pass
|
||||
finally:
|
||||
geth = {geth_names[i]: geth_contents[i] for i in range(len(geth_names))}
|
||||
test_suite_data.current_test.geth_paths = self.github_report.save_geth(geth)
|
||||
try:
|
||||
geth = {geth_names[i]: geth_contents[i] for i in range(len(geth_names))}
|
||||
test_suite_data.current_test.geth_paths = self.github_report.save_geth(geth)
|
||||
except IndexError:
|
||||
pass
|
||||
|
||||
@pytest.fixture(scope='class', autouse=True)
|
||||
def prepare(self, request):
|
||||
@@ -390,28 +395,30 @@ class SauceSharedMultipleDeviceTestCase(AbstractTestCase):
|
||||
from tests.conftest import sauce
|
||||
requests_session = requests.Session()
|
||||
requests_session.auth = (sauce_username, sauce_access_key)
|
||||
for _, driver in cls.drivers.items():
|
||||
session_id = driver.session_id
|
||||
try:
|
||||
sauce.jobs.update_job(username=sauce_username, job_id=session_id, name=cls.__name__)
|
||||
except (RemoteDisconnected, SauceException):
|
||||
pass
|
||||
try:
|
||||
driver.quit()
|
||||
except WebDriverException:
|
||||
pass
|
||||
url = 'https://api.%s/rest/v1/%s/jobs/%s/assets/%s' % (apibase, sauce_username, session_id, "log.json")
|
||||
WebDriverWait(driver, 60, 2).until(lambda _: requests_session.get(url).status_code == 200)
|
||||
commands = requests_session.get(url).json()
|
||||
for command in commands:
|
||||
if hasattr(cls, 'drivers'):
|
||||
for _, driver in cls.drivers.items():
|
||||
session_id = driver.session_id
|
||||
try:
|
||||
if command['message'].startswith("Started "):
|
||||
for test in test_suite_data.tests:
|
||||
if command['message'] == "Started %s" % test.name:
|
||||
test.testruns[-1].first_commands[session_id] = commands.index(command) + 1
|
||||
except KeyError:
|
||||
continue
|
||||
cls.loop.close()
|
||||
sauce.jobs.update_job(username=sauce_username, job_id=session_id, name=cls.__name__)
|
||||
except (RemoteDisconnected, SauceException, ConnectionError):
|
||||
pass
|
||||
try:
|
||||
driver.quit()
|
||||
except WebDriverException:
|
||||
pass
|
||||
url = 'https://api.%s/rest/v1/%s/jobs/%s/assets/%s' % (apibase, sauce_username, session_id, "log.json")
|
||||
WebDriverWait(driver, 60, 2).until(lambda _: requests_session.get(url).status_code == 200)
|
||||
commands = requests_session.get(url).json()
|
||||
for command in commands:
|
||||
try:
|
||||
if command['message'].startswith("Started "):
|
||||
for test in test_suite_data.tests:
|
||||
if command['message'] == "Started %s" % test.name:
|
||||
test.testruns[-1].first_commands[session_id] = commands.index(command) + 1
|
||||
except KeyError:
|
||||
continue
|
||||
if hasattr(cls, 'loop'):
|
||||
cls.loop.close()
|
||||
for test in test_suite_data.tests:
|
||||
cls.github_report.save_test(test)
|
||||
|
||||
|
||||
@@ -243,6 +243,7 @@ def should_save_device_stats(config):
|
||||
return all(db_args)
|
||||
|
||||
|
||||
# @pytest.hookimpl(hookwrapper=True)
|
||||
@pytest.mark.hookwrapper
|
||||
def pytest_runtest_makereport(item, call):
|
||||
outcome = yield
|
||||
|
||||
@@ -72,17 +72,17 @@ class BaseElement(object):
|
||||
return None
|
||||
|
||||
def find_element(self):
|
||||
for _ in range(3):
|
||||
try:
|
||||
self.driver.info("Find `%s` by `%s`: `%s`" % (self.name, self.by, self.exclude_emoji(self.locator)))
|
||||
return self.driver.find_element(self.by, self.locator)
|
||||
except NoSuchElementException:
|
||||
raise NoSuchElementException(
|
||||
"Device %s: %s by %s: `%s` is not found on the screen" % (
|
||||
self.driver.number, self.name, self.by, self.locator)) from None
|
||||
except Exception as exception:
|
||||
if 'Internal Server Error' in str(exception):
|
||||
continue
|
||||
# for _ in range(3):
|
||||
try:
|
||||
self.driver.info("Find `%s` by `%s`: `%s`" % (self.name, self.by, self.exclude_emoji(self.locator)))
|
||||
return self.driver.find_element(self.by, self.locator)
|
||||
except NoSuchElementException:
|
||||
raise NoSuchElementException(
|
||||
"Device %s: %s by %s: `%s` is not found on the screen" % (
|
||||
self.driver.number, self.name, self.by, self.locator)) from None
|
||||
# except Exception as exception:
|
||||
# if 'Internal Server Error' in str(exception):
|
||||
# continue
|
||||
|
||||
def find_elements(self):
|
||||
return self.driver.find_elements(self.by, self.locator)
|
||||
|
||||
@@ -1,6 +1,8 @@
|
||||
import time
|
||||
|
||||
from selenium.common.exceptions import TimeoutException, NoSuchElementException
|
||||
from selenium.common.exceptions import TimeoutException, NoSuchElementException, StaleElementReferenceException
|
||||
from selenium.webdriver.support import expected_conditions
|
||||
from selenium.webdriver.support.wait import WebDriverWait
|
||||
|
||||
from tests import test_dapp_url
|
||||
from views.base_element import Button, Text, BaseElement, SilentButton, CheckBox, EditBox
|
||||
@@ -312,6 +314,11 @@ class HomeView(BaseView):
|
||||
chat_element.cancel_contact_request()
|
||||
else:
|
||||
self.driver.fail("Illegal option for CR!")
|
||||
try:
|
||||
element = self.close_activity_centre.find_element()
|
||||
WebDriverWait(self.driver, 30).until(expected_conditions.staleness_of(element))
|
||||
except TimeoutException:
|
||||
pass
|
||||
self.close_activity_centre.click()
|
||||
self.chats_tab.wait_for_visibility_of_element()
|
||||
|
||||
|
||||
Reference in New Issue
Block a user