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

Method createSession

javascript/selenium-webdriver/firefox.js:563–605  ·  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

561 * @return {!Driver} A new driver instance.
562 */
563 static createSession(opt_config, opt_executor) {
564 let caps = opt_config instanceof Capabilities ? opt_config : new Options(opt_config)
565
566 let firefoxBrowserPath = null
567
568 let executor
569 let onQuit
570
571 if (opt_executor instanceof http.Executor) {
572 executor = opt_executor
573 configureExecutor(executor)
574 } else if (opt_executor instanceof remote.DriverService) {
575 if (!opt_executor.getExecutable()) {
576 const { driverPath, browserPath } = getBinaryPaths(caps)
577 opt_executor.setExecutable(driverPath)
578 firefoxBrowserPath = browserPath
579 }
580 executor = createExecutor(opt_executor.start())
581 onQuit = () => opt_executor.kill()
582 } else {
583 let service = new ServiceBuilder().build()
584 if (!service.getExecutable()) {
585 const { driverPath, browserPath } = getBinaryPaths(caps)
586 service.setExecutable(driverPath)
587 firefoxBrowserPath = browserPath
588 }
589 executor = createExecutor(service.start())
590 onQuit = () => service.kill()
591 }
592
593 if (firefoxBrowserPath) {
594 const vendorOptions = caps.get(FIREFOX_CAPABILITY_KEY)
595 if (vendorOptions) {
596 vendorOptions['binary'] = firefoxBrowserPath
597 caps.set(FIREFOX_CAPABILITY_KEY, vendorOptions)
598 } else {
599 caps.set(FIREFOX_CAPABILITY_KEY, { binary: firefoxBrowserPath })
600 }
601 caps.delete(Capability.BROWSER_VERSION)
602 }
603
604 return /** @type {!Driver} */ (super.createSession(executor, caps, onQuit))
605 }
606
607 /**
608 * 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
getMethod · 0.65
setMethod · 0.65
getExecutableMethod · 0.45
setExecutableMethod · 0.45
killMethod · 0.45
buildMethod · 0.45
deleteMethod · 0.45

Tested by

no test coverage detected