e2e: separated tests to run in PRs

This commit is contained in:
Yevheniia Berdnyk 2024-07-02 15:38:06 +03:00
parent 5f085e9cea
commit 0f3538756a
No known key found for this signature in database
4 changed files with 54 additions and 20 deletions

View File

@ -18,7 +18,7 @@ from selenium.webdriver.support.wait import WebDriverWait
from urllib3.exceptions import MaxRetryError, ProtocolError
from support.api.network_api import NetworkApi
from tests import test_suite_data, start_threads, appium_container, pytest_config_global, transl
from tests import test_suite_data, start_threads, appium_container, pytest_config_global, transl, run_in_parallel
from tests.conftest import sauce_username, sauce_access_key, apibase, github_report, run_name
executor_sauce_lab = 'https://%s:%s@ondemand.%s:443/wd/hub' % (sauce_username, sauce_access_key, apibase)
@ -60,14 +60,11 @@ def add_local_devices_to_capabilities():
return updated_capabilities
def get_capabilities_sauce_lab():
def get_common_capabilities():
caps = dict()
caps['platformName'] = 'Android'
caps['idleTimeout'] = 1000
caps['appium:app'] = 'sauce-storage:' + test_suite_data.apk_name
caps['appium:deviceName'] = 'Android GoogleAPI Emulator'
caps['appium:deviceOrientation'] = 'portrait'
caps['appium:platformVersion'] = '14.0'
caps['appium:automationName'] = 'UiAutomator2'
caps['appium:newCommandTimeout'] = 600
caps['appium:idleTimeout'] = 1000
@ -81,7 +78,6 @@ def get_capabilities_sauce_lab():
caps['appium:enforceXPath1'] = True
caps['enforceXPath1'] = True
caps['sauce:options'] = dict()
caps['sauce:options']['appiumVersion'] = '2.0.0'
caps['sauce:options']['username'] = sauce_username
caps['sauce:options']['accessKey'] = sauce_access_key
caps['sauce:options']['build'] = run_name
@ -89,6 +85,15 @@ def get_capabilities_sauce_lab():
caps['sauce:options']['maxDuration'] = 3600
caps['sauce:options']['idleTimeout'] = 1000
caps['sauce:options']['android.gpu.mode'] = 'hardware'
return caps
def get_capabilities_sauce_lab():
caps = get_common_capabilities()
caps['appium:app'] = 'sauce-storage:' + test_suite_data.apk_name
caps['appium:deviceName'] = 'Android GoogleAPI Emulator'
caps['appium:platformVersion'] = '14.0'
caps['sauce:options']['appiumVersion'] = '2.0.0'
options = AppiumOptions()
options.load_capabilities(caps)
@ -96,10 +101,17 @@ def get_capabilities_sauce_lab():
return options
# def update_capabilities_sauce_lab(new_capabilities: dict):
# caps = get_capabilities_sauce_lab().copy()
# caps.update(new_capabilities)
# return caps
def get_capabilities_real_device():
caps = get_common_capabilities()
caps['appium:app'] = 'sauce-storage:' + pytest_config_global['apk_real_device']
caps['appium:deviceName'] = pytest_config_global['real_device_name']
caps['appium:platformVersion'] = '14'
caps['sauce:options']['appiumVersion'] = 'latest'
options = AppiumOptions()
options.load_capabilities(caps)
return options
def get_app_path():
@ -306,12 +318,23 @@ def create_shared_drivers(quantity):
asyncio.set_event_loop(loop)
print('SC Executor: %s' % executor_sauce_lab)
try:
drivers = loop.run_until_complete(start_threads(test_suite_data.current_test.name,
quantity,
Driver,
drivers,
command_executor=executor_sauce_lab,
options=get_capabilities_sauce_lab()))
if pytest_config_global['apk_real_device']:
commands = [
(Driver, {'command_executor': executor_sauce_lab, 'options': get_capabilities_real_device()}),
]
if quantity > 1:
for i in range(quantity - 1):
commands.append(
(Driver, {'command_executor': executor_sauce_lab, 'options': get_capabilities_sauce_lab()})
)
drivers = loop.run_until_complete(run_in_parallel((tuple(commands))))
else:
drivers = loop.run_until_complete(start_threads(test_suite_data.current_test.name,
quantity,
Driver,
drivers,
command_executor=executor_sauce_lab,
options=get_capabilities_sauce_lab()))
if len(drivers) < quantity:
test_suite_data.current_test.testruns[-1].error = "Not all %s drivers are created" % quantity

View File

@ -46,7 +46,7 @@ def pytest_addoption(parser):
help='Android device platform version')
parser.addoption('--log_steps',
action='store',
default=False,
default=True,
help='Display each test step in terminal as plain text: True/False')
parser.addoption('--pr_number',
action='store',
@ -75,6 +75,16 @@ def pytest_addoption(parser):
default=None,
help='Url or local path to apk for upgrade')
# running on real devices
parser.addoption('--apk_real_device',
action='store',
default=None,
help='Url or local path to apk to be run on real device')
parser.addoption('--real_device_name',
action='store',
default='Samsung Galaxy S.*',
help='Real device name or name pattern')
# chat bot
parser.addoption('--messages_number',

View File

@ -579,6 +579,7 @@ class HomeView(BaseView):
def get_link_to_profile(self):
self.show_qr_code_button.click()
self.link_to_profile_button.click()
self.sharing_text_native.wait_for_visibility_of_element()
link_to_profile = self.sharing_text_native.text
self.click_system_back_button()
return link_to_profile

View File

@ -3,7 +3,7 @@ import os
from selenium.common.exceptions import NoSuchElementException
from tests import common_password, appium_root_project_path
from tests import common_password, appium_root_project_path, pytest_config_global
from tests.base_test_case import get_app_path
from views.base_element import Button, EditBox, Text
from views.base_view import BaseView
@ -244,8 +244,8 @@ class SignInView(BaseView):
self.generate_keys_button.click_until_presence_of_element(self.profile_title_input)
self.set_profile(username)
self.set_password(password)
# if self.enable_biometric_maybe_later_button.is_element_displayed(10):
# self.enable_biometric_maybe_later_button.click()
if pytest_config_global['apk_real_device']:
self.enable_biometric_maybe_later_button.wait_and_click()
# self.next_button.click_until_absense_of_element(self.element_by_translation_id("intro-wizard-title2"))
# if keycard:
# keycard_flow = self.keycard_storage_button.click()