-
Notifications
You must be signed in to change notification settings - Fork 0
/
conftest.py
46 lines (36 loc) · 1.65 KB
/
conftest.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
import pytest
import yaml
from appium import webdriver
from appium.options.android import UiAutomator2Options
pytest_plugins = 'pytester'
def load_caps_from_yaml(path):
with open(path, 'r') as file:
return yaml.safe_load(file)
@pytest.fixture(scope='function')
def init_driver(request):
desired_caps = load_caps_from_yaml('/platform/V13_caps.yml')
options = UiAutomator2Options()
options.udid = desired_caps['caps']['appium:udid']
options.platform_name = desired_caps['caps']['platformName']
options.app_package = desired_caps['caps']['appium:appPackage']
options.app_activity = desired_caps['caps']['appium:appActivity']
options.no_reset = desired_caps['caps']['appium:noReset']
options.full_reset = desired_caps['caps']['appium:fullReset']
options.automation_name = desired_caps['caps']['appium:automationName']
options.auto_webview = desired_caps['caps']['appium:autoWebView']
options.set_web_contents_debugging_enabled = desired_caps['caps']['appium:setWebContentsDebuggingEnabled']
options.auto_accept_alerts = desired_caps['caps']['appium:autoAcceptAlerts']
options.new_command_timeout = desired_caps['caps']['appium:newCommandTimeout']
driver = webdriver.Remote(
command_executor=desired_caps['appium_lib']['server_url'],
options=options
)
request.cls.driver = driver
yield driver
driver.quit()
def pytest_configure(config):
terminal_reporter = config.pluginmanager.getplugin('terminalreporter')
if terminal_reporter is not None:
terminal_reporter.section_title = lambda x: None
def pytest_sessionfinish(session, exitstatus):
session.config._html = None