MCPcopy Create free account
hub / github.com/SeleniumHQ/selenium / createSession

Method createSession

javascript/selenium-webdriver/firefox.js:467–509  ·  view source on GitHub ↗

* Creates a new Firefox session. * * @param {(Options|Capabilities|Object)=} opt_config The * configuration options for this driver, specified as either an * Options or Capabilities, or as a raw hash object. * @param {(http.Executor|remote.DriverService)=} opt_ex

(opt_config, opt_executor)

Source from the content-addressed store, hash-verified

465 * @return {!Driver} A new driver instance.
466 */
467 static createSession(opt_config, opt_executor) {
468 let caps = opt_config instanceof Capabilities ? opt_config : new Options(opt_config)
469
470 let firefoxBrowserPath = null
471
472 let executor
473 let onQuit
474
475 if (opt_executor instanceof http.Executor) {
476 executor = opt_executor
477 configureExecutor(executor)
478 } else if (opt_executor instanceof remote.DriverService) {
479 if (!opt_executor.getExecutable()) {
480 const { driverPath, browserPath } = getBinaryPaths(caps)
481 opt_executor.setExecutable(driverPath)
482 firefoxBrowserPath = browserPath
483 }
484 executor = createExecutor(opt_executor.start())
485 onQuit = () => opt_executor.kill()
486 } else {
487 let service = new ServiceBuilder().build()
488 if (!service.getExecutable()) {
489 const { driverPath, browserPath } = getBinaryPaths(caps)
490 service.setExecutable(driverPath)
491 firefoxBrowserPath = browserPath
492 }
493 executor = createExecutor(service.start())
494 onQuit = () => service.kill()
495 }
496
497 if (firefoxBrowserPath) {
498 const vendorOptions = caps.get(FIREFOX_CAPABILITY_KEY)
499 if (vendorOptions) {
500 vendorOptions['binary'] = firefoxBrowserPath
501 caps.set(FIREFOX_CAPABILITY_KEY, vendorOptions)
502 } else {
503 caps.set(FIREFOX_CAPABILITY_KEY, { binary: firefoxBrowserPath })
504 }
505 caps.delete(Capability.BROWSER_VERSION)
506 }
507
508 return /** @type {!Driver} */ (super.createSession(executor, caps, onQuit))
509 }
510
511 /**
512 * This function is a no-op as file detectors are not supported by this

Callers

nothing calls this directly

Calls 11

getBinaryPathsFunction · 0.85
configureExecutorFunction · 0.70
createExecutorFunction · 0.70
startMethod · 0.65
buildMethod · 0.65
getMethod · 0.65
setMethod · 0.65
getExecutableMethod · 0.45
setExecutableMethod · 0.45
killMethod · 0.45
deleteMethod · 0.45

Tested by

no test coverage detected