Exemplo n.º 1
0
def _get_driver(capabilities):
    logger.debug('Creating web driver')
    start_time = datetime.now()
    # set resolve_ip to false to make it work in cases when remote driver is running in OpenShift
    command_executor = RemoteConnection(cfg.selenium.web_driver,
                                        resolve_ip=False)
    # increase the timeout because we are waiting for new pod to be created which takes some time
    command_executor.set_timeout(120)
    driver = webdriver.Remote(command_executor,
                              desired_capabilities=capabilities)
    # reset the timeout to default, only driver creation is taking so much time
    command_executor.reset_timeout()
    _delta = datetime.now() - start_time
    logger.debug('Web driver created successfully. Time taken: {} ms'.format(
        int(_delta.total_seconds() * 1000)))
    return driver
Exemplo n.º 2
0
def _get_driver(capabilities):
    logger.debug('Creating web driver')
    start_time = datetime.now()
    # set resolve_ip to false to make it work in cases when remote driver is running in OpenShift
    # https://github.com/ddavison/selenium-openshift-templates/issues/6
    command_executor = RemoteConnection(cfg.selenium.web_driver,
                                        resolve_ip=False)
    # increase the timeout because we are waiting for new pod to be created which takes some time
    command_executor.set_timeout(120)
    # using keep_alive=True which should save some connections
    # https://github.com/SeleniumHQ/selenium/issues/5758
    # and https://github.com/seleniumhq/selenium/issues/3457
    driver = webdriver.Remote(command_executor,
                              desired_capabilities=capabilities,
                              options=_get_browser_options(),
                              keep_alive=True)
    # reset the timeout to default, only driver creation is taking so much time
    command_executor.reset_timeout()
    _delta = datetime.now() - start_time
    logger.debug('Web driver created successfully. Time taken: {} ms'.format(
        int(_delta.total_seconds() * 1000)))
    return driver