Set up the selenium driver and connect to the server

        :param maximize: True if the driver should be maximized
        :returns: selenium driver
349416
def connect(self, maximize=True):
        
        if not self.config.get('Driver', 'type') or self.config.get('Driver', 'type') in ['api', 'no_driver']:
            return None

        self.driver = ConfigDriver(self.config, self.utils).create_driver()

        # Save session id and remote node to download video after the test execution
        self.session_id = self.driver.session_id
        self.server_type, self.remote_node = self.utils.get_remote_node()
        if self.server_type == 'grid':
            self.remote_node_video_enabled = self.utils.is_remote_video_enabled(self.remote_node)
        else:
            self.remote_node_video_enabled = True if self.server_type in ['ggr', 'selenoid'] else False

            # Save app_strings in mobile tests
        if self.is_mobile_test() and not self.is_web_test() and self.config.getboolean_optional('Driver',
                                                                                                'appium_app_strings'):
            self.app_strings = self.driver.app_strings()

        if self.is_maximizable():
            # Bounds and screen
            bounds_x, bounds_y = self.get_config_window_bounds()
            self.driver.set_window_position(bounds_x, bounds_y)
            self.logger.debug('Window bounds: %s x %s', bounds_x, bounds_y)

            # Maximize browser
            if maximize:
                # Set window size or maximize
                window_width = self.config.get_optional('Driver', 'window_width')
                window_height = self.config.get_optional('Driver', 'window_height')
                if window_width and window_height:
                    self.driver.set_window_size(window_width, window_height)
                else:
                    self.driver.maximize_window()

        # Log window size
        window_size = self.utils.get_window_size()
        self.logger.debug('Window size: %s x %s', window_size['width'], window_size['height'])

        # Update baseline
        self.update_visual_baseline()

        # Discard previous logcat logs
        self.utils.discard_logcat_logs()

        # Set implicitly wait timeout
        self.utils.set_implicitly_wait()

        return self.driver
181338
def __create_driver_from_browser_config(self):
        '''
        
        '''
        try:
            browser_type = self._config_reader.get(
                WebDriverFactory.BROWSER_TYPE_CONFIG)
        except KeyError:
            _wtflog("%s missing is missing from config file. Using defaults",
                    WebDriverFactory.BROWSER_TYPE_CONFIG)
            browser_type = WebDriverFactory.FIREFOX

        # Special Chrome Sauce
        options = webdriver.ChromeOptions()
        options.add_experimental_option("excludeSwitches", ["ignore-certificate-errors"])
        options.add_argument("always-authorize-plugins")

        browser_type_dict = {
            self.CHROME: lambda: webdriver.Chrome(
                self._config_reader.get(WebDriverFactory.CHROME_DRIVER_PATH),
                chrome_options=options),
            self.FIREFOX: lambda: webdriver.Firefox(),
            self.INTERNETEXPLORER: lambda: webdriver.Ie(),
            self.OPERA: lambda: webdriver.Opera(),
            self.PHANTOMJS: lambda: self.__create_phantom_js_driver(),
            self.SAFARI: lambda: self.__create_safari_driver()
        }

        try:
            return browser_type_dict[browser_type]()
        except KeyError:
            raise TypeError(
                u("Unsupported Browser Type {0}").format(browser_type))
1089190
def driver(self):
        """"""
        from dallinger.config import get_config

        config = get_config()
        if not config.ready:
            config.load()
        driver_url = config.get("webdriver_url", None)
        driver_type = config.get("webdriver_type")
        driver = None

        if driver_url:
            capabilities = CAPABILITY_MAP.get(driver_type.lower())
            if capabilities is None:
                raise ValueError(
                    "Unsupported remote webdriver_type: {}".format(driver_type)
                )
            driver = webdriver.Remote(
                desired_capabilities=capabilities, command_executor=driver_url
            )
        else:
            driver_class = DRIVER_MAP.get(driver_type.lower())
            if driver_class is not None:
                driver = driver_class()

        if driver is None:
            raise ValueError("Unsupported webdriver_type: {}".format(driver_type))

        driver.set_window_size(1024, 768)
        logger.info("Created {} webdriver.".format(driver_type))
        return driver
1345017
def init_driver(client_id):
    

    # Create profile directory if it does not exist
    profile_path = CHROME_CACHE_PATH + str(client_id)
    if not os.path.exists(profile_path):
        os.makedirs(profile_path)
    
    # Options to customize chrome window
    chrome_options = [
        'window-size=' + CHROME_WINDOW_SIZE,
        '--user-agent=Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Ubuntu Chromium/60.0.3112.78 Chrome/60.0.3112.78 Safari/537.36'
    ]
    if CHROME_IS_HEADLESS:
        chrome_options.append('--headless')
    if CHROME_DISABLE_GPU:
        chrome_options.append('--disable-gpu')
    
    # Create a whatsapidriver object
    d = WhatsAPIDriver(
        username=client_id, 
        profile=profile_path, 
        client='chrome', 
        chrome_options=chrome_options
    )
    return d
1020465
def start(self):
        
        LOGGER.debug("rest.Driver.start")
        self.session = requests.Session()
        self.session.auth = (self.user, self.password)
348725
private Connection getConnectionViaDriverMangaer(String driver, String url, String user, String password) {

        Connection conn = null;
        try {
            Class.forName(driver);
            conn = DriverManager.getConnection(url, user, password);
        } catch (ClassNotFoundException e) {
            e.printStackTrace();
        } catch (SQLException e) {
            e.printStackTrace();
        }
        return conn;
    }
631029
def get_driver(self, name, version):
        
        user_credentials = self.get_user_credentials()  # get credentials
        return discovery.build(
            name, version,
            http=self.authenticate(user_credentials)
        )
94236
def reset(self):
        
        # Kill old connection
        self.quit()
        # Clear chrome configs
        self.opts = webdriver.ChromeOptions()
        # Create new web driver
        self._create_session()
1029459
def get_default_wrapper(cls):
        
        if cls.is_empty():
            # Create a new driver wrapper if the pool is empty
            from toolium.driver_wrapper import DriverWrapper
            DriverWrapper()
        return cls.driver_wrappers[0]
1240517
def connect_wrapper(context_or_world):
    
    # Create driver if it is not already created
    if context_or_world.driver_wrapper.driver:
        context_or_world.driver = context_or_world.driver_wrapper.driver
    else:
        context_or_world.driver = context_or_world.driver_wrapper.connect()

    # Copy app_strings object
    context_or_world.app_strings = context_or_world.driver_wrapper.app_strings
878577
def connect(self, driver):
        """"""
        #              0            1                              2                      3
        events = [ESCAPE_CHAR, driver.press_return_re, driver.standby_re, driver.username_re,
                  #            4                   5                  6                     7
                  driver.password_re, driver.more_re, self.device.prompt_re, driver.rommon_re,
                  #       8                              9              10            11              12
                  driver.unable_to_connect_re, driver.timeout_re, pexpect.TIMEOUT, PASSWORD_OK, driver.syntax_error_re]

        transitions = [
            (ESCAPE_CHAR, [0], 1, None, _C['esc_char_timeout']),
            (driver.syntax_error_re, [0], -1, CommandSyntaxError("Command syntax error"), 0),
            (driver.press_return_re, [0, 1], 1, a_send_newline, 10),
            (PASSWORD_OK, [0, 1], 1, a_send_newline, 10),
            (driver.standby_re, [0, 5], -1, partial(a_standby_console), 0),
            (driver.username_re, [0, 1, 5, 6], -1, partial(a_save_last_pattern, self), 0),
            (driver.password_re, [0, 1, 5], -1, partial(a_save_last_pattern, self), 0),
            (driver.more_re, [0, 5], 7, partial(a_send, "q"), 10),
            # router sends it again to delete
            (driver.more_re, [7], 8, None, 10),
            # (prompt, [0, 1, 5], 6, a_send_newline, 10),
            (self.device.prompt_re, [0, 1, 5], 0, None, 10),
            (self.device.prompt_re, [6, 8, 5], -1, partial(a_save_last_pattern, self), 0),
            (driver.rommon_re, [0, 1, 5], -1, partial(a_save_last_pattern, self), 0),
            (driver.unable_to_connect_re, [0, 1, 5], -1, a_unable_to_connect, 0),
            (driver.timeout_re, [0, 1, 5], -1, ConnectionTimeoutError("Connection Timeout", self.hostname), 0),
            (pexpect.TIMEOUT, [0, 1], 5, a_send_newline, 10),
            (pexpect.TIMEOUT, [5], -1, ConnectionTimeoutError("Connection timeout", self.hostname), 0)
        ]

        self.log("EXPECTED_PROMPT={}".format(pattern_to_str(self.device.prompt_re)))
        # setting max_transitions to large number to swallow prompt like strings from prompt
        fsm = FSM("TELNET-CONNECT", self.device, events, transitions, timeout=_C['connect_timeout'],
                  init_pattern=self.last_pattern, max_transitions=500)
        return fsm.run()
1204347
def copy_user_agent_from_driver(self):
        
        selenium_user_agent = self.driver.execute_script("return navigator.userAgent;")
        self.headers.update({"user-agent": selenium_user_agent})
333804
def _setup_edge(self, capabilities):
        
        edge_driver = self.config.get('Driver', 'edge_driver_path')
        self.logger.debug("Edge driver path given in properties: %s", edge_driver)
        return webdriver.Edge(edge_driver, capabilities=capabilities)
634163
def __create_phantom_js_driver(self):
        '''
        
        '''
        try:
            return webdriver.PhantomJS(executable_path=self._config_reader.get(self.PHANTOMEJS_EXEC_PATH),
                                       service_args=['--ignore-ssl-errors=true'])
        except KeyError:
            return webdriver.PhantomJS(service_args=['--ignore-ssl-errors=true'])
1238763
def get_driver(configuration):
    
    resources = configuration["resources"]
    machines = resources["machines"]
    networks = resources["networks"]
    oargrid_jobids = configuration.get("oargrid_jobids")

    if oargrid_jobids:
        logger.debug("Loading the OargridStaticDriver")
        return OargridStaticDriver(oargrid_jobids)
    else:
        job_name = configuration.get("job_name", DEFAULT_JOB_NAME)
        walltime = configuration.get("walltime", DEFAULT_WALLTIME)
        job_type = configuration.get("job_type", JOB_TYPE_DEPLOY)
        reservation_date = configuration.get("reservation", False)
        # NOTE(msimonin): some time ago asimonet proposes to auto-detect
        # the queues and it was quiet convenient
        # see https://github.com/BeyondTheClouds/enos/pull/62
        queue = configuration.get("queue", None)
        logger.debug("Loading the OargridDynamicDriver")

        return OargridDynamicDriver(
            job_name,
            walltime,
            job_type,
            reservation_date,
            queue,
            machines,
            networks
        )
1062006
def _setup_opera(self, capabilities):
        
        opera_driver = self.config.get('Driver', 'opera_driver_path')
        self.logger.debug("Opera driver path given in properties: %s", opera_driver)
        return webdriver.Opera(executable_path=opera_driver, desired_capabilities=capabilities)
148440
def new_driver(browser_name, *args, **kwargs):
        
        if browser_name == FIREFOX:
            return webdriver.Firefox(*args, **kwargs)

        # elif options['local'] and options['browser_name'] == CHROME:
        #     return webdriver.Chrome(*args, **kwargs)
        #
        # elif options['local'] and options['browser_name'] == IE:
        #     return webdriver.Ie(*args, **kwargs)
        #
        # elif options['local'] and options['browser_name'] == OPERA:
        #     return webdriver.Opera(*args, **kwargs)

        elif browser_name == PHANTOMJS:
            executable_path = os.path.join(os.path.dirname(__file__), 'phantomjs/executable/phantomjs_64bit')
            driver = webdriver.PhantomJS(executable_path=executable_path, **kwargs)
            driver.set_window_size(1280, 800)  # Set a default because phantom needs it
            return driver

        else:  # remote
            driver = webdriver.Remote(*args, **kwargs)
            return driver