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