Пример #1
0
def driver(request):
    kwargs = {}

    try:
        driver_class = request.param
    except AttributeError:
        raise Exception('This test requires a --driver to be specified.')

    # conditionally mark tests as expected to fail based on driver
    request.node._evalxfail = request.node._evalxfail or MarkEvaluator(
        request.node, 'xfail_{0}'.format(driver_class.lower()))
    if request.node._evalxfail.istrue():

        def fin():
            global driver_instance
            if driver_instance is not None:
                driver_instance.quit()
            driver_instance = None

        request.addfinalizer(fin)

    # skip driver instantiation if xfail(run=False)
    if not request.config.getoption('runxfail'):
        if request.node._evalxfail.istrue():
            if request.node._evalxfail.get('run') is False:
                yield
                return

    global driver_instance
    if driver_instance is None:
        if driver_class == 'BlackBerry':
            kwargs.update({'device_password': '******'})
        if driver_class == 'Firefox':
            kwargs.update({'capabilities': {'marionette': False}})
        if driver_class == 'Marionette':
            driver_class = 'Firefox'
        if driver_class == 'Remote':
            capabilities = DesiredCapabilities.FIREFOX.copy()
            capabilities['marionette'] = False
            kwargs.update({'desired_capabilities': capabilities})
        if driver_class == 'WebKitGTK':
            additional_args = {}
            options = webdriver.WebKitGTKOptions()
            options.overlay_scrollbars_enabled = False
            browser_path = os.environ.get('WD_BROWSER_PATH')
            if browser_path is not None:
                options.browser_executable_path = browser_path
            browser_args = os.environ.get('WD_BROWSER_ARGS')
            if browser_args is not None:
                for arg in browser_args.split():
                    options.add_browser_argument(arg)
            additional_args['options'] = options
            driver_path = os.environ.get('WD_DRIVER_PATH')
            if driver_path is not None:
                additional_args['executable_path'] = driver_path
            kwargs.update(additional_args)
        driver_instance = getattr(webdriver, driver_class)(**kwargs)
    yield driver_instance
    if MarkEvaluator(request.node, 'no_driver_after_test').istrue():
        driver_instance = None
Пример #2
0
    def start_engine(self, headless=None):
        print("driver", self.driver_path)
        safari_options = webdriver.WebKitGTKOptions()

        if headless is None:
            headless = HEADLESS

        if isinstance(headless, str):
            headless = str2bool(headless)

        safari_options.headless = headless
        print("Headless mode: '{0}'".format(headless), type(headless))

        self._driver = webdriver.Safari(executable_path=self.driver_path)
        self._driver.set_window_size(1440, 900)
Пример #3
0
    def setUp(self):
        self.vars = {}

        timeout = 30.0
        options = webdriver.WebKitGTKOptions()
        options.ignore_local_proxy_environment_variables()
        options.add_argument('one')
        options.add_argument('two')
        options.set_capability('browserName', 'safari')
        self.driver = webdriver.Remote(
            command_executor=
            'http://addr-of-remote-server.com/api/v4/grid/wd/hub',
            options=options)
        self.driver.implicitly_wait(timeout)
        add_flow_markers()
        apiritif.put_into_thread_store(timeout=timeout,
                                       func_mode=False,
                                       driver=self.driver,
                                       windows={},
                                       scenario_name='remote_sc')
Пример #4
0
    def setUp(self):
        self.vars = {}

        timeout = 30.0
        options = webdriver.WebKitGTKOptions()
        options.add_argument('one')
        options.add_argument('two')
        self.driver = webdriver.Remote(
            command_executor=
            'http://*****:*****@remote_web_driver:port/api/v4/grid/wd/hub',
            desired_capabilities={
                'browserName': 'safari',
                'cap1': 'val1',
                'cap2': 'val2'
            },
            options=options)
        self.driver.implicitly_wait(timeout)
        add_flow_markers()
        apiritif.put_into_thread_store(timeout=timeout,
                                       func_mode=False,
                                       driver=self.driver,
                                       windows={},
                                       scenario_name='loc_sc_remote')
Пример #5
0
FUZZ = "fuzz"
UNDERSLASH = "_"
EMPTY_STRING = ""
HTML_EXTENSION = ".html"
FILE_PREFIX = "file://"

BROWSER_COMMAND = "epiphany"
PAGE_LOAD_TIMEOUT = 30

SUCCESS_FLAG = "success"
TIMEOUT_FLAG = "timeout"
CRASH_FLAG = "crash"
ERROR_FLAG = "error"

options = webdriver.WebKitGTKOptions()
options.binary_location = BROWSER_COMMAND
options.add_argument("--automation-mode")
options.set_capability("browserName", "Epiphany")
options.set_capability('version', '3.31.4')


def main():
    if len(argv) < 2:
        raise Exception("Must provide a valid html base directory")
    if len(argv) < 3:
        raise Exception("Must provide a valid results directory")

    html_dir = argv[1]
    results_dir = argv[2]