webdriver
Advanced tools
Comparing version 8.29.7 to 8.30.0
@@ -1,11 +0,5 @@ | ||
/// <reference types="node" resolution-mode="require"/> | ||
import type { ChildProcess } from 'node:child_process'; | ||
import { type CommandEndpoint } from '@wdio/protocols'; | ||
import type { WebDriverResponse } from './request/index.js'; | ||
import type { BaseClient, BidiResponses } from './types.js'; | ||
interface BaseClientWithEventHandler extends BaseClient { | ||
_driverProcess?: ChildProcess; | ||
} | ||
export default function (method: string, endpointUri: string, commandInfo: CommandEndpoint, doubleEncodeVariables?: boolean): (this: BaseClientWithEventHandler, ...args: any[]) => Promise<WebDriverResponse | BidiResponses | void>; | ||
export {}; | ||
export default function (method: string, endpointUri: string, commandInfo: CommandEndpoint, doubleEncodeVariables?: boolean): (this: BaseClient, ...args: any[]) => Promise<WebDriverResponse | BidiResponses | void>; | ||
//# sourceMappingURL=command.d.ts.map |
@@ -92,2 +92,5 @@ import logger from '@wdio/logger'; | ||
log.info('COMMAND', commandCallStructure(command, args)); | ||
/** | ||
* use then here so we can better unit test what happens before and after the request | ||
*/ | ||
return request.makeRequest(this.options, this.sessionId).then((result) => { | ||
@@ -106,12 +109,12 @@ if (typeof result.value !== 'undefined') { | ||
if (command === 'deleteSession') { | ||
const shutdownDriver = body.deleteSessionOpts?.shutdownDriver !== false; | ||
/** | ||
* kill driver process if there is one | ||
*/ | ||
if (this._driverProcess && body.deleteSessionOpts?.shutdownDriver !== false) { | ||
log.info(`Kill ${this._driverProcess.spawnfile} driver process with command line: ${this._driverProcess.spawnargs.slice(1).join(' ')}`); | ||
const killedSuccessfully = this._driverProcess.kill('SIGKILL'); | ||
if (shutdownDriver && 'wdio:driverPID' in this.capabilities && this.capabilities['wdio:driverPID']) { | ||
log.info(`Kill driver process with PID ${this.capabilities['wdio:driverPID']}`); | ||
const killedSuccessfully = process.kill(this.capabilities['wdio:driverPID'], 'SIGKILL'); | ||
if (!killedSuccessfully) { | ||
log.warn('Failed to kill driver process, manully clean-up might be required'); | ||
log.warn('Failed to kill driver process, manually clean-up might be required'); | ||
} | ||
this._driverProcess = undefined; | ||
setTimeout(() => { | ||
@@ -118,0 +121,0 @@ /** |
@@ -19,3 +19,3 @@ import type { Options } from '@wdio/types'; | ||
*/ | ||
static reloadSession(instance: Client): Promise<string>; | ||
static reloadSession(instance: Client, newCapabilities?: WebdriverIO.Capabilities): Promise<string>; | ||
static get WebDriver(): typeof WebDriver; | ||
@@ -22,0 +22,0 @@ } |
import logger from '@wdio/logger'; | ||
import { webdriverMonad, sessionEnvironmentDetector, startWebDriver } from '@wdio/utils'; | ||
import { validateConfig } from '@wdio/config'; | ||
import { deepmerge } from 'deepmerge-ts'; | ||
import command from './command.js'; | ||
@@ -23,6 +24,10 @@ import { DEFAULTS } from './constants.js'; | ||
const protocolCommands = getPrototype(environment); | ||
const driverPrototype = { | ||
_driverProcess: { value: driverProcess, configurable: false, writable: true } | ||
}; | ||
/** | ||
* attach driver process to instance capabilities so we can kill the driver process | ||
* even after attaching to this session | ||
*/ | ||
if (driverProcess?.pid) { | ||
capabilities['wdio:driverPID'] = driverProcess.pid; | ||
} | ||
/** | ||
* initiate WebDriver Bidi | ||
@@ -39,3 +44,2 @@ */ | ||
...userPrototype, | ||
...driverPrototype, | ||
...bidiPrototype | ||
@@ -114,10 +118,23 @@ }); | ||
*/ | ||
static async reloadSession(instance) { | ||
const params = { | ||
...instance.options, | ||
capabilities: instance.requestedCapabilities | ||
}; | ||
const { sessionId, capabilities } = await startWebDriverSession(params); | ||
static async reloadSession(instance, newCapabilities) { | ||
const capabilities = deepmerge(instance.requestedCapabilities, newCapabilities || {}); | ||
const params = { ...instance.options, capabilities }; | ||
let driverProcess; | ||
if (newCapabilities?.browserName) { | ||
delete params.port; | ||
delete params.hostname; | ||
driverProcess = await startWebDriver(params); | ||
} | ||
const { sessionId, capabilities: newSessionCapabilities } = await startWebDriverSession(params); | ||
/** | ||
* attach driver process to instance capabilities so we can kill the driver process | ||
* even after attaching to this session | ||
*/ | ||
if (driverProcess?.pid) { | ||
newSessionCapabilities['wdio:driverPID'] = driverProcess.pid; | ||
} | ||
instance.options.hostname = params.hostname; | ||
instance.options.port = params.port; | ||
instance.sessionId = sessionId; | ||
instance.capabilities = capabilities; | ||
instance.capabilities = newSessionCapabilities; | ||
return sessionId; | ||
@@ -124,0 +141,0 @@ } |
{ | ||
"name": "webdriver", | ||
"version": "8.29.7", | ||
"version": "8.30.0", | ||
"description": "A Node.js bindings implementation for the W3C WebDriver and Mobile JSONWire Protocol", | ||
@@ -41,7 +41,7 @@ "author": "Christian Bromann <mail@bromann.dev>", | ||
"@types/ws": "^8.5.3", | ||
"@wdio/config": "8.29.3", | ||
"@wdio/config": "8.30.0", | ||
"@wdio/logger": "8.28.0", | ||
"@wdio/protocols": "8.29.7", | ||
"@wdio/types": "8.29.1", | ||
"@wdio/utils": "8.29.3", | ||
"@wdio/types": "8.30.0", | ||
"@wdio/utils": "8.30.0", | ||
"deepmerge-ts": "^5.1.0", | ||
@@ -52,3 +52,3 @@ "got": "^12.6.1", | ||
}, | ||
"gitHead": "1c7195268663df56856494c69d7bd655c834a368" | ||
"gitHead": "033e2a91e97c9bd060eb70f2e4e412d382bec3af" | ||
} |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
206691
3710
+ Added@types/node@20.17.3(transitive)
+ Added@wdio/config@8.30.0(transitive)
+ Added@wdio/types@8.30.0(transitive)
+ Added@wdio/utils@8.30.0(transitive)
- Removed@types/node@20.17.4(transitive)
- Removed@wdio/config@8.29.3(transitive)
- Removed@wdio/types@8.29.1(transitive)
- Removed@wdio/utils@8.29.3(transitive)
Updated@wdio/config@8.30.0
Updated@wdio/types@8.30.0
Updated@wdio/utils@8.30.0