@wdio/utils 8.20.0 → 8.21.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.
- package/build/envDetector.d.ts.map +1 -1
- package/build/envDetector.js +15 -2
- package/build/node/utils.d.ts.map +1 -1
- package/build/node/utils.js +39 -9
- package/package.json +3 -3
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"envDetector.d.ts","sourceRoot":"","sources":["../src/envDetector.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,aAAa,CAAA;AAQ/C;;;;GAIG;AACH,wBAAgB,KAAK,CAAC,YAAY,CAAC,EAAE,YAAY,CAAC,mBAAmB,WAwCpE;
|
|
1
|
+
{"version":3,"file":"envDetector.d.ts","sourceRoot":"","sources":["../src/envDetector.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,aAAa,CAAA;AAQ/C;;;;GAIG;AACH,wBAAgB,KAAK,CAAC,YAAY,CAAC,EAAE,YAAY,CAAC,mBAAmB,WAwCpE;AAwKD;;;;;GAKG;AACH,wBAAgB,+BAA+B,CAAC,YAAY,EAAE,WAAW,CAAC,YAAY,EAAE,kBAAkB,EAAE,MAAM;;;;;;;;EAIjH;AAED;;;;;GAKG;AACH,wBAAgB,0BAA0B,CAAC,EAAE,YAAY,EAAE,qBAAqB,EAAE,EAC9E;IAAE,YAAY,EAAE,YAAY,CAAC,gBAAgB,CAAC;IAAC,qBAAqB,EAAE,YAAY,CAAC,gBAAgB,CAAA;CAAE;;;;;;;;;;EAexG;AAED;;;;GAIG;AACH,wBAAgB,2BAA2B,CAAC,EAAE,WAAW,EAAE,EAAE,WAAW,CAAC,YAAY;;;;;;;;;;;EAapF;AAED;;;;;GAKG;AACH,wBAAgB,4BAA4B,CAAC,YAAY,EAAE,WAAW,CAAC,YAAY;;;;;;;;EAUlF"}
|
package/build/envDetector.js
CHANGED
|
@@ -76,6 +76,8 @@ function isFirefox(capabilities) {
|
|
|
76
76
|
*/
|
|
77
77
|
function isMobile(capabilities) {
|
|
78
78
|
const browserName = (capabilities.browserName || '').toLowerCase();
|
|
79
|
+
const bsOptions = capabilities['bstack:options'] || {};
|
|
80
|
+
const browserstackBrowserName = (bsOptions.browserName || '').toLowerCase();
|
|
79
81
|
/**
|
|
80
82
|
* we have mobile capabilities if
|
|
81
83
|
*/
|
|
@@ -86,6 +88,9 @@ function isMobile(capabilities) {
|
|
|
86
88
|
capabilities.platformName && capabilities.platformName.match(/ios/i) ||
|
|
87
89
|
capabilities.platformName && capabilities.platformName.match(/tvos/i) ||
|
|
88
90
|
capabilities.platformName && capabilities.platformName.match(/android/i) ||
|
|
91
|
+
/ios/i.test(bsOptions.platformName || '') ||
|
|
92
|
+
/tvos/i.test(bsOptions.platformName || '') ||
|
|
93
|
+
/android/i.test(bsOptions.platformName || '') ||
|
|
89
94
|
/**
|
|
90
95
|
* capabilities contain mobile only specific capabilities
|
|
91
96
|
*/
|
|
@@ -94,10 +99,12 @@ function isMobile(capabilities) {
|
|
|
94
99
|
* browserName is empty (and eventually app is defined)
|
|
95
100
|
*/
|
|
96
101
|
capabilities.browserName === '' ||
|
|
102
|
+
bsOptions.browserName === '' ||
|
|
97
103
|
/**
|
|
98
104
|
* browserName is a mobile browser
|
|
99
105
|
*/
|
|
100
|
-
MOBILE_BROWSER_NAMES.includes(browserName)
|
|
106
|
+
MOBILE_BROWSER_NAMES.includes(browserName) ||
|
|
107
|
+
MOBILE_BROWSER_NAMES.includes(browserstackBrowserName));
|
|
101
108
|
}
|
|
102
109
|
/**
|
|
103
110
|
* check if session is run on iOS device
|
|
@@ -105,11 +112,14 @@ function isMobile(capabilities) {
|
|
|
105
112
|
* @return {Boolean} true if run on iOS device
|
|
106
113
|
*/
|
|
107
114
|
function isIOS(capabilities) {
|
|
115
|
+
const bsOptions = capabilities?.['bstack:options'] || {};
|
|
108
116
|
if (!capabilities) {
|
|
109
117
|
return false;
|
|
110
118
|
}
|
|
111
119
|
return Boolean((capabilities.platformName && capabilities.platformName.match(/iOS/i)) ||
|
|
112
|
-
(capabilities.deviceName && capabilities.deviceName.match(/(iPad|iPhone)/i))
|
|
120
|
+
(capabilities.deviceName && capabilities.deviceName.match(/(iPad|iPhone)/i)) ||
|
|
121
|
+
(/iOS/i.test(bsOptions.platformName || '')) ||
|
|
122
|
+
(/(iPad|iPhone)/i.test(bsOptions.deviceName || '')));
|
|
113
123
|
}
|
|
114
124
|
/**
|
|
115
125
|
* check if session is run on Android device
|
|
@@ -117,10 +127,13 @@ function isIOS(capabilities) {
|
|
|
117
127
|
* @return {Boolean} true if run on Android device
|
|
118
128
|
*/
|
|
119
129
|
function isAndroid(capabilities) {
|
|
130
|
+
const bsOptions = capabilities?.['bstack:options'] || {};
|
|
120
131
|
if (!capabilities) {
|
|
121
132
|
return false;
|
|
122
133
|
}
|
|
123
134
|
return Boolean((capabilities.platformName && capabilities.platformName.match(/Android/i)) ||
|
|
135
|
+
(/Android/i.test(bsOptions.platformName || '')) ||
|
|
136
|
+
(/Android/i.test(bsOptions.browserName || '')) ||
|
|
124
137
|
(capabilities.browserName && capabilities.browserName.match(/Android/i)));
|
|
125
138
|
}
|
|
126
139
|
/**
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../../src/node/utils.ts"],"names":[],"mappings":"AAeA,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,YAAY,CAAA;AACtD,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,aAAa,CAAA;AAK1C;;;;GAIG;AACH,eAAO,MAAM,SAAS,UAAW,MAAM,YAWtC,CAAA;AAED,wBAAgB,WAAW,CAAC,MAAM,EAAE,oBAAoB,YAYvD;AAED,wBAAgB,sBAAsB,CAAC,UAAU,CAAC,EAAE,MAAM,sBAqBzD;AAED,wBAAsB,uBAAuB,CAAC,WAAW,CAAC,EAAE,MAAM,+BAiBjE;AAGD,eAAO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wdio/logger';
|
|
|
8
8
|
import { install, canDownload, resolveBuildId, detectBrowserPlatform, Browser, ChromeReleaseChannel, computeExecutablePath } from '@puppeteer/browsers';
|
|
9
9
|
import { download as downloadGeckodriver } from 'geckodriver';
|
|
10
10
|
import { download as downloadEdgedriver } from 'edgedriver';
|
|
11
|
-
import { locateChrome, locateFirefox } from 'locate-app';
|
|
11
|
+
import { locateChrome, locateFirefox, locateApp } from 'locate-app';
|
|
12
12
|
const log = logger('webdriver');
|
|
13
13
|
const EXCLUDED_PARAMS = ['version', 'help'];
|
|
14
14
|
/**
|
|
@@ -102,24 +102,39 @@ const _install = async (args) => {
|
|
|
102
102
|
await install(args);
|
|
103
103
|
log.progress('');
|
|
104
104
|
};
|
|
105
|
+
function locateChromeSafely() {
|
|
106
|
+
return locateChrome().catch(() => undefined);
|
|
107
|
+
}
|
|
105
108
|
export async function setupPuppeteerBrowser(cacheDir, caps) {
|
|
106
109
|
caps.browserName = caps.browserName?.toLowerCase();
|
|
107
|
-
const browserName = caps.browserName === Browser.FIREFOX
|
|
110
|
+
const browserName = caps.browserName === Browser.FIREFOX
|
|
111
|
+
? Browser.FIREFOX
|
|
112
|
+
: caps.browserName === Browser.CHROMIUM
|
|
113
|
+
? Browser.CHROMIUM
|
|
114
|
+
: Browser.CHROME;
|
|
108
115
|
const exist = await fsp.access(cacheDir).then(() => true, () => false);
|
|
116
|
+
const isChromeOrChromium = browserName === Browser.CHROME || caps.browserName === Browser.CHROMIUM;
|
|
109
117
|
if (!exist) {
|
|
110
118
|
await fsp.mkdir(cacheDir, { recursive: true });
|
|
111
119
|
}
|
|
120
|
+
/**
|
|
121
|
+
* in case we run Chromium tests we have to switch back to browserName: 'chrome'
|
|
122
|
+
* as 'chromium' is not recognised as a valid browser name by Chromedriver
|
|
123
|
+
*/
|
|
124
|
+
if (browserName === Browser.CHROMIUM) {
|
|
125
|
+
caps.browserName = Browser.CHROME;
|
|
126
|
+
}
|
|
112
127
|
/**
|
|
113
128
|
* don't set up Chrome/Firefox if a binary was defined in caps
|
|
114
129
|
*/
|
|
115
|
-
const browserOptions = (
|
|
130
|
+
const browserOptions = (isChromeOrChromium
|
|
116
131
|
? caps['goog:chromeOptions']
|
|
117
132
|
: caps['moz:firefoxOptions']) || {};
|
|
118
133
|
if (typeof browserOptions.binary === 'string') {
|
|
119
134
|
return {
|
|
120
135
|
executablePath: browserOptions.binary,
|
|
121
136
|
browserVersion: (caps.browserVersion ||
|
|
122
|
-
(
|
|
137
|
+
(isChromeOrChromium
|
|
123
138
|
? getBuildIdByChromePath(browserOptions.binary)
|
|
124
139
|
: await getBuildIdByFirefoxPath(browserOptions.binary)))
|
|
125
140
|
};
|
|
@@ -130,9 +145,15 @@ export async function setupPuppeteerBrowser(cacheDir, caps) {
|
|
|
130
145
|
}
|
|
131
146
|
if (!caps.browserVersion) {
|
|
132
147
|
const executablePath = browserName === Browser.CHROME
|
|
133
|
-
? await
|
|
134
|
-
:
|
|
135
|
-
|
|
148
|
+
? await locateChromeSafely()
|
|
149
|
+
: browserName === Browser.CHROMIUM
|
|
150
|
+
? await locateApp({
|
|
151
|
+
appName: Browser.CHROMIUM,
|
|
152
|
+
macOsName: Browser.CHROMIUM,
|
|
153
|
+
linuxWhich: 'chromium-browser'
|
|
154
|
+
}).catch(() => undefined)
|
|
155
|
+
: await locateFirefox().catch(() => undefined);
|
|
156
|
+
const tag = isChromeOrChromium
|
|
136
157
|
? getBuildIdByChromePath(executablePath)
|
|
137
158
|
: await getBuildIdByFirefoxPath(executablePath);
|
|
138
159
|
/**
|
|
@@ -167,7 +188,16 @@ export async function setupPuppeteerBrowser(cacheDir, caps) {
|
|
|
167
188
|
log.info(`Setting up ${browserName} v${buildId}`);
|
|
168
189
|
await _install(installOptions);
|
|
169
190
|
const executablePath = computeExecutablePath(installOptions);
|
|
170
|
-
|
|
191
|
+
/**
|
|
192
|
+
* for Chromium browser `resolveBuildId` returns with a useless build id
|
|
193
|
+
* which will not find a Chromedriver, therefor we need to resolve the
|
|
194
|
+
* id using Chrome as browser name
|
|
195
|
+
*/
|
|
196
|
+
let browserVersion = buildId;
|
|
197
|
+
if (browserName === Browser.CHROMIUM) {
|
|
198
|
+
browserVersion = await resolveBuildId(Browser.CHROME, platform, tag);
|
|
199
|
+
}
|
|
200
|
+
return { executablePath, browserVersion };
|
|
171
201
|
}
|
|
172
202
|
export function getDriverOptions(caps) {
|
|
173
203
|
return (caps['wdio:chromedriverOptions'] ||
|
|
@@ -193,7 +223,7 @@ export async function setupChromedriver(cacheDir, driverVersion) {
|
|
|
193
223
|
if (!platform) {
|
|
194
224
|
throw new Error('The current platform is not supported.');
|
|
195
225
|
}
|
|
196
|
-
const version = driverVersion || getBuildIdByChromePath(await
|
|
226
|
+
const version = driverVersion || getBuildIdByChromePath(await locateChromeSafely()) || ChromeReleaseChannel.STABLE;
|
|
197
227
|
const buildId = await resolveBuildId(Browser.CHROMEDRIVER, platform, version);
|
|
198
228
|
let executablePath = computeExecutablePath({
|
|
199
229
|
browser: Browser.CHROMEDRIVER,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@wdio/utils",
|
|
3
|
-
"version": "8.
|
|
3
|
+
"version": "8.21.0",
|
|
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",
|
|
@@ -39,7 +39,7 @@
|
|
|
39
39
|
"dependencies": {
|
|
40
40
|
"@puppeteer/browsers": "^1.6.0",
|
|
41
41
|
"@wdio/logger": "8.16.17",
|
|
42
|
-
"@wdio/types": "8.
|
|
42
|
+
"@wdio/types": "8.21.0",
|
|
43
43
|
"decamelize": "^6.0.0",
|
|
44
44
|
"deepmerge-ts": "^5.1.0",
|
|
45
45
|
"edgedriver": "^5.3.5",
|
|
@@ -55,5 +55,5 @@
|
|
|
55
55
|
"publishConfig": {
|
|
56
56
|
"access": "public"
|
|
57
57
|
},
|
|
58
|
-
"gitHead": "
|
|
58
|
+
"gitHead": "92a7474463e872223ee26c99112e79ad7d8eb8d3"
|
|
59
59
|
}
|