1from .base import require_arg 2from .base import get_timeout_multiplier # noqa: F401 3from .chrome import ChromeBrowser 4from ..executors import executor_kwargs as base_executor_kwargs 5from ..executors.base import WdspecExecutor # noqa: F401 6from ..executors.executorselenium import (SeleniumTestharnessExecutor, # noqa: F401 7 SeleniumRefTestExecutor) # noqa: F401 8 9 10__wptrunner__ = {"product": "opera", 11 "check_args": "check_args", 12 "browser": "OperaBrowser", 13 "executor": {"testharness": "SeleniumTestharnessExecutor", 14 "reftest": "SeleniumRefTestExecutor", 15 "wdspec": "WdspecExecutor"}, 16 "browser_kwargs": "browser_kwargs", 17 "executor_kwargs": "executor_kwargs", 18 "env_extras": "env_extras", 19 "env_options": "env_options", 20 "timeout_multiplier": "get_timeout_multiplier"} 21 22 23def check_args(**kwargs): 24 require_arg(kwargs, "webdriver_binary") 25 26 27def browser_kwargs(logger, test_type, run_info_data, config, **kwargs): 28 return {"binary": kwargs["binary"], 29 "webdriver_binary": kwargs["webdriver_binary"], 30 "webdriver_args": kwargs.get("webdriver_args")} 31 32 33def executor_kwargs(logger, test_type, test_environment, run_info_data, 34 **kwargs): 35 from selenium.webdriver import DesiredCapabilities 36 37 executor_kwargs = base_executor_kwargs(test_type, test_environment, run_info_data, **kwargs) 38 executor_kwargs["close_after_done"] = True 39 capabilities = dict(DesiredCapabilities.OPERA.items()) 40 capabilities.setdefault("operaOptions", {})["prefs"] = { 41 "profile": { 42 "default_content_setting_values": { 43 "popups": 1 44 } 45 } 46 } 47 for (kwarg, capability) in [("binary", "binary"), ("binary_args", "args")]: 48 if kwargs[kwarg] is not None: 49 capabilities["operaOptions"][capability] = kwargs[kwarg] 50 if test_type == "testharness": 51 capabilities["operaOptions"]["useAutomationExtension"] = False 52 capabilities["operaOptions"]["excludeSwitches"] = ["enable-automation"] 53 if test_type == "wdspec": 54 capabilities["operaOptions"]["w3c"] = True 55 executor_kwargs["capabilities"] = capabilities 56 return executor_kwargs 57 58 59def env_extras(**kwargs): 60 return [] 61 62 63def env_options(): 64 return {} 65 66 67class OperaBrowser(ChromeBrowser): 68 pass 69