@wdio/utils 8.15.4 → 8.15.7

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":"index.d.ts","sourceRoot":"","sources":["../../src/driver/index.ts"],"names":[],"mappings":";AAEA,OAAO,EAAyB,MAAM,oBAAoB,CAAA;AAO1D,OAAO,EAA8B,KAAK,mBAAmB,IAAI,sBAAsB,EAAE,MAAM,cAAc,CAAA;AAC7G,OAAO,EAA6B,KAAK,qBAAqB,EAAE,MAAM,aAAa,CAAA;AACnF,OAAO,EAA4B,KAAK,oBAAoB,EAAE,MAAM,YAAY,CAAA;AAChF,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,qBAAqB,CAAA;AAEzD,OAAO,KAAK,EAAgB,OAAO,EAAE,MAAM,aAAa,CAAA;AAQxD,MAAM,MAAM,sBAAsB,GAAG,cAAc,GAAG,IAAI,CAAC,oBAAoB,EAAE,MAAM,GAAG,mBAAmB,GAAG,sBAAsB,CAAC,CAAA;AACvI,OAAO,CAAC,MAAM,CAAC;IACX,UAAU,WAAW,CAAC;QAClB,UAAU,mBAAoB,SAAQ,sBAAsB;SAAG;QAC/D,UAAU,kBAAmB,SAAQ,IAAI,CAAC,qBAAqB,EAAE,MAAM,CAAC;SAAG;QAC3E,UAAU,iBAAkB,SAAQ,IAAI,CAAC,oBAAoB,EAAE,MAAM,CAAC;SAAG;QACzE,UAAU,mBAAoB,SAAQ,IAAI,CAAC,sBAAsB,EAAE,MAAM,CAAC;SAAG;KAChF;CACJ;AAID,wBAAsB,cAAc,CAAE,OAAO,EAAE,OAAO,CAAC,SAAS,wCAoH/D"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/driver/index.ts"],"names":[],"mappings":";AAGA,OAAO,EAAyB,MAAM,oBAAoB,CAAA;AAO1D,OAAO,EAA8B,KAAK,mBAAmB,IAAI,sBAAsB,EAAE,MAAM,cAAc,CAAA;AAC7G,OAAO,EAA6B,KAAK,qBAAqB,EAAE,MAAM,aAAa,CAAA;AACnF,OAAO,EAA0C,KAAK,oBAAoB,EAAE,MAAM,YAAY,CAAA;AAC9F,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,qBAAqB,CAAA;AAEzD,OAAO,KAAK,EAAgB,OAAO,EAAE,MAAM,aAAa,CAAA;AAQxD,MAAM,MAAM,sBAAsB,GAAG,cAAc,GAAG,IAAI,CAAC,oBAAoB,EAAE,MAAM,GAAG,mBAAmB,GAAG,sBAAsB,CAAC,CAAA;AACvI,OAAO,CAAC,MAAM,CAAC;IACX,UAAU,WAAW,CAAC;QAClB,UAAU,mBAAoB,SAAQ,sBAAsB;SAAG;QAC/D,UAAU,kBAAmB,SAAQ,IAAI,CAAC,qBAAqB,EAAE,MAAM,CAAC;SAAG;QAC3E,UAAU,iBAAkB,SAAQ,IAAI,CAAC,oBAAoB,EAAE,MAAM,CAAC;SAAG;QACzE,UAAU,mBAAoB,SAAQ,IAAI,CAAC,sBAAsB,EAAE,MAAM,CAAC;SAAG;KAChF;CACJ;AAKD,wBAAsB,cAAc,CAAE,OAAO,EAAE,OAAO,CAAC,SAAS,wCA+H/D"}
@@ -1,4 +1,5 @@
1
1
  import fs from 'node:fs';
2
+ import os from 'node:os';
2
3
  import path from 'node:path';
3
4
  import cp from 'node:child_process';
4
5
  import getPort from 'get-port';
@@ -7,10 +8,11 @@ import logger from '@wdio/logger';
7
8
  import { deepmerge } from 'deepmerge-ts';
8
9
  import { start as startSafaridriver } from 'safaridriver';
9
10
  import { start as startGeckodriver } from 'geckodriver';
10
- import { start as startEdgedriver } from 'edgedriver';
11
+ import { start as startEdgedriver, findEdgePath } from 'edgedriver';
11
12
  import { parseParams, setupChrome, definesRemoteDriver, setupChromedriver, isChrome, isFirefox, isEdge, isSafari, getCacheDir } from './utils.js';
12
13
  import { SUPPORTED_BROWSERNAMES } from '../constants.js';
13
14
  const log = logger('@wdio/utils');
15
+ const DRIVER_WAIT_TIMEOUT = 10 * 1000; // 10s
14
16
  export async function startWebDriver(options) {
15
17
  /**
16
18
  * in case we are running unit tests, just return
@@ -48,7 +50,9 @@ export async function startWebDriver(options) {
48
50
  */
49
51
  const chromedriverOptions = caps['wdio:chromedriverOptions'] || {};
50
52
  const { executablePath: chromeExecuteablePath, browserVersion } = await setupChrome(cacheDir, caps);
51
- const { executablePath: chromedriverExcecuteablePath } = await setupChromedriver(cacheDir, browserVersion);
53
+ const { executablePath: chromedriverExcecuteablePath } = chromedriverOptions.binary
54
+ ? { executablePath: chromedriverOptions.binary }
55
+ : await setupChromedriver(cacheDir, browserVersion);
52
56
  caps['goog:chromeOptions'] = deepmerge({ binary: chromeExecuteablePath }, caps['goog:chromeOptions'] || {});
53
57
  chromedriverOptions.allowedOrigins = chromedriverOptions.allowedOrigins || ['*'];
54
58
  chromedriverOptions.allowedIps = chromedriverOptions.allowedIps || [''];
@@ -94,6 +98,13 @@ export async function startWebDriver(options) {
94
98
  * Microsoft Edge is very particular when it comes to browser names
95
99
  */
96
100
  caps.browserName = 'MicrosoftEdge';
101
+ /**
102
+ * on Linux set the path to the Edge binary if not already set
103
+ */
104
+ if (!caps['ms:edgeOptions']?.binary && os.platform() !== 'darwin' && os.platform() !== 'win32') {
105
+ caps['ms:edgeOptions'] = caps['ms:edgeOptions'] || {};
106
+ caps['ms:edgeOptions'].binary = findEdgePath();
107
+ }
97
108
  }
98
109
  else {
99
110
  throw new Error(`Unknown browser name "${caps.browserName}". Make sure to pick from one of the following ` +
@@ -109,7 +120,8 @@ export async function startWebDriver(options) {
109
120
  driverProcess.stdout?.pipe(logStream);
110
121
  driverProcess.stderr?.pipe(logStream);
111
122
  }
112
- await waitPort({ port, output: 'silent' });
123
+ await waitPort({ port, output: 'silent', timeout: DRIVER_WAIT_TIMEOUT })
124
+ .catch((e) => { throw new Error(`Timed out to connect to ${driver}: ${e.message}`); });
113
125
  options.hostname = '0.0.0.0';
114
126
  options.port = port;
115
127
  log.info(`Started ${driver} in ${Date.now() - start}ms on port ${port}`);
@@ -5,17 +5,8 @@ export declare function getLocalChromePath(): string | undefined;
5
5
  export declare function getBuildIdByPath(chromePath?: string): string | undefined;
6
6
  export declare const downloadProgressCallback: (artifact: string, downloadedBytes: number, totalBytes: number) => void;
7
7
  export declare function setupChrome(cacheDir: string, caps: Capabilities.Capabilities): Promise<{
8
- cacheDir: string;
9
- platform: import("@puppeteer/browsers").BrowserPlatform;
10
8
  executablePath: string;
11
- buildId: string;
12
- browserVersion?: undefined;
13
- } | {
14
- executablePath: string;
15
- browserVersion: string;
16
- cacheDir?: undefined;
17
- platform?: undefined;
18
- buildId?: undefined;
9
+ browserVersion: string | undefined;
19
10
  }>;
20
11
  export declare function getCacheDir(options: Pick<Options.WebDriver, 'cacheDir'>, caps: Capabilities.Capabilities): string;
21
12
  export declare function setupChromedriver(cacheDir: string, driverVersion?: string): Promise<{
@@ -1 +1 @@
1
- {"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../../src/driver/utils.ts"],"names":[],"mappings":"AAgBA,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,YAAY,CAAA;AACtD,OAAO,KAAK,EAAE,OAAO,EAAE,YAAY,EAAE,MAAM,aAAa,CAAA;AAOxD,wBAAgB,WAAW,CAAC,MAAM,EAAE,oBAAoB,YAYvD;AAED,wBAAgB,kBAAkB,uBAOjC;AAED,wBAAgB,gBAAgB,CAAC,UAAU,CAAC,EAAE,MAAM,sBAenD;AAGD,eAAO,MAAM,wBAAwB,aAAc,MAAM,mBAAmB,MAAM,cAAc,MAAM,SAOrG,CAAA;AAED,wBAAsB,WAAW,CAAC,QAAQ,EAAE,MAAM,EAAE,IAAI,EAAE,YAAY,CAAC,YAAY;;;;;;;;;;;;GAmDlF;AAED,wBAAgB,WAAW,CAAE,OAAO,EAAE,IAAI,CAAC,OAAO,CAAC,SAAS,EAAE,UAAU,CAAC,EAAE,IAAI,EAAE,YAAY,CAAC,YAAY,UASzG;AAED,wBAAsB,iBA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,CAAC,EAAE,IAAI,EAAE,YAAY,CAAC,YAAY,UAGzG;AAED,wBAAsB,iBAAiB,CAAE,QAAQ,EAAE,MAAM,EAAE,aAAa,CAAC,EAAE,MAAM;;GA8DhF;AAED,wBAAgB,gBAAgB,CAAE,QAAQ,EAAE,MAAM,EAAE,aAAa,CAAC,EAAE,MAAM,mBAEzE;AAED,wBAAgB,eAAe,CAAE,QAAQ,EAAE,MAAM,EAAE,aAAa,CAAC,EAAE,MAAM,mBAExE;AAED;;;;;;;GAOG;AACH,wBAAgB,mBAAmB,CAAC,OAAO,EAAE,IAAI,CAAC,OAAO,CAAC,SAAS,EAAE,MAAM,GAAG,KAAK,GAAG,UAAU,GAAG,UAAU,GAAG,MAAM,GAAG,MAAM,CAAC,WAQ/H;AAED,wBAAgB,QAAQ,CAAE,WAAW,CAAC,EAAE,MAAM,WAE7C;AACD,wBAAgB,QAAQ,CAAE,WAAW,CAAC,EAAE,MAAM,WAE7C;AACD,wBAAgB,SAAS,CAAE,WAAW,CAAC,EAAE,MAAM,WAE9C;AACD,wBAAgB,MAAM,CAAE,WAAW,CAAC,EAAE,MAAM,WAE3C"}
@@ -65,6 +65,16 @@ export async function setupChrome(cacheDir, caps) {
65
65
  if (!exist) {
66
66
  await fsp.mkdir(cacheDir, { recursive: true });
67
67
  }
68
+ /**
69
+ * don't set up Chrome if a binary was defined in caps
70
+ */
71
+ const chromeOptions = caps['goog:chromeOptions'] || {};
72
+ if (typeof chromeOptions.binary === 'string') {
73
+ return {
74
+ executablePath: chromeOptions.binary,
75
+ browserVersion: getBuildIdByPath(chromeOptions.binary)
76
+ };
77
+ }
68
78
  const platform = detectBrowserPlatform();
69
79
  if (!platform) {
70
80
  throw new Error('The current platform is not supported.');
@@ -77,10 +87,8 @@ export async function setupChrome(cacheDir, caps) {
77
87
  */
78
88
  if (tag) {
79
89
  return {
80
- cacheDir,
81
- platform,
82
90
  executablePath,
83
- buildId: await resolveBuildId(Browser.CHROME, platform, tag)
91
+ browserVersion: await resolveBuildId(Browser.CHROME, platform, tag)
84
92
  };
85
93
  }
86
94
  }
@@ -106,12 +114,16 @@ export async function setupChrome(cacheDir, caps) {
106
114
  const executablePath = computeExecutablePath(installOptions);
107
115
  return { executablePath, browserVersion: buildId };
108
116
  }
109
- export function getCacheDir(options, caps) {
110
- const driverOptions = (caps['wdio:chromedriverOptions'] ||
111
- caps['wdio:chromedriverOptions'] ||
112
- caps['wdio:chromedriverOptions'] ||
113
- caps['wdio:chromedriverOptions'] ||
117
+ function getDriverOptions(caps) {
118
+ return (caps['wdio:chromedriverOptions'] ||
119
+ caps['wdio:geckodriverOptions'] ||
120
+ caps['wdio:edgedriverOptions'] ||
121
+ // Safaridriver does not have any options as it already
122
+ // is installed on macOS
114
123
  {});
124
+ }
125
+ export function getCacheDir(options, caps) {
126
+ const driverOptions = getDriverOptions(caps);
115
127
  return driverOptions.cacheDir || options.cacheDir || os.tmpdir();
116
128
  }
117
129
  export async function setupChromedriver(cacheDir, driverVersion) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@wdio/utils",
3
- "version": "8.15.4",
3
+ "version": "8.15.7",
4
4
  "description": "A WDIO helper utility to provide several utility functions used across the project.",
5
5
  "author": "Christian Bromann <mail@bromann.dev>",
6
6
  "homepage": "https://github.com/webdriverio/webdriverio/tree/main/packages/wdio-utils",
@@ -32,11 +32,11 @@
32
32
  "dependencies": {
33
33
  "@puppeteer/browsers": "^1.6.0",
34
34
  "@wdio/logger": "8.11.0",
35
- "@wdio/types": "8.15.0",
35
+ "@wdio/types": "8.15.7",
36
36
  "chrome-launcher": "^1.0.0",
37
37
  "decamelize": "^6.0.0",
38
38
  "deepmerge-ts": "^5.1.0",
39
- "edgedriver": "^5.3.3",
39
+ "edgedriver": "^5.3.5",
40
40
  "geckodriver": "^4.2.0",
41
41
  "get-port": "^7.0.0",
42
42
  "got": "^13.0.0",
@@ -47,5 +47,5 @@
47
47
  "publishConfig": {
48
48
  "access": "public"
49
49
  },
50
- "gitHead": "528fe3a1d3d37a44f58882a65170971f38461add"
50
+ "gitHead": "24d8f0dccf54e6e19779094d73eb90ae9086ee86"
51
51
  }