webdriver 9.16.2 → 9.18.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1 +1 @@
1
- {"version":3,"file":"command.d.ts","sourceRoot":"","sources":["../src/command.ts"],"names":[],"mappings":"AAEA,OAAO,EAAyB,KAAK,eAAe,EAAE,MAAM,iBAAiB,CAAA;AAI7E,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,oBAAoB,CAAA;AAC3D,OAAO,KAAK,EAAE,UAAU,EAAgB,aAAa,EAAwB,MAAM,YAAY,CAAA;AAS/F,MAAM,CAAC,OAAO,WACV,MAAM,EAAE,MAAM,EACd,WAAW,EAAE,MAAM,EACnB,WAAW,EAAE,eAAe,EAC5B,qBAAqB,UAAQ,UAIgB,UAAU,mBAAmB,OAAO,EAAE,KAAG,OAAO,CAAC,iBAAiB,GAAG,aAAa,GAAG,IAAI,CAAC,CAqN1I"}
1
+ {"version":3,"file":"command.d.ts","sourceRoot":"","sources":["../src/command.ts"],"names":[],"mappings":"AAEA,OAAO,EAAyB,KAAK,eAAe,EAAE,MAAM,iBAAiB,CAAA;AAI7E,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,oBAAoB,CAAA;AAC3D,OAAO,KAAK,EAAE,UAAU,EAAgB,aAAa,EAAwB,MAAM,YAAY,CAAA;AAS/F,MAAM,CAAC,OAAO,WACV,MAAM,EAAE,MAAM,EACd,WAAW,EAAE,MAAM,EACnB,WAAW,EAAE,eAAe,EAC5B,qBAAqB,UAAQ,IAIU,MAAM,UAAU,EAAE,GAAG,cAAc,OAAO,EAAE,KAAG,OAAO,CAAC,iBAAiB,GAAG,aAAa,GAAG,IAAI,CAAC,CAkM1I"}
@@ -1,4 +1,5 @@
1
1
  import type WebSocket from 'ws';
2
+ import type { Options } from '@wdio/types';
2
3
  import type { BrowserSocket } from './bidi/socket.js';
3
4
  import type { FetchRequest } from './request/web.js';
4
5
  /**
@@ -7,13 +8,17 @@ import type { FetchRequest } from './request/web.js';
7
8
  export declare const isNode: boolean;
8
9
  export interface EnvironmentVariables {
9
10
  WEBDRIVER_CACHE_DIR?: string;
11
+ WDIO_LOG_LEVEL?: Options.WebDriverLogTypes;
10
12
  PROXY_URL?: string;
11
13
  NO_PROXY?: string[];
14
+ WDIO_WORKER_ID?: string;
15
+ WDIO_UNIT_TESTS?: string;
12
16
  }
13
17
  export interface EnvironmentDependencies {
14
18
  Request: typeof FetchRequest;
15
19
  Socket: typeof BrowserSocket;
16
20
  createBidiConnection: (wsUrl?: string, options?: WebSocket.ClientOptions) => Promise<WebSocket | undefined>;
21
+ killDriverProcess: (capabilities: WebdriverIO.Capabilities, shutdownDriver: boolean) => void;
17
22
  variables: EnvironmentVariables;
18
23
  }
19
24
  /**
@@ -1 +1 @@
1
- {"version":3,"file":"environment.d.ts","sourceRoot":"","sources":["../src/environment.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,SAAS,MAAM,IAAI,CAAA;AAE/B,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,kBAAkB,CAAA;AACrD,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,kBAAkB,CAAA;AAEpD;;GAEG;AACH,eAAO,MAAM,MAAM,SAAwD,CAAA;AAE3E,MAAM,WAAW,oBAAoB;IACjC,mBAAmB,CAAC,EAAE,MAAM,CAAA;IAC5B,SAAS,CAAC,EAAE,MAAM,CAAA;IAClB,QAAQ,CAAC,EAAE,MAAM,EAAE,CAAA;CACtB;AAED,MAAM,WAAW,uBAAuB;IACpC,OAAO,EAAE,OAAO,YAAY,CAAC;IAC7B,MAAM,EAAE,OAAO,aAAa,CAAC;IAC7B,oBAAoB,EAAE,CAAC,KAAK,CAAC,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,SAAS,CAAC,aAAa,KAAK,OAAO,CAAC,SAAS,GAAG,SAAS,CAAC,CAAC;IAC5G,SAAS,EAAE,oBAAoB,CAAA;CAClC;AAED;;;GAGG;AACH,eAAO,MAAM,WAAW,EAAE;IACtB,KAAK,EAAE,uBAAuB,CAAC;CAgBlC,CAAA"}
1
+ {"version":3,"file":"environment.d.ts","sourceRoot":"","sources":["../src/environment.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,SAAS,MAAM,IAAI,CAAA;AAC/B,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,aAAa,CAAA;AAE1C,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,kBAAkB,CAAA;AACrD,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,kBAAkB,CAAA;AAEpD;;GAEG;AACH,eAAO,MAAM,MAAM,SAAwD,CAAA;AAE3E,MAAM,WAAW,oBAAoB;IACjC,mBAAmB,CAAC,EAAE,MAAM,CAAA;IAC5B,cAAc,CAAC,EAAE,OAAO,CAAC,iBAAiB,CAAA;IAC1C,SAAS,CAAC,EAAE,MAAM,CAAA;IAClB,QAAQ,CAAC,EAAE,MAAM,EAAE,CAAA;IACnB,cAAc,CAAC,EAAE,MAAM,CAAA;IACvB,eAAe,CAAC,EAAE,MAAM,CAAA;CAC3B;AAED,MAAM,WAAW,uBAAuB;IACpC,OAAO,EAAE,OAAO,YAAY,CAAC;IAC7B,MAAM,EAAE,OAAO,aAAa,CAAC;IAC7B,oBAAoB,EAAE,CAAC,KAAK,CAAC,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,SAAS,CAAC,aAAa,KAAK,OAAO,CAAC,SAAS,GAAG,SAAS,CAAC,CAAC;IAC5G,iBAAiB,EAAE,CAAC,YAAY,EAAE,WAAW,CAAC,YAAY,EAAE,cAAc,EAAE,OAAO,KAAK,IAAI,CAAC;IAC7F,SAAS,EAAE,oBAAoB,CAAA;CAClC;AAED;;;GAGG;AACH,eAAO,MAAM,WAAW,EAAE;IACtB,KAAK,EAAE,uBAAuB,CAAC;CAmBlC,CAAA"}
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAOA,OA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AM,KAAK,SAAS,qBAEnB;CACJ;AAED;;GAEG;AACH,OAAO,EAAE,YAAY,EAAE,QAAQ,EAAE,OAAO,EAAE,kBAAkB,EAAE,YAAY,EAAE,gBAAgB,EAAE,SAAS,EAAE,CAAA;AACzG,cAAc,YAAY,CAAA;AAC1B,cAAc,gBAAgB,CAAA;AAC9B,cAAc,mBAAmB,CAAA;AACjC,OAAO,KAAK,KAAK,MAAM,sBAAsB,CAAA;AAC7C,OAAO,KAAK,MAAM,MAAM,uBAAuB,CAAA"}
package/build/index.js CHANGED
@@ -44,6 +44,9 @@ var environment = {
44
44
  get createBidiConnection() {
45
45
  throw new Error("createBidiConnection is not available in this environment");
46
46
  },
47
+ get killDriverProcess() {
48
+ throw new Error("killDriverProcess is not available in this environment");
49
+ },
47
50
  get variables() {
48
51
  return {};
49
52
  }
@@ -1250,13 +1253,13 @@ var getSessionError = (err, params = {}) => {
1250
1253
  if (err.message === "Response has empty body") {
1251
1254
  return "Make sure to connect to valid hostname:port or the port is not in use.\nIf you use a grid server " + w3cCapMessage;
1252
1255
  }
1253
- if (err.message.includes("failed serving request POST /wd/hub/session: Unauthorized") && ((_a = params.hostname) == null ? void 0 : _a.endsWith("saucelabs.com"))) {
1256
+ if (err.message.includes("failed serving request POST /wd/hub/session: Unauthorized") && (params.hostname === "saucelabs.com" || ((_a = params.hostname) == null ? void 0 : _a.endsWith(".saucelabs.com")))) {
1254
1257
  return "Session request was not authorized because you either did provide a wrong access key or tried to run in a region that has not been enabled for your user. If have registered a free trial account it is connected to a specific region. Ensure this region is set in your configuration (https://webdriver.io/docs/options.html#region).";
1255
1258
  }
1256
1259
  return err.message;
1257
1260
  };
1258
1261
  function initiateBidi(socketUrl, strictSSL = true, userHeaders) {
1259
- const isUnitTesting = process.env.WDIO_UNIT_TESTS;
1262
+ const isUnitTesting = environment.value.variables.WDIO_UNIT_TESTS;
1260
1263
  if (isUnitTesting) {
1261
1264
  log2.info("Skip connecting to WebDriver Bidi interface due to unit tests");
1262
1265
  return {
@@ -1356,7 +1359,8 @@ function command_default(method, endpointUri, commandInfo, doubleEncodeVariables
1356
1359
  })), ...parameters];
1357
1360
  const commandUsage = "".concat(command, "(").concat(commandParams.map((p) => p.name).join(", "), ")");
1358
1361
  const moreInfo = "\n\nFor more info see ".concat(ref, "\n");
1359
- if (typeof deprecated === "string" && !process.env.DISABLE_WEBDRIVERIO_DEPRECATION_WARNINGS) {
1362
+ const DISABLE_WEBDRIVERIO_DEPRECATION_WARNINGS = globalThis.process && globalThis.process.env ? globalThis.process.env.DISABLE_WEBDRIVERIO_DEPRECATION_WARNINGS : void 0;
1363
+ if (typeof deprecated === "string" && !DISABLE_WEBDRIVERIO_DEPRECATION_WARNINGS) {
1360
1364
  const warning = deprecated.replace("This command", 'The "'.concat(command, '" command'));
1361
1365
  log3.warn(warning);
1362
1366
  console.warn("\u26A0\uFE0F [WEBDRIVERIO DEPRECATION NOTICE] ".concat(warning));
@@ -1431,25 +1435,8 @@ function command_default(method, endpointUri, commandInfo, doubleEncodeVariables
1431
1435
  const browser = this;
1432
1436
  (_a = browser._bidiHandler) == null ? void 0 : _a.close();
1433
1437
  const shutdownDriver = ((_b = maskedBody.deleteSessionOpts) == null ? void 0 : _b.shutdownDriver) !== false;
1434
- if (shutdownDriver && "wdio:driverPID" in this.capabilities && this.capabilities["wdio:driverPID"]) {
1435
- log3.info("Kill driver process with PID ".concat(this.capabilities["wdio:driverPID"]));
1436
- try {
1437
- const killedSuccessfully = process.kill(this.capabilities["wdio:driverPID"], "SIGKILL");
1438
- if (!killedSuccessfully) {
1439
- log3.warn("Failed to kill driver process, manually clean-up might be required");
1440
- }
1441
- } catch (err) {
1442
- log3.warn("Failed to kill driver process", err);
1443
- }
1444
- setTimeout(() => {
1445
- for (const handle of process._getActiveHandles()) {
1446
- if (handle.servername && handle.servername.includes("edgedl.me")) {
1447
- handle.destroy();
1448
- }
1449
- }
1450
- }, 10);
1451
- }
1452
- if (!process.env.WDIO_WORKER_ID) {
1438
+ environment.value.killDriverProcess(this.capabilities, shutdownDriver);
1439
+ if (!environment.value.variables.WDIO_WORKER_ID) {
1453
1440
  logger3.clearLogger();
1454
1441
  }
1455
1442
  }
@@ -1509,7 +1496,7 @@ var log4 = logger4("webdriver");
1509
1496
  var WebDriver = class _WebDriver {
1510
1497
  static async newSession(options, modifier, userPrototype = {}, customCommandWrapper) {
1511
1498
  var _a;
1512
- const envLogLevel = process.env.WDIO_LOG_LEVEL;
1499
+ const envLogLevel = environment.value.variables.WDIO_LOG_LEVEL;
1513
1500
  options.logLevel = envLogLevel != null ? envLogLevel : options.logLevel;
1514
1501
  const params = validateConfig(DEFAULTS, options);
1515
1502
  if (params.logLevel && (!options.logLevels || !options.logLevels.webdriver)) {
@@ -1805,7 +1792,7 @@ var WebDriverResponseError = class _WebDriverResponseError extends WebDriverErro
1805
1792
  // package.json
1806
1793
  var package_default = {
1807
1794
  name: "webdriver",
1808
- version: "9.16.0",
1795
+ version: "9.17.0",
1809
1796
  description: "A Node.js bindings implementation for the W3C WebDriver and Mobile JSONWire Protocol",
1810
1797
  author: "Christian Bromann <mail@bromann.dev>",
1811
1798
  homepage: "https://github.com/webdriverio/webdriverio/tree/main/packages/webdriver",
@@ -1849,7 +1836,8 @@ var package_default = {
1849
1836
  "@wdio/types": "workspace:*",
1850
1837
  "@wdio/utils": "workspace:*",
1851
1838
  "deepmerge-ts": "^7.0.3",
1852
- undici: "^6.20.1",
1839
+ "https-proxy-agent": "^7.0.6",
1840
+ undici: "^6.21.3",
1853
1841
  ws: "^8.8.0"
1854
1842
  }
1855
1843
  };
@@ -1938,7 +1926,7 @@ var WebDriverRequest = class {
1938
1926
  });
1939
1927
  const searchParams = isBrowser ? void 0 : typeof options.queryParams === "object" ? options.queryParams : void 0;
1940
1928
  if (this.body && (Object.keys(this.body).length || this.method === "POST")) {
1941
- const contentLength = Buffer.byteLength(JSON.stringify(this.body), "utf8");
1929
+ const contentLength = new TextEncoder().encode(JSON.stringify(this.body)).length;
1942
1930
  requestOptions.body = this.body;
1943
1931
  requestHeaders.set("Content-Length", "".concat(contentLength));
1944
1932
  }
@@ -2067,6 +2055,8 @@ var log6 = logger6("webdriver");
2067
2055
  environment.value = {
2068
2056
  Request: FetchRequest,
2069
2057
  Socket: BrowserSocket,
2058
+ killDriverProcess: () => {
2059
+ },
2070
2060
  createBidiConnection: (webSocketUrl, options) => {
2071
2061
  log6.info("Connecting to webSocketUrl ".concat(webSocketUrl));
2072
2062
  const ws = new BrowserSocket(webSocketUrl, options);
@@ -1 +1 @@
1
- {"version":3,"file":"bidi.d.ts","sourceRoot":"","sources":["../../src/node/bidi.ts"],"names":[],"mappings":"AAMA,OAAO,SAAS,EAAE,EAAE,KAAK,aAAa,EAAE,MAAM,IAAI,CAAA;AAKlD,wBAAsB,oBAAoB,CAAC,YAAY,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,aAAa,GAAG,OAAO,CAAC,SAAS,GAAG,SAAS,CAAC,CAGxH;AAED;;;;GAIG;AACH,wBAAsB,0BAA0B,CAAC,YAAY,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,EAAE,CAAC,CAqBxF;AAcD;;;;GAIG;AACH,wBAAsB,gBAAgB,CAAC,aAAa,EAAE,MAAM,EAAE,EAAE,OAAO,CAAC,EAAE,aAAa,GAAG,OAAO,CAAC,SAAS,GAAG,SAAS,CAAC,CAsDvH"}
1
+ {"version":3,"file":"bidi.d.ts","sourceRoot":"","sources":["../../src/node/bidi.ts"],"names":[],"mappings":"AASA,OAAO,SAAS,EAAE,EAAE,KAAK,aAAa,EAAE,MAAM,IAAI,CAAA;AAMlD,wBAAsB,oBAAoB,CAAC,YAAY,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,aAAa,GAAG,OAAO,CAAC,SAAS,GAAG,SAAS,CAAC,CAGxH;AAED;;;;GAIG;AACH,wBAAsB,0BAA0B,CAAC,YAAY,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,EAAE,CAAC,CAqBxF;AAcD;;;;GAIG;AACH,wBAAsB,gBAAgB,CAAC,aAAa,EAAE,MAAM,EAAE,EAAE,OAAO,CAAC,EAAE,aAAa,GAAG,OAAO,CAAC,SAAS,GAAG,SAAS,CAAC,CAuEvH"}
@@ -0,0 +1,7 @@
1
+ /**
2
+ * Kill the driver process after `deleteSession` command is done
3
+ * @param capabilities - the capabilities of the driver
4
+ * @param shutdownDriver - whether to shutdown the driver
5
+ */
6
+ export declare function killDriverProcess(capabilities: WebdriverIO.Capabilities, shutdownDriver: boolean): void;
7
+ //# sourceMappingURL=utils.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../../src/node/utils.ts"],"names":[],"mappings":"AAIA;;;;GAIG;AACH,wBAAgB,iBAAiB,CAAC,YAAY,EAAE,WAAW,CAAC,YAAY,EAAE,cAAc,EAAE,OAAO,QAwBhG"}
@@ -1 +1 @@
1
- {"version":3,"file":"node.d.ts","sourceRoot":"","sources":["../src/node.ts"],"names":[],"mappings":"AAGA,OAAO,SAAS,MAAM,YAAY,CAAA;AAMlC,eAAe,SAAS,CAAA;AACxB,cAAc,YAAY,CAAA"}
1
+ {"version":3,"file":"node.d.ts","sourceRoot":"","sources":["../src/node.ts"],"names":[],"mappings":"AAIA,OAAO,SAAS,MAAM,YAAY,CAAA;AAOlC,eAAe,SAAS,CAAA;AACxB,cAAc,YAAY,CAAA"}
package/build/node.js CHANGED
@@ -25,6 +25,9 @@ var environment = {
25
25
  get createBidiConnection() {
26
26
  throw new Error("createBidiConnection is not available in this environment");
27
27
  },
28
+ get killDriverProcess() {
29
+ throw new Error("killDriverProcess is not available in this environment");
30
+ },
28
31
  get variables() {
29
32
  return {};
30
33
  }
@@ -1220,13 +1223,13 @@ It seems like the service failed to start or is rejecting any connections.`;
1220
1223
  if (err.message === "Response has empty body") {
1221
1224
  return "Make sure to connect to valid hostname:port or the port is not in use.\nIf you use a grid server " + w3cCapMessage;
1222
1225
  }
1223
- if (err.message.includes("failed serving request POST /wd/hub/session: Unauthorized") && params.hostname?.endsWith("saucelabs.com")) {
1226
+ if (err.message.includes("failed serving request POST /wd/hub/session: Unauthorized") && (params.hostname === "saucelabs.com" || params.hostname?.endsWith(".saucelabs.com"))) {
1224
1227
  return "Session request was not authorized because you either did provide a wrong access key or tried to run in a region that has not been enabled for your user. If have registered a free trial account it is connected to a specific region. Ensure this region is set in your configuration (https://webdriver.io/docs/options.html#region).";
1225
1228
  }
1226
1229
  return err.message;
1227
1230
  };
1228
1231
  function initiateBidi(socketUrl, strictSSL = true, userHeaders) {
1229
- const isUnitTesting = process.env.WDIO_UNIT_TESTS;
1232
+ const isUnitTesting = environment.value.variables.WDIO_UNIT_TESTS;
1230
1233
  if (isUnitTesting) {
1231
1234
  log2.info("Skip connecting to WebDriver Bidi interface due to unit tests");
1232
1235
  return {
@@ -1328,7 +1331,8 @@ function command_default(method, endpointUri, commandInfo, doubleEncodeVariables
1328
1331
 
1329
1332
  For more info see ${ref}
1330
1333
  `;
1331
- if (typeof deprecated === "string" && !process.env.DISABLE_WEBDRIVERIO_DEPRECATION_WARNINGS) {
1334
+ const DISABLE_WEBDRIVERIO_DEPRECATION_WARNINGS = globalThis.process && globalThis.process.env ? globalThis.process.env.DISABLE_WEBDRIVERIO_DEPRECATION_WARNINGS : void 0;
1335
+ if (typeof deprecated === "string" && !DISABLE_WEBDRIVERIO_DEPRECATION_WARNINGS) {
1332
1336
  const warning = deprecated.replace("This command", `The "${command}" command`);
1333
1337
  log3.warn(warning);
1334
1338
  console.warn(`\u26A0\uFE0F [WEBDRIVERIO DEPRECATION NOTICE] ${warning}`);
@@ -1408,25 +1412,8 @@ Actual: ${actual}` + moreInfo
1408
1412
  const browser = this;
1409
1413
  browser._bidiHandler?.close();
1410
1414
  const shutdownDriver = maskedBody.deleteSessionOpts?.shutdownDriver !== false;
1411
- if (shutdownDriver && "wdio:driverPID" in this.capabilities && this.capabilities["wdio:driverPID"]) {
1412
- log3.info(`Kill driver process with PID ${this.capabilities["wdio:driverPID"]}`);
1413
- try {
1414
- const killedSuccessfully = process.kill(this.capabilities["wdio:driverPID"], "SIGKILL");
1415
- if (!killedSuccessfully) {
1416
- log3.warn("Failed to kill driver process, manually clean-up might be required");
1417
- }
1418
- } catch (err) {
1419
- log3.warn("Failed to kill driver process", err);
1420
- }
1421
- setTimeout(() => {
1422
- for (const handle of process._getActiveHandles()) {
1423
- if (handle.servername && handle.servername.includes("edgedl.me")) {
1424
- handle.destroy();
1425
- }
1426
- }
1427
- }, 10);
1428
- }
1429
- if (!process.env.WDIO_WORKER_ID) {
1415
+ environment.value.killDriverProcess(this.capabilities, shutdownDriver);
1416
+ if (!environment.value.variables.WDIO_WORKER_ID) {
1430
1417
  logger3.clearLogger();
1431
1418
  }
1432
1419
  }
@@ -1485,7 +1472,7 @@ var remoteTypes_exports = {};
1485
1472
  var log4 = logger4("webdriver");
1486
1473
  var WebDriver = class _WebDriver {
1487
1474
  static async newSession(options, modifier, userPrototype = {}, customCommandWrapper) {
1488
- const envLogLevel = process.env.WDIO_LOG_LEVEL;
1475
+ const envLogLevel = environment.value.variables.WDIO_LOG_LEVEL;
1489
1476
  options.logLevel = envLogLevel ?? options.logLevel;
1490
1477
  const params = validateConfig(DEFAULTS, options);
1491
1478
  if (params.logLevel && (!options.logLevels || !options.logLevels.webdriver)) {
@@ -1624,7 +1611,7 @@ var WebDriver = class _WebDriver {
1624
1611
 
1625
1612
  // src/request/node.ts
1626
1613
  import dns from "node:dns";
1627
- import { fetch as fetch2, Agent, ProxyAgent } from "undici";
1614
+ import { fetch as fetch2, Agent, ProxyAgent, getGlobalDispatcher } from "undici";
1628
1615
 
1629
1616
  // src/request/request.ts
1630
1617
  import logger5 from "@wdio/logger";
@@ -1736,7 +1723,7 @@ var WebDriverResponseError = class _WebDriverResponseError extends WebDriverErro
1736
1723
  // package.json
1737
1724
  var package_default = {
1738
1725
  name: "webdriver",
1739
- version: "9.16.0",
1726
+ version: "9.17.0",
1740
1727
  description: "A Node.js bindings implementation for the W3C WebDriver and Mobile JSONWire Protocol",
1741
1728
  author: "Christian Bromann <mail@bromann.dev>",
1742
1729
  homepage: "https://github.com/webdriverio/webdriverio/tree/main/packages/webdriver",
@@ -1780,7 +1767,8 @@ var package_default = {
1780
1767
  "@wdio/types": "workspace:*",
1781
1768
  "@wdio/utils": "workspace:*",
1782
1769
  "deepmerge-ts": "^7.0.3",
1783
- undici: "^6.20.1",
1770
+ "https-proxy-agent": "^7.0.6",
1771
+ undici: "^6.21.3",
1784
1772
  ws: "^8.8.0"
1785
1773
  }
1786
1774
  };
@@ -1868,7 +1856,7 @@ var WebDriverRequest = class {
1868
1856
  });
1869
1857
  const searchParams = isBrowser ? void 0 : typeof options.queryParams === "object" ? options.queryParams : void 0;
1870
1858
  if (this.body && (Object.keys(this.body).length || this.method === "POST")) {
1871
- const contentLength = Buffer.byteLength(JSON.stringify(this.body), "utf8");
1859
+ const contentLength = new TextEncoder().encode(JSON.stringify(this.body)).length;
1872
1860
  requestOptions.body = this.body;
1873
1861
  requestHeaders.set("Content-Length", `${contentLength}`);
1874
1862
  }
@@ -2000,6 +1988,14 @@ var FetchRequest = class extends WebDriverRequest {
2000
1988
  if (sessionId && SESSION_DISPATCHERS.has(sessionId)) {
2001
1989
  return SESSION_DISPATCHERS.get(sessionId);
2002
1990
  }
1991
+ try {
1992
+ const globalDispatcher = getGlobalDispatcher();
1993
+ if (globalDispatcher && (globalDispatcher.constructor.name === "ProxyAgent" || "proxy" in globalDispatcher || // Also check for other custom dispatcher types
1994
+ globalDispatcher.constructor.name !== "Agent" && globalDispatcher.constructor.name !== "MockAgent")) {
1995
+ return globalDispatcher;
1996
+ }
1997
+ } catch {
1998
+ }
2003
1999
  const { PROXY_URL, NO_PROXY } = environment.value.variables;
2004
2000
  const shouldUseProxy = PROXY_URL && !NO_PROXY?.some((str) => url.hostname.endsWith(str));
2005
2001
  const dispatcher = shouldUseProxy ? new ProxyAgent({
@@ -2043,6 +2039,7 @@ import { isIP } from "node:net";
2043
2039
  import dns2 from "node:dns/promises";
2044
2040
  import logger6 from "@wdio/logger";
2045
2041
  import WebSocket from "ws";
2042
+ import { HttpsProxyAgent } from "https-proxy-agent";
2046
2043
  var log6 = logger6("webdriver");
2047
2044
  var CONNECTION_TIMEOUT = 1e4;
2048
2045
  async function createBidiConnection(webSocketUrl, options) {
@@ -2070,7 +2067,20 @@ async function connectWebsocket(candidateUrls, options) {
2070
2067
  const websockets = candidateUrls.map((candidateUrl) => {
2071
2068
  log6.debug(`Attempt to connect to webSocketUrl ${candidateUrl}`);
2072
2069
  try {
2073
- const ws2 = new WebSocket(candidateUrl, options);
2070
+ const finalizedOptions = { ...options };
2071
+ const { PROXY_URL, NO_PROXY } = environment.value.variables;
2072
+ const shouldUseProxy = PROXY_URL && !NO_PROXY?.some((str) => {
2073
+ try {
2074
+ return new URL(candidateUrl).hostname.endsWith(str);
2075
+ } catch {
2076
+ return false;
2077
+ }
2078
+ });
2079
+ if (shouldUseProxy) {
2080
+ log6.debug(`Adding proxy ${PROXY_URL} for webSocketUrl ${candidateUrl}`);
2081
+ finalizedOptions.agent = new HttpsProxyAgent(PROXY_URL);
2082
+ }
2083
+ const ws2 = new WebSocket(candidateUrl, finalizedOptions);
2074
2084
  return ws2;
2075
2085
  } catch {
2076
2086
  return void 0;
@@ -2131,6 +2141,30 @@ function firstResolved(promises, errorMessages = []) {
2131
2141
  });
2132
2142
  }
2133
2143
 
2144
+ // src/node/utils.ts
2145
+ import logger7 from "@wdio/logger";
2146
+ var log7 = logger7("webdriver");
2147
+ function killDriverProcess(capabilities, shutdownDriver) {
2148
+ if (shutdownDriver && "wdio:driverPID" in capabilities && capabilities["wdio:driverPID"]) {
2149
+ log7.info(`Kill driver process with PID ${capabilities["wdio:driverPID"]}`);
2150
+ try {
2151
+ const killedSuccessfully = process.kill(capabilities["wdio:driverPID"], "SIGKILL");
2152
+ if (!killedSuccessfully) {
2153
+ log7.warn("Failed to kill driver process, manually clean-up might be required");
2154
+ }
2155
+ } catch (err) {
2156
+ log7.warn("Failed to kill driver process", err);
2157
+ }
2158
+ setTimeout(() => {
2159
+ for (const handle of process._getActiveHandles()) {
2160
+ if (handle.servername && handle.servername.includes("edgedl.me")) {
2161
+ handle.destroy();
2162
+ }
2163
+ }
2164
+ }, 10);
2165
+ }
2166
+ }
2167
+
2134
2168
  // src/node.ts
2135
2169
  var node_default = WebDriver;
2136
2170
  environment.value = {
@@ -2149,7 +2183,10 @@ environment.value = {
2149
2183
  ),
2150
2184
  Socket: ws,
2151
2185
  createBidiConnection,
2186
+ killDriverProcess,
2152
2187
  variables: {
2188
+ WDIO_LOG_LEVEL: process.env.WDIO_LOG_LEVEL,
2189
+ WDIO_UNIT_TESTS: process.env.WDIO_UNIT_TESTS,
2153
2190
  WEBDRIVER_CACHE_DIR: process.env.WEBDRIVER_CACHE_DIR || os.tmpdir(),
2154
2191
  PROXY_URL: process.env.HTTP_PROXY || process.env.HTTPS_PROXY,
2155
2192
  NO_PROXY: process.env.NO_PROXY && process.env.NO_PROXY.trim() ? process.env.NO_PROXY.trim().split(/[\s,;]+/) : []
@@ -1 +1 @@
1
- {"version":3,"file":"node.d.ts","sourceRoot":"","sources":["../../src/request/node.ts"],"names":[],"mappings":"AACA,OAAO,EAAmE,KAAK,UAAU,EAAE,MAAM,QAAQ,CAAA;AAGzG,OAAO,EAAE,gBAAgB,EAAE,MAAM,cAAc,CAAA;AAC/C,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,YAAY,CAAA;AAMhD,eAAO,MAAM,mBAAmB,EAAE,GAAG,CAAC,MAAM,EAAE,UAAU,CAAa,CAAA;AAErE;;GAEG;AACH,qBAAa,YAAa,SAAQ,gBAAgB;IACxC,KAAK,CAAE,GAAG,EAAE,GAAG,EAAE,IAAI,EAAE,WAAW;IAcxC,OAAO,CAAC,aAAa;IA+BrB,OAAO,CAAC,wBAAwB;IAS1B,aAAa,CAAE,OAAO,EAAE,cAAc,EAAE,SAAS,CAAC,EAAE,MAAM,EAAE,SAAS,GAAE,OAAe;;;;CAM/F"}
1
+ {"version":3,"file":"node.d.ts","sourceRoot":"","sources":["../../src/request/node.ts"],"names":[],"mappings":"AACA,OAAO,EAAmE,KAAK,UAAU,EAAuB,MAAM,QAAQ,CAAA;AAG9H,OAAO,EAAE,gBAAgB,EAAE,MAAM,cAAc,CAAA;AAC/C,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,YAAY,CAAA;AAMhD,eAAO,MAAM,mBAAmB,EAAE,GAAG,CAAC,MAAM,EAAE,UAAU,CAAa,CAAA;AAErE;;GAEG;AACH,qBAAa,YAAa,SAAQ,gBAAgB;IACxC,KAAK,CAAE,GAAG,EAAE,GAAG,EAAE,IAAI,EAAE,WAAW;IAcxC,OAAO,CAAC,aAAa;IAqDrB,OAAO,CAAC,wBAAwB;IAS1B,aAAa,CAAE,OAAO,EAAE,cAAc,EAAE,SAAS,CAAC,EAAE,MAAM,EAAE,SAAS,GAAE,OAAe;;;;CAM/F"}
package/build/utils.d.ts CHANGED
@@ -55,7 +55,7 @@ export declare const getSessionError: (err: JSONWPCommandError, params?: Partial
55
55
  * @returns prototype with interface for bidi primitives
56
56
  */
57
57
  export declare function initiateBidi(socketUrl: string, strictSSL?: boolean, userHeaders?: Record<string, string>): PropertyDescriptorMap;
58
- export declare function parseBidiMessage(this: EventEmitter, data: Buffer): void;
58
+ export declare function parseBidiMessage(this: EventEmitter, data: ArrayBuffer): void;
59
59
  /**
60
60
  * Masks the `text` parameter in a WebDriver command if masking is enabled in the options.
61
61
  *
@@ -1 +1 @@
1
- {"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../src/utils.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,aAAa,CAAA;AAI/C,OAAO,KAAK,EAAE,eAAe,EAAY,MAAM,iBAAiB,CAAA;AAMhE,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,aAAa,CAAA;AAM1C,OAAO,KAAK,EAAE,MAAM,EAAE,k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AE,EAAE,OAAO,CAAC,YAAY,CAAC,GAAG,qBAAqB,CAuBpM;AAED;;;;;GAKG;AACH,wBAAgB,kBAAkB,CAAC,MAAM,EAAE,MAAM,QAgBhD;AAED;;;;GAIG;AACH,eAAO,MAAM,eAAe,GAAI,KAAK,kBAAkB,EAAE,SAAQ,OAAO,CAAC,OAAO,CAAC,SAAS,CAAM,WAmD/F,CAAA;AAED;;;;;;GAMG;AACH,wBAAgB,YAAY,CACxB,SAAS,EAAE,MAAM,EACjB,SAAS,GAAE,OAAc,EACzB,WAAW,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,GACrC,qBAAqB,CA6CvB;AAED,wBAAgB,gBAAgB,CAAE,IAAI,EAAE,YAAY,EAAE,IAAI,EAAE,WAAW,QAWtE;AAED;;;;;;;;;;;;;;;GAeG;AACH,wBAAgB,IAAI,CAAC,WAAW,EAAE,eAAe,EAAE,OAAO,EAAE,qBAAqB,EAAE,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EAAE,IAAI,EAAE,OAAO,EAAE;;;;EA8BhI"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "webdriver",
3
- "version": "9.16.2",
3
+ "version": "9.18.0",
4
4
  "description": "A Node.js bindings implementation for the W3C WebDriver and Mobile JSONWire Protocol",
5
5
  "author": "Christian Bromann <mail@bromann.dev>",
6
6
  "homepage": "https://github.com/webdriverio/webdriverio/tree/main/packages/webdriver",
@@ -38,14 +38,15 @@
38
38
  "dependencies": {
39
39
  "@types/node": "^20.1.0",
40
40
  "@types/ws": "^8.5.3",
41
- "@wdio/config": "9.16.2",
42
- "@wdio/logger": "9.16.2",
41
+ "@wdio/config": "9.18.0",
42
+ "@wdio/logger": "9.18.0",
43
43
  "@wdio/protocols": "9.16.2",
44
44
  "@wdio/types": "9.16.2",
45
- "@wdio/utils": "9.16.2",
45
+ "@wdio/utils": "9.18.0",
46
46
  "deepmerge-ts": "^7.0.3",
47
- "undici": "^6.20.1",
47
+ "https-proxy-agent": "^7.0.6",
48
+ "undici": "^6.21.3",
48
49
  "ws": "^8.8.0"
49
50
  },
50
- "gitHead": "ff2154c00e7ba6d6e2a58e0b8e1258a20229752d"
51
+ "gitHead": "a515cdf9ce892da87708c290dd2b05b051bbe602"
51
52
  }