MCPcopy Index your code
hub / github.com/SeleniumHQ/selenium / createSession

Method createSession

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

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