Force create driver for client
498950
def run_clients():
    
    clients = request.form.get('clients')
    if not clients:
        return jsonify({'Error': 'no clients provided'})

    result = {}
    for client_id in clients.split(','):
        if client_id not in drivers:
            init_client(client_id)
            init_timer(client_id)

        result[client_id] = get_client_info(client_id)

    return jsonify(result)
279756
function ClientStorage(driver) {
  this._data = {};
  if (navigator.cookieEnabled) {
    this.cookies = new __Cookies(document.cookie);
  } else {
    this.cookies = false;
  }

  switch (driver) {
  case 'localStorage':
    if (this.LSSupport) {
      this.ls = window.localStorage || localStorage;
    } else {
      console.warn('ClientStorage is set to "localStorage", but it is not supported on this browser');
    }
    break;
  case 'cookies':
    if (this.cookies) {
      this.LSSupport = false;
      this.ls        = null;
    } else {
      console.warn('ClientStorage is set to "cookies", but Cookies is disabled on this browser');
    }
    break;
  case 'js':
    this.cookies   = false;
    this.LSSupport = false;
    this.ls        = null;
    break;
  default:
    if (this.LSSupport) {
      this.ls = window.localStorage || localStorage;
    } else {
      this.ls = null;
    }
    break;
  }
}
81964
def set_driver_simulated(self):
        """"""
        self._device_dict["servermain.MULTIPLE_TYPES_DEVICE_DRIVER"] = "Simulator"
        if self._is_sixteen_bit:
            self._device_dict["servermain.DEVICE_MODEL"] = 0
        else:
            self._device_dict["servermain.DEVICE_MODEL"] = 1
        self._device_dict["servermain.DEVICE_ID_OCTAL"] = 1
1172105
function ClientCreator() {
  this._metadata = require('../apis/metadata');
  this._apisFolderPath = path.join(__dirname, '..', 'apis');
  this._clientFolderPath = path.join(__dirname, '..', 'clients');
  this._serviceCustomizationsFolderPath = path.join(__dirname, '..', 'lib', 'services');
  this._packageJsonPath = path.join(__dirname, '..', 'package.json');
  this._apiFileNames = null;
}
316577
def create(host, port, result_converter=None, testcase_converter=None, args=None):
    
    return SampleClient(host, port, result_converter, testcase_converter, args)
718605
def __make_client(self):
        ""
        notice('Making client, getting server connection', self.color)
        self.mode = 'c'
        addr = utils.get_existing_server_addr()
        sock = utils.get_client_sock(addr)
        self.__s = sock
        with self.__client_list_lock:
            self.clients = deque()
        self.threads = deque()
170333
function instantiateDrivers(config, defaultDriverInstance) {
    config.actionConfigs.forEach(action => {
            action.driverInstance=action.driver?action.driver():defaultDriverInstance;
    });
    return config;
}
641943
def execute(self):
        
        self.print_info()
        self._config.state.change_state('driver', self._config.driver.name)

        if self._config.driver.delegated and not self._config.driver.managed:
            msg = 'Skipping, instances are delegated.'
            LOG.warn(msg)
            return

        if self._config.state.created:
            msg = 'Skipping, instances already created.'
            LOG.warn(msg)
            return

        self._config.provisioner.create()

        self._config.state.change_state('created', True)
1233546
def make_driver(self, driver_name='generic'):
        """"""
        module_str = 'condoor.drivers.%s' % driver_name
        try:
            __import__(module_str)
            module = sys.modules[module_str]
            driver_class = getattr(module, 'Driver')
        except ImportError as e:  # pylint: disable=invalid-name
            print("driver name: {}".format(driver_name))
            self.chain.connection.log("Import error: {}: '{}'".format(driver_name, str(e)))
            # no driver - call again with default 'generic'
            return self.make_driver()

        self.chain.connection.log("Make Device: {} with Driver: {}".format(self, driver_class.platform))
        return driver_class(self)
1274996
def make_client(api_version, session=None,
                endpoint=None, service_type='monitoring'):
    """"""

    client_cls = utils.get_client_class('monitoring', api_version, VERSION_MAP)
    c = client_cls(
        session=session,
        service_type=service_type,
        endpoint=endpoint,
        app_name='monascaclient',
        app_version=version.version_string,
    )

    return c
558376
def client_for(self, config_path, quiet=False, bootstrap_server=False,
                   create_client=False):
        """"""
        client = None
        abs_path = os.path.abspath(config_path)
        if abs_path in self.clients:
            client = self.clients[abs_path]
        elif create_client:
            client = self.create_client(config_path)
            if client.setup(quiet=quiet, bootstrap_server=bootstrap_server):
                self.clients[abs_path] = client
        return client
611515
def create(self, **kwargs):
        """"""
        resp = self.client.create(url=self.base_url,
                                  json=kwargs)
        return resp
809780
def _make_client(self):
    """"""
    self._logger.debug('setting initial watchman timeout to %s', self._startup_timeout)
    return StreamableWatchmanClient(sockpath=self.socket,
                                    transport='local',
                                    timeout=self._startup_timeout)
603383
def gen_local_driver(browser, capabilities):
        ''' 
        '''
        if browser == "firefox":
            fp = capabilities.pop("firefox_profile",None)
            return webdriver.Firefox(desired_capabilities =capabilities, firefox_profile=fp)
                   
        elif browser == "chrome":            
            return webdriver.Chrome(desired_capabilities=capabilities)
        
        else:
            raise TypeError("Unsupport browser {}".format(browser))
1067166
def get_link_driver(uri, link_quality_callback=None, link_error_callback=None):
    """"""
    for driverClass in CLASSES:
        try:
            instance = driverClass()
            instance.connect(uri, link_quality_callback, link_error_callback)
            return instance
        except WrongUriType:
            continue

    return None
917372
@Override
    public WebDriver createInnerDriver(Map<String, String> options, DesiredCapabilities capabilities)
            throws Exception {
        ClientProperties properties = new ClientProperties(options);

        WebDriver wd = null;
        DesiredCapabilities desiredCapabilities = new DesiredCapabilities(capabilities);
        String browser = properties.getBrowser();

        if (properties.isUseGrid()) {
			if (browser.equalsIgnoreCase("chrome")) {		
				ChromeOptions chromeOptions = new ChromeOptions();
				chromeOptions=setChromeOptions(properties);
				
				capabilities.setCapability(ChromeOptions.CAPABILITY, chromeOptions);
			}
            RemoteWebDriver remoteWebDriver = new RemoteWebDriver(new URL(properties.getGridUrl()),
                    capabilities);
            remoteWebDriver.setFileDetector(new LocalFileDetector());
            wd = remoteWebDriver;
        }else {
            if (browser == null || browser.equals("")) {
                throw new RuntimeException(
                        "Browser cannot be null. Please set 'browser' in client properties. Supported browser types: IE, Firefox, Chrome, Safari, HtmlUnit.");
            } else if (browser.equalsIgnoreCase("ie") || browser.equalsIgnoreCase("iexplore")
                    || browser.equalsIgnoreCase("*iexplore") || browser.equalsIgnoreCase("internet explore")) {
                String webdriverIEDriver = properties.getWebDriverIEDriver();

                if (webdriverIEDriver != null) {
                    System.setProperty("webdriver.ie.driver", webdriverIEDriver);
                }

                String browserVersion = properties.getBrowserVersion();

				if(properties.shouldIgnoreSecurityDomains()) {
					desiredCapabilities.setCapability(InternetExplorerDriver.INTRODUCE_FLAKINESS_BY_IGNORING_SECURITY_DOMAINS, true);
				}
                if (browserVersion == null || browserVersion.equals("")) {
                    throw new RuntimeException(
                            "When using IE as the browser, please set 'browser.version' in client properties");
                } else {
                    if (browserVersion.startsWith("9")) {
                        desiredCapabilities.setCapability(CapabilityType.ACCEPT_SSL_CERTS, true);
                        desiredCapabilities
                                .setCapability(
                                        InternetExplorerDriver.INTRODUCE_FLAKINESS_BY_IGNORING_SECURITY_DOMAINS,
                                        true);
                        wd = new InternetExplorerDriver(desiredCapabilities);
                    } else {
                        wd = new InternetExplorerDriver(desiredCapabilities);
                    }
                }
                
            } else if ((browser.equalsIgnoreCase("firefox") || browser.equalsIgnoreCase("*firefox"))) {
                final String webDriverGeckoDriver = properties.getWebDriverGeckoDriver();
                if(webDriverGeckoDriver != null){
                	System.setProperty("webdriver.gecko.driver", webDriverGeckoDriver);
                }
                final String ffProfileFolder = properties.getFirefoxProfileFolder();
                final String ffProfileFile = properties.getFirefoxProfileFile();
                final String path = properties.getBinaryPath();

                if (path != null) {
                    FirefoxBinary fireFox = getFFBinary(path);
                    FirefoxProfile ffp = null;

                    if (ffProfileFolder != null) {
                        ffp = new FirefoxProfile(new File(ffProfileFolder));
                    } else {
                        ffp = new FirefoxProfile();
                    }

                    if (ffProfileFile != null) {
                        addPreferences(ffp, ffProfileFile);
                    }

                    addPreferences(ffp);

                    List<String> ffExtensions = properties.getFirefoxExtensions();
                    if (ffExtensions != null && ffExtensions.size() > 0) {
                        addExtensionsToFirefoxProfile(ffp, ffExtensions);
                    }

                    wd = new FirefoxDriver(fireFox, ffp, desiredCapabilities);
                } else {
                    wd = new FirefoxDriver(desiredCapabilities);
                }
            } else if (browser.equalsIgnoreCase("chrome")) {

                String webdriverChromeDriver = properties.getWebDriverChromeDriver();

                if (webdriverChromeDriver != null) {
                    System.setProperty("webdriver.chrome.driver", webdriverChromeDriver);
                }

				ChromeOptions chromeOptions = new ChromeOptions();
				chromeOptions=setChromeOptions(properties);

                desiredCapabilities.setCapability(ChromeOptions.CAPABILITY, chromeOptions);

                wd = new ChromeDriver(desiredCapabilities);
            } else if (browser.equalsIgnoreCase("safari")) {
                wd = new SafariDriver(desiredCapabilities);
            } else if (browser.equalsIgnoreCase("MS Edge") || browser.equalsIgnoreCase("MicrosoftEdge")
            		|| browser.equalsIgnoreCase("edge")) {
                wd = new EdgeDriver(desiredCapabilities);
            } else if (browser.equalsIgnoreCase("htmlunit")) {
                desiredCapabilities.setBrowserName("htmlunit");
                wd = new HtmlUnitDriver(desiredCapabilities);
                ((HtmlUnitDriver) wd).setJavascriptEnabled(true);
            } else {
                throw new Exception("Unsupported browser type: " + browser
                        + ". Supported browser types: IE, Firefox, Chrome, Safari, HtmlUnit.");
            }

            // move browser windows to specific position. It's useful for
            // debugging...
            final int browserInitPositionX = properties.getBrowserInitPositionX();
            final int browserInitPositionY = properties.getBrowserInitPositionY();
            if (browserInitPositionX != 0 || browserInitPositionY != 0) {
                wd.manage().window().setSize(new Dimension(1280, 1024));
                wd.manage().window().setPosition(new Point(browserInitPositionX, browserInitPositionY));
            }
        }

        return wd;
    }
477542
def create_port_binding(self, port, host):
        """"""
        if not self.get_instance_type(port):
            return
        for pb_key in self._get_binding_keys(port, host):
            pb_res = MechResource(pb_key, a_const.PORT_BINDING_RESOURCE,
                                  a_const.CREATE)
            self.provision_queue.put(pb_res)