@wdio/utils 7.17.0 → 7.19.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/constants.d.ts +82 -0
- package/build/constants.d.ts.map +1 -0
- package/build/constants.js +84 -0
- package/build/envDetector.d.ts +71 -0
- package/build/envDetector.d.ts.map +1 -0
- package/build/envDetector.js +223 -0
- package/build/index.d.ts +22 -0
- package/build/index.d.ts.map +1 -0
- package/build/index.js +40 -0
- package/build/initialisePlugin.d.ts +9 -0
- package/build/initialisePlugin.d.ts.map +1 -0
- package/build/initialisePlugin.js +45 -0
- package/build/initialiseServices.d.ts +23 -0
- package/build/initialiseServices.d.ts.map +1 -0
- package/build/initialiseServices.js +162 -0
- package/build/monad.d.ts +16 -0
- package/build/monad.d.ts.map +1 -0
- package/build/monad.js +171 -0
- package/build/shim.d.ts +59 -0
- package/build/shim.d.ts.map +1 -0
- package/build/shim.js +402 -0
- package/build/test-framework/errorHandler.d.ts +11 -0
- package/build/test-framework/errorHandler.d.ts.map +1 -0
- package/build/test-framework/errorHandler.js +35 -0
- package/build/test-framework/index.d.ts +4 -0
- package/build/test-framework/index.d.ts.map +1 -0
- package/build/test-framework/index.js +8 -0
- package/build/test-framework/testFnWrapper.d.ts +27 -0
- package/build/test-framework/testFnWrapper.d.ts.map +1 -0
- package/build/test-framework/testFnWrapper.js +80 -0
- package/build/test-framework/testInterfaceWrapper.d.ts +68 -0
- package/build/test-framework/testInterfaceWrapper.d.ts.map +1 -0
- package/build/test-framework/testInterfaceWrapper.js +159 -0
- package/build/test-framework/types.d.ts +52 -0
- package/build/test-framework/types.d.ts.map +1 -0
- package/build/test-framework/types.js +2 -0
- package/build/utils.d.ts +76 -0
- package/build/utils.d.ts.map +1 -0
- package/build/utils.js +251 -0
- package/package.json +5 -5
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* unicode characters
|
|
3
|
+
* https://w3c.github.io/webdriver/webdriver-spec.html#character-types
|
|
4
|
+
*/
|
|
5
|
+
export declare const UNICODE_CHARACTERS: {
|
|
6
|
+
NULL: string;
|
|
7
|
+
Unidentified: string;
|
|
8
|
+
Cancel: string;
|
|
9
|
+
Help: string;
|
|
10
|
+
Backspace: string;
|
|
11
|
+
'Back space': string;
|
|
12
|
+
Tab: string;
|
|
13
|
+
Clear: string;
|
|
14
|
+
Return: string;
|
|
15
|
+
Enter: string;
|
|
16
|
+
Shift: string;
|
|
17
|
+
Control: string;
|
|
18
|
+
'Control Left': string;
|
|
19
|
+
'Control Right': string;
|
|
20
|
+
Alt: string;
|
|
21
|
+
Pause: string;
|
|
22
|
+
Escape: string;
|
|
23
|
+
Space: string;
|
|
24
|
+
' ': string;
|
|
25
|
+
PageUp: string;
|
|
26
|
+
Pageup: string;
|
|
27
|
+
Page_Up: string;
|
|
28
|
+
PageDown: string;
|
|
29
|
+
Pagedown: string;
|
|
30
|
+
Page_Down: string;
|
|
31
|
+
End: string;
|
|
32
|
+
Home: string;
|
|
33
|
+
ArrowLeft: string;
|
|
34
|
+
'Left arrow': string;
|
|
35
|
+
Arrow_Left: string;
|
|
36
|
+
ArrowUp: string;
|
|
37
|
+
'Up arrow': string;
|
|
38
|
+
Arrow_Up: string;
|
|
39
|
+
ArrowRight: string;
|
|
40
|
+
'Right arrow': string;
|
|
41
|
+
Arrow_Right: string;
|
|
42
|
+
ArrowDown: string;
|
|
43
|
+
'Down arrow': string;
|
|
44
|
+
Arrow_Down: string;
|
|
45
|
+
Insert: string;
|
|
46
|
+
Delete: string;
|
|
47
|
+
Semicolon: string;
|
|
48
|
+
Equals: string;
|
|
49
|
+
'Numpad 0': string;
|
|
50
|
+
'Numpad 1': string;
|
|
51
|
+
'Numpad 2': string;
|
|
52
|
+
'Numpad 3': string;
|
|
53
|
+
'Numpad 4': string;
|
|
54
|
+
'Numpad 5': string;
|
|
55
|
+
'Numpad 6': string;
|
|
56
|
+
'Numpad 7': string;
|
|
57
|
+
'Numpad 8': string;
|
|
58
|
+
'Numpad 9': string;
|
|
59
|
+
Multiply: string;
|
|
60
|
+
Add: string;
|
|
61
|
+
Separator: string;
|
|
62
|
+
Subtract: string;
|
|
63
|
+
Decimal: string;
|
|
64
|
+
Divide: string;
|
|
65
|
+
F1: string;
|
|
66
|
+
F2: string;
|
|
67
|
+
F3: string;
|
|
68
|
+
F4: string;
|
|
69
|
+
F5: string;
|
|
70
|
+
F6: string;
|
|
71
|
+
F7: string;
|
|
72
|
+
F8: string;
|
|
73
|
+
F9: string;
|
|
74
|
+
F10: string;
|
|
75
|
+
F11: string;
|
|
76
|
+
F12: string;
|
|
77
|
+
Command: string;
|
|
78
|
+
Meta: string;
|
|
79
|
+
ZenkakuHankaku: string;
|
|
80
|
+
Zenkaku_Hankaku: string;
|
|
81
|
+
};
|
|
82
|
+
//# sourceMappingURL=constants.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"constants.d.ts","sourceRoot":"","sources":["../src/constants.ts"],"names":[],"mappings":"AAAA;;;GAGG;AACH,eAAO,MAAM,kBAAkB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CA4E9B,CAAA"}
|
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.UNICODE_CHARACTERS = void 0;
|
|
4
|
+
/**
|
|
5
|
+
* unicode characters
|
|
6
|
+
* https://w3c.github.io/webdriver/webdriver-spec.html#character-types
|
|
7
|
+
*/
|
|
8
|
+
exports.UNICODE_CHARACTERS = {
|
|
9
|
+
'NULL': '\uE000',
|
|
10
|
+
'Unidentified': '\uE000',
|
|
11
|
+
'Cancel': '\uE001',
|
|
12
|
+
'Help': '\uE002',
|
|
13
|
+
'Backspace': '\uE003',
|
|
14
|
+
'Back space': '\uE003',
|
|
15
|
+
'Tab': '\uE004',
|
|
16
|
+
'Clear': '\uE005',
|
|
17
|
+
'Return': '\uE006',
|
|
18
|
+
'Enter': '\uE007',
|
|
19
|
+
'Shift': '\uE008',
|
|
20
|
+
'Control': '\uE009',
|
|
21
|
+
'Control Left': '\uE009',
|
|
22
|
+
'Control Right': '\uE051',
|
|
23
|
+
'Alt': '\uE00A',
|
|
24
|
+
'Pause': '\uE00B',
|
|
25
|
+
'Escape': '\uE00C',
|
|
26
|
+
'Space': '\uE00D',
|
|
27
|
+
' ': '\uE00D',
|
|
28
|
+
'PageUp': '\uE00E',
|
|
29
|
+
'Pageup': '\uE00E',
|
|
30
|
+
'Page_Up': '\uE00E',
|
|
31
|
+
'PageDown': '\uE00F',
|
|
32
|
+
'Pagedown': '\uE00F',
|
|
33
|
+
'Page_Down': '\uE00F',
|
|
34
|
+
'End': '\uE010',
|
|
35
|
+
'Home': '\uE011',
|
|
36
|
+
'ArrowLeft': '\uE012',
|
|
37
|
+
'Left arrow': '\uE012',
|
|
38
|
+
'Arrow_Left': '\uE012',
|
|
39
|
+
'ArrowUp': '\uE013',
|
|
40
|
+
'Up arrow': '\uE013',
|
|
41
|
+
'Arrow_Up': '\uE013',
|
|
42
|
+
'ArrowRight': '\uE014',
|
|
43
|
+
'Right arrow': '\uE014',
|
|
44
|
+
'Arrow_Right': '\uE014',
|
|
45
|
+
'ArrowDown': '\uE015',
|
|
46
|
+
'Down arrow': '\uE015',
|
|
47
|
+
'Arrow_Down': '\uE015',
|
|
48
|
+
'Insert': '\uE016',
|
|
49
|
+
'Delete': '\uE017',
|
|
50
|
+
'Semicolon': '\uE018',
|
|
51
|
+
'Equals': '\uE019',
|
|
52
|
+
'Numpad 0': '\uE01A',
|
|
53
|
+
'Numpad 1': '\uE01B',
|
|
54
|
+
'Numpad 2': '\uE01C',
|
|
55
|
+
'Numpad 3': '\uE01D',
|
|
56
|
+
'Numpad 4': '\uE01E',
|
|
57
|
+
'Numpad 5': '\uE01F',
|
|
58
|
+
'Numpad 6': '\uE020',
|
|
59
|
+
'Numpad 7': '\uE021',
|
|
60
|
+
'Numpad 8': '\uE022',
|
|
61
|
+
'Numpad 9': '\uE023',
|
|
62
|
+
'Multiply': '\uE024',
|
|
63
|
+
'Add': '\uE025',
|
|
64
|
+
'Separator': '\uE026',
|
|
65
|
+
'Subtract': '\uE027',
|
|
66
|
+
'Decimal': '\uE028',
|
|
67
|
+
'Divide': '\uE029',
|
|
68
|
+
'F1': '\uE031',
|
|
69
|
+
'F2': '\uE032',
|
|
70
|
+
'F3': '\uE033',
|
|
71
|
+
'F4': '\uE034',
|
|
72
|
+
'F5': '\uE035',
|
|
73
|
+
'F6': '\uE036',
|
|
74
|
+
'F7': '\uE037',
|
|
75
|
+
'F8': '\uE038',
|
|
76
|
+
'F9': '\uE039',
|
|
77
|
+
'F10': '\uE03A',
|
|
78
|
+
'F11': '\uE03B',
|
|
79
|
+
'F12': '\uE03C',
|
|
80
|
+
'Command': '\uE03D',
|
|
81
|
+
'Meta': '\uE03D',
|
|
82
|
+
'ZenkakuHankaku': '\uE040',
|
|
83
|
+
'Zenkaku_Hankaku': '\uE040'
|
|
84
|
+
};
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
import type { Capabilities } from '@wdio/types';
|
|
2
|
+
/**
|
|
3
|
+
* check if session is based on W3C protocol based on the /session response
|
|
4
|
+
* @param {Object} capabilities caps of session response
|
|
5
|
+
* @return {Boolean} true if W3C (browser)
|
|
6
|
+
*/
|
|
7
|
+
export declare function isW3C(capabilities?: Capabilities.DesiredCapabilities): boolean;
|
|
8
|
+
/**
|
|
9
|
+
* returns information about the environment before the session is created
|
|
10
|
+
* @param {Object} capabilities caps provided by user
|
|
11
|
+
* @param {string=} automationProtocol `devtools`
|
|
12
|
+
* @return {Object} object with environment flags
|
|
13
|
+
*/
|
|
14
|
+
export declare function capabilitiesEnvironmentDetector(capabilities: Capabilities.Capabilities, automationProtocol: string): {
|
|
15
|
+
isChrome: boolean;
|
|
16
|
+
isFirefox: boolean;
|
|
17
|
+
isMobile: boolean;
|
|
18
|
+
isIOS: boolean;
|
|
19
|
+
isAndroid: boolean;
|
|
20
|
+
isSauce: boolean;
|
|
21
|
+
};
|
|
22
|
+
/**
|
|
23
|
+
* returns information about the environment when the session is created
|
|
24
|
+
* @param {Object} capabilities caps of session response
|
|
25
|
+
* @param {Object} requestedCapabilities
|
|
26
|
+
* @return {Object} object with environment flags
|
|
27
|
+
*/
|
|
28
|
+
export declare function sessionEnvironmentDetector({ capabilities, requestedCapabilities }: {
|
|
29
|
+
capabilities: Capabilities.DesiredCapabilities;
|
|
30
|
+
requestedCapabilities: Capabilities.DesiredCapabilities | Capabilities.W3CCapabilities;
|
|
31
|
+
}): {
|
|
32
|
+
isW3C: boolean;
|
|
33
|
+
isChrome: boolean;
|
|
34
|
+
isFirefox: boolean;
|
|
35
|
+
isMobile: boolean;
|
|
36
|
+
isIOS: boolean;
|
|
37
|
+
isAndroid: boolean;
|
|
38
|
+
isSauce: boolean;
|
|
39
|
+
isSeleniumStandalone: boolean;
|
|
40
|
+
};
|
|
41
|
+
/**
|
|
42
|
+
* returns information about the environment when `devtools` protocol is used
|
|
43
|
+
* @param {Object} capabilities caps of session response
|
|
44
|
+
* @return {Object} object with environment flags
|
|
45
|
+
*/
|
|
46
|
+
export declare function devtoolsEnvironmentDetector({ browserName }: Capabilities.Capabilities): {
|
|
47
|
+
isDevTools: boolean;
|
|
48
|
+
isW3C: boolean;
|
|
49
|
+
isMobile: boolean;
|
|
50
|
+
isIOS: boolean;
|
|
51
|
+
isAndroid: boolean;
|
|
52
|
+
isFirefox: boolean;
|
|
53
|
+
isChrome: boolean;
|
|
54
|
+
isSauce: boolean;
|
|
55
|
+
isSeleniumStandalone: boolean;
|
|
56
|
+
};
|
|
57
|
+
/**
|
|
58
|
+
* returns information about the environment before the session is created
|
|
59
|
+
* `isW3C`, `isSeleniumStandalone` cannot be detected
|
|
60
|
+
* @param {Object} capabilities caps provided by user
|
|
61
|
+
* @return {Object} object with environment flags
|
|
62
|
+
*/
|
|
63
|
+
export declare function webdriverEnvironmentDetector(capabilities: Capabilities.Capabilities): {
|
|
64
|
+
isChrome: boolean;
|
|
65
|
+
isFirefox: boolean;
|
|
66
|
+
isMobile: boolean;
|
|
67
|
+
isIOS: boolean;
|
|
68
|
+
isAndroid: boolean;
|
|
69
|
+
isSauce: boolean;
|
|
70
|
+
};
|
|
71
|
+
//# sourceMappingURL=envDetector.d.ts.map
|
|
@@ -0,0 +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,CAAE,YAAY,CAAC,EAAE,YAAY,CAAC,mBAAmB,WAiCrE;AA0ID;;;;;GAKG;AACH,wBAAgB,+BAA+B,CAAE,YAAY,EAAE,YAAY,CAAC,YAAY,EAAE,kBAAkB,EAAE,MAAM;;;;;;;EAInH;AAED;;;;;GAKG;AACH,wBAAgB,0BAA0B,CAAE,EAAE,YAAY,EAAE,qBAAqB,EAAE,EAAE;IAAE,YAAY,EAAE,YAAY,CAAC,mBAAmB,CAAC;IAAC,qBAAqB,EAAE,YAAY,CAAC,mBAAmB,GAAG,YAAY,CAAC,eAAe,CAAA;CAAE;;;;;;;;;EAW9N;AAED;;;;GAIG;AACH,wBAAgB,2BAA2B,CAAE,EAAE,WAAW,EAAE,EAAE,YAAY,CAAC,YAAY;;;;;;;;;;EAYtF;AAED;;;;;GAKG;AACH,wBAAgB,4BAA4B,CAAE,YAAY,EAAE,YAAY,CAAC,YAAY;;;;;;;EASpF"}
|
|
@@ -0,0 +1,223 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.webdriverEnvironmentDetector = exports.devtoolsEnvironmentDetector = exports.sessionEnvironmentDetector = exports.capabilitiesEnvironmentDetector = exports.isW3C = void 0;
|
|
4
|
+
const MOBILE_BROWSER_NAMES = ['ipad', 'iphone', 'android'];
|
|
5
|
+
const MOBILE_CAPABILITIES = [
|
|
6
|
+
'appium-version', 'appiumVersion', 'device-type', 'deviceType',
|
|
7
|
+
'device-orientation', 'deviceOrientation', 'deviceName', 'automationName'
|
|
8
|
+
];
|
|
9
|
+
/**
|
|
10
|
+
* check if session is based on W3C protocol based on the /session response
|
|
11
|
+
* @param {Object} capabilities caps of session response
|
|
12
|
+
* @return {Boolean} true if W3C (browser)
|
|
13
|
+
*/
|
|
14
|
+
function isW3C(capabilities) {
|
|
15
|
+
/**
|
|
16
|
+
* JSONWire protocol doesn't return a property `capabilities`.
|
|
17
|
+
* Also check for Appium response as it is using JSONWire protocol for most of the part.
|
|
18
|
+
*/
|
|
19
|
+
if (!capabilities) {
|
|
20
|
+
return false;
|
|
21
|
+
}
|
|
22
|
+
/**
|
|
23
|
+
* assume session to be a WebDriver session when
|
|
24
|
+
* - capabilities are returned
|
|
25
|
+
* (https://w3c.github.io/webdriver/#dfn-new-sessions)
|
|
26
|
+
* - it is an Appium session (since Appium is full W3C compliant)
|
|
27
|
+
*/
|
|
28
|
+
const isAppium = Boolean(capabilities.automationName ||
|
|
29
|
+
capabilities.deviceName ||
|
|
30
|
+
capabilities.appiumVersion);
|
|
31
|
+
const hasW3CCaps = Boolean(
|
|
32
|
+
/**
|
|
33
|
+
* safari docker image may not provide a platformName therefore
|
|
34
|
+
* check one of the available "platformName" or "browserVersion"
|
|
35
|
+
*/
|
|
36
|
+
(capabilities.platformName || capabilities.browserVersion) &&
|
|
37
|
+
/**
|
|
38
|
+
* local safari and BrowserStack don't provide platformVersion therefore
|
|
39
|
+
* check also if setWindowRect is provided
|
|
40
|
+
*/
|
|
41
|
+
(capabilities.platformVersion || Object.prototype.hasOwnProperty.call(capabilities, 'setWindowRect')));
|
|
42
|
+
return Boolean(hasW3CCaps || isAppium);
|
|
43
|
+
}
|
|
44
|
+
exports.isW3C = isW3C;
|
|
45
|
+
/**
|
|
46
|
+
* check if session is run by Chromedriver
|
|
47
|
+
* @param {Object} capabilities caps of session response
|
|
48
|
+
* @return {Boolean} true if run by Chromedriver
|
|
49
|
+
*/
|
|
50
|
+
function isChrome(capabilities) {
|
|
51
|
+
if (!capabilities) {
|
|
52
|
+
return false;
|
|
53
|
+
}
|
|
54
|
+
return Boolean(capabilities.chrome || capabilities['goog:chromeOptions']);
|
|
55
|
+
}
|
|
56
|
+
/**
|
|
57
|
+
* check if session is run by Chromedriver
|
|
58
|
+
* @param {Object} capabilities caps of session response
|
|
59
|
+
* @return {Boolean} true if run by Chromedriver
|
|
60
|
+
*/
|
|
61
|
+
function isFirefox(capabilities) {
|
|
62
|
+
if (!capabilities) {
|
|
63
|
+
return false;
|
|
64
|
+
}
|
|
65
|
+
return (capabilities.browserName === 'firefox' ||
|
|
66
|
+
Boolean(Object.keys(capabilities).find((cap) => cap.startsWith('moz:'))));
|
|
67
|
+
}
|
|
68
|
+
/**
|
|
69
|
+
* check if current platform is mobile device
|
|
70
|
+
*
|
|
71
|
+
* @param {Object} caps capabilities
|
|
72
|
+
* @return {Boolean} true if platform is mobile device
|
|
73
|
+
*/
|
|
74
|
+
function isMobile(capabilities) {
|
|
75
|
+
const browserName = (capabilities.browserName || '').toLowerCase();
|
|
76
|
+
/**
|
|
77
|
+
* we have mobile capabilities if
|
|
78
|
+
*/
|
|
79
|
+
return Boolean(
|
|
80
|
+
/**
|
|
81
|
+
* there are any Appium vendor capabilties
|
|
82
|
+
*/
|
|
83
|
+
Object.keys(capabilities).find((cap) => cap.startsWith('appium:')) ||
|
|
84
|
+
/**
|
|
85
|
+
* capabilities contain mobile only specific capabilities
|
|
86
|
+
*/
|
|
87
|
+
Object.keys(capabilities).find((cap) => MOBILE_CAPABILITIES.includes(cap)) ||
|
|
88
|
+
/**
|
|
89
|
+
* browserName is empty (and eventually app is defined)
|
|
90
|
+
*/
|
|
91
|
+
capabilities.browserName === '' ||
|
|
92
|
+
/**
|
|
93
|
+
* browserName is a mobile browser
|
|
94
|
+
*/
|
|
95
|
+
MOBILE_BROWSER_NAMES.includes(browserName));
|
|
96
|
+
}
|
|
97
|
+
/**
|
|
98
|
+
* check if session is run on iOS device
|
|
99
|
+
* @param {Object} capabilities of session response
|
|
100
|
+
* @return {Boolean} true if run on iOS device
|
|
101
|
+
*/
|
|
102
|
+
function isIOS(capabilities) {
|
|
103
|
+
if (!capabilities) {
|
|
104
|
+
return false;
|
|
105
|
+
}
|
|
106
|
+
return Boolean((capabilities.platformName && capabilities.platformName.match(/iOS/i)) ||
|
|
107
|
+
(capabilities.deviceName && capabilities.deviceName.match(/(iPad|iPhone)/i)));
|
|
108
|
+
}
|
|
109
|
+
/**
|
|
110
|
+
* check if session is run on Android device
|
|
111
|
+
* @param {Object} capabilities caps of session response
|
|
112
|
+
* @return {Boolean} true if run on Android device
|
|
113
|
+
*/
|
|
114
|
+
function isAndroid(capabilities) {
|
|
115
|
+
if (!capabilities) {
|
|
116
|
+
return false;
|
|
117
|
+
}
|
|
118
|
+
return Boolean((capabilities.platformName && capabilities.platformName.match(/Android/i)) ||
|
|
119
|
+
(capabilities.browserName && capabilities.browserName.match(/Android/i)));
|
|
120
|
+
}
|
|
121
|
+
/**
|
|
122
|
+
* detects if session is run on Sauce with extended debugging enabled
|
|
123
|
+
* @param {string} hostname hostname of session request
|
|
124
|
+
* @param {object} capabilities session capabilities
|
|
125
|
+
* @return {Boolean} true if session is running on Sauce with extended debugging enabled
|
|
126
|
+
*/
|
|
127
|
+
function isSauce(capabilities) {
|
|
128
|
+
if (!capabilities) {
|
|
129
|
+
return false;
|
|
130
|
+
}
|
|
131
|
+
const caps = capabilities.alwaysMatch
|
|
132
|
+
? capabilities.alwaysMatch
|
|
133
|
+
: capabilities;
|
|
134
|
+
return Boolean(caps.extendedDebugging ||
|
|
135
|
+
(caps['sauce:options'] &&
|
|
136
|
+
caps['sauce:options'].extendedDebugging));
|
|
137
|
+
}
|
|
138
|
+
/**
|
|
139
|
+
* detects if session is run using Selenium Standalone server
|
|
140
|
+
* @param {object} capabilities session capabilities
|
|
141
|
+
* @return {Boolean} true if session is run with Selenium Standalone Server
|
|
142
|
+
*/
|
|
143
|
+
function isSeleniumStandalone(capabilities) {
|
|
144
|
+
if (!capabilities) {
|
|
145
|
+
return false;
|
|
146
|
+
}
|
|
147
|
+
return (
|
|
148
|
+
/**
|
|
149
|
+
* Selenium v3 and below
|
|
150
|
+
*/
|
|
151
|
+
Boolean(capabilities['webdriver.remote.sessionid']) ||
|
|
152
|
+
/**
|
|
153
|
+
* Selenium v4 and up
|
|
154
|
+
*/
|
|
155
|
+
Boolean(capabilities['se:cdp']));
|
|
156
|
+
}
|
|
157
|
+
/**
|
|
158
|
+
* returns information about the environment before the session is created
|
|
159
|
+
* @param {Object} capabilities caps provided by user
|
|
160
|
+
* @param {string=} automationProtocol `devtools`
|
|
161
|
+
* @return {Object} object with environment flags
|
|
162
|
+
*/
|
|
163
|
+
function capabilitiesEnvironmentDetector(capabilities, automationProtocol) {
|
|
164
|
+
return automationProtocol === 'devtools'
|
|
165
|
+
? devtoolsEnvironmentDetector(capabilities)
|
|
166
|
+
: webdriverEnvironmentDetector(capabilities);
|
|
167
|
+
}
|
|
168
|
+
exports.capabilitiesEnvironmentDetector = capabilitiesEnvironmentDetector;
|
|
169
|
+
/**
|
|
170
|
+
* returns information about the environment when the session is created
|
|
171
|
+
* @param {Object} capabilities caps of session response
|
|
172
|
+
* @param {Object} requestedCapabilities
|
|
173
|
+
* @return {Object} object with environment flags
|
|
174
|
+
*/
|
|
175
|
+
function sessionEnvironmentDetector({ capabilities, requestedCapabilities }) {
|
|
176
|
+
return {
|
|
177
|
+
isW3C: isW3C(capabilities),
|
|
178
|
+
isChrome: isChrome(capabilities),
|
|
179
|
+
isFirefox: isFirefox(capabilities),
|
|
180
|
+
isMobile: isMobile(capabilities),
|
|
181
|
+
isIOS: isIOS(capabilities),
|
|
182
|
+
isAndroid: isAndroid(capabilities),
|
|
183
|
+
isSauce: isSauce(requestedCapabilities),
|
|
184
|
+
isSeleniumStandalone: isSeleniumStandalone(capabilities)
|
|
185
|
+
};
|
|
186
|
+
}
|
|
187
|
+
exports.sessionEnvironmentDetector = sessionEnvironmentDetector;
|
|
188
|
+
/**
|
|
189
|
+
* returns information about the environment when `devtools` protocol is used
|
|
190
|
+
* @param {Object} capabilities caps of session response
|
|
191
|
+
* @return {Object} object with environment flags
|
|
192
|
+
*/
|
|
193
|
+
function devtoolsEnvironmentDetector({ browserName }) {
|
|
194
|
+
return {
|
|
195
|
+
isDevTools: true,
|
|
196
|
+
isW3C: true,
|
|
197
|
+
isMobile: false,
|
|
198
|
+
isIOS: false,
|
|
199
|
+
isAndroid: false,
|
|
200
|
+
isFirefox: false,
|
|
201
|
+
isChrome: browserName === 'chrome',
|
|
202
|
+
isSauce: false,
|
|
203
|
+
isSeleniumStandalone: false,
|
|
204
|
+
};
|
|
205
|
+
}
|
|
206
|
+
exports.devtoolsEnvironmentDetector = devtoolsEnvironmentDetector;
|
|
207
|
+
/**
|
|
208
|
+
* returns information about the environment before the session is created
|
|
209
|
+
* `isW3C`, `isSeleniumStandalone` cannot be detected
|
|
210
|
+
* @param {Object} capabilities caps provided by user
|
|
211
|
+
* @return {Object} object with environment flags
|
|
212
|
+
*/
|
|
213
|
+
function webdriverEnvironmentDetector(capabilities) {
|
|
214
|
+
return {
|
|
215
|
+
isChrome: isChrome(capabilities),
|
|
216
|
+
isFirefox: isFirefox(capabilities),
|
|
217
|
+
isMobile: isMobile(capabilities),
|
|
218
|
+
isIOS: isIOS(capabilities),
|
|
219
|
+
isAndroid: isAndroid(capabilities),
|
|
220
|
+
isSauce: isSauce(capabilities)
|
|
221
|
+
};
|
|
222
|
+
}
|
|
223
|
+
exports.webdriverEnvironmentDetector = webdriverEnvironmentDetector;
|
package/build/index.d.ts
ADDED
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import initialisePlugin from './initialisePlugin';
|
|
2
|
+
import { initialiseWorkerService, initialiseLauncherService } from './initialiseServices';
|
|
3
|
+
import webdriverMonad from './monad';
|
|
4
|
+
import { commandCallStructure, isValidParameter, getArgumentType, safeRequire, isFunctionAsync, transformCommandLogResult, canAccess, sleep } from './utils';
|
|
5
|
+
import { wrapCommand, runFnInFiberContext, executeHooksWithArgs, hasWdioSyncSupport, executeSync, executeAsync } from './shim';
|
|
6
|
+
import { testFnWrapper, runTestInFiberContext } from './test-framework';
|
|
7
|
+
import { isW3C, capabilitiesEnvironmentDetector, sessionEnvironmentDetector, devtoolsEnvironmentDetector } from './envDetector';
|
|
8
|
+
import { UNICODE_CHARACTERS } from './constants';
|
|
9
|
+
export { initialisePlugin, initialiseLauncherService, initialiseWorkerService, isFunctionAsync, transformCommandLogResult, webdriverMonad, commandCallStructure, isValidParameter, getArgumentType, safeRequire, canAccess, sleep,
|
|
10
|
+
/**
|
|
11
|
+
* wdio-sync shim
|
|
12
|
+
*/
|
|
13
|
+
wrapCommand, executeSync, executeAsync, runFnInFiberContext, runTestInFiberContext, testFnWrapper, executeHooksWithArgs, hasWdioSyncSupport,
|
|
14
|
+
/**
|
|
15
|
+
* environmentDetector
|
|
16
|
+
*/
|
|
17
|
+
isW3C, sessionEnvironmentDetector, capabilitiesEnvironmentDetector, devtoolsEnvironmentDetector,
|
|
18
|
+
/**
|
|
19
|
+
* constants
|
|
20
|
+
*/
|
|
21
|
+
UNICODE_CHARACTERS };
|
|
22
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAEA,OAAO,gBAAgB,MAAM,oBAAoB,CAAA;AACjD,OAAO,EAAE,uBAAuB,EAAE,yBAAyB,EAAE,MAAM,sBAAsB,CAAA;AACzF,OAAO,cAAc,MAAM,SAAS,CAAA;AACpC,OAAO,EACH,oBAAoB,EAAE,gBAAgB,EAAE,eAAe,EAAE,WAAW,EACpE,eAAe,EAAE,yBAAyB,EAAE,SAAS,EAAE,KAAK,EAC/D,MAAM,SAAS,CAAA;AAChB,OAAO,EACH,WAAW,EAAE,mBAAmB,EAAE,oBAAoB,EACtD,kBAAkB,EAAE,WAAW,EAAE,YAAY,EAChD,MAAM,QAAQ,CAAA;AACf,OAAO,EAAE,aAAa,EAAE,qBAAqB,EAAE,MAAM,kBAAkB,CAAA;AACvE,OAAO,EACH,KAAK,EAAE,+BAA+B,EACtC,0BAA0B,EAAE,2BAA2B,EAC1D,MAAM,eAAe,CAAA;AACtB,OAAO,EAAE,kBAAkB,EAAE,MAAM,aAAa,CAAA;AAEhD,OAAO,EACH,gBAAgB,EAChB,yBAAyB,EACzB,uBAAuB,EACvB,eAAe,EACf,yBAAyB,EACzB,cAAc,EACd,oBAAoB,EACpB,gBAAgB,EAChB,eAAe,EACf,WAAW,EACX,SAAS,EACT,KAAK;AAEL;;GAEG;AACH,WAAW,EACX,WAAW,EACX,YAAY,EACZ,mBAAmB,EACnB,qBAAqB,EACrB,aAAa,EACb,oBAAoB,EACpB,kBAAkB;AAElB;;GAEG;AACH,KAAK,EACL,0BAA0B,EAC1B,+BAA+B,EAC/B,2BAA2B;AAE3B;;GAEG;AACH,kBAAkB,EACrB,CAAA"}
|
package/build/index.js
ADDED
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/* istanbul ignore file */
|
|
3
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
4
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
5
|
+
};
|
|
6
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
7
|
+
exports.UNICODE_CHARACTERS = exports.devtoolsEnvironmentDetector = exports.capabilitiesEnvironmentDetector = exports.sessionEnvironmentDetector = exports.isW3C = exports.hasWdioSyncSupport = exports.executeHooksWithArgs = exports.testFnWrapper = exports.runTestInFiberContext = exports.runFnInFiberContext = exports.executeAsync = exports.executeSync = exports.wrapCommand = exports.sleep = exports.canAccess = exports.safeRequire = exports.getArgumentType = exports.isValidParameter = exports.commandCallStructure = exports.webdriverMonad = exports.transformCommandLogResult = exports.isFunctionAsync = exports.initialiseWorkerService = exports.initialiseLauncherService = exports.initialisePlugin = void 0;
|
|
8
|
+
const initialisePlugin_1 = __importDefault(require("./initialisePlugin"));
|
|
9
|
+
exports.initialisePlugin = initialisePlugin_1.default;
|
|
10
|
+
const initialiseServices_1 = require("./initialiseServices");
|
|
11
|
+
Object.defineProperty(exports, "initialiseWorkerService", { enumerable: true, get: function () { return initialiseServices_1.initialiseWorkerService; } });
|
|
12
|
+
Object.defineProperty(exports, "initialiseLauncherService", { enumerable: true, get: function () { return initialiseServices_1.initialiseLauncherService; } });
|
|
13
|
+
const monad_1 = __importDefault(require("./monad"));
|
|
14
|
+
exports.webdriverMonad = monad_1.default;
|
|
15
|
+
const utils_1 = require("./utils");
|
|
16
|
+
Object.defineProperty(exports, "commandCallStructure", { enumerable: true, get: function () { return utils_1.commandCallStructure; } });
|
|
17
|
+
Object.defineProperty(exports, "isValidParameter", { enumerable: true, get: function () { return utils_1.isValidParameter; } });
|
|
18
|
+
Object.defineProperty(exports, "getArgumentType", { enumerable: true, get: function () { return utils_1.getArgumentType; } });
|
|
19
|
+
Object.defineProperty(exports, "safeRequire", { enumerable: true, get: function () { return utils_1.safeRequire; } });
|
|
20
|
+
Object.defineProperty(exports, "isFunctionAsync", { enumerable: true, get: function () { return utils_1.isFunctionAsync; } });
|
|
21
|
+
Object.defineProperty(exports, "transformCommandLogResult", { enumerable: true, get: function () { return utils_1.transformCommandLogResult; } });
|
|
22
|
+
Object.defineProperty(exports, "canAccess", { enumerable: true, get: function () { return utils_1.canAccess; } });
|
|
23
|
+
Object.defineProperty(exports, "sleep", { enumerable: true, get: function () { return utils_1.sleep; } });
|
|
24
|
+
const shim_1 = require("./shim");
|
|
25
|
+
Object.defineProperty(exports, "wrapCommand", { enumerable: true, get: function () { return shim_1.wrapCommand; } });
|
|
26
|
+
Object.defineProperty(exports, "runFnInFiberContext", { enumerable: true, get: function () { return shim_1.runFnInFiberContext; } });
|
|
27
|
+
Object.defineProperty(exports, "executeHooksWithArgs", { enumerable: true, get: function () { return shim_1.executeHooksWithArgs; } });
|
|
28
|
+
Object.defineProperty(exports, "hasWdioSyncSupport", { enumerable: true, get: function () { return shim_1.hasWdioSyncSupport; } });
|
|
29
|
+
Object.defineProperty(exports, "executeSync", { enumerable: true, get: function () { return shim_1.executeSync; } });
|
|
30
|
+
Object.defineProperty(exports, "executeAsync", { enumerable: true, get: function () { return shim_1.executeAsync; } });
|
|
31
|
+
const test_framework_1 = require("./test-framework");
|
|
32
|
+
Object.defineProperty(exports, "testFnWrapper", { enumerable: true, get: function () { return test_framework_1.testFnWrapper; } });
|
|
33
|
+
Object.defineProperty(exports, "runTestInFiberContext", { enumerable: true, get: function () { return test_framework_1.runTestInFiberContext; } });
|
|
34
|
+
const envDetector_1 = require("./envDetector");
|
|
35
|
+
Object.defineProperty(exports, "isW3C", { enumerable: true, get: function () { return envDetector_1.isW3C; } });
|
|
36
|
+
Object.defineProperty(exports, "capabilitiesEnvironmentDetector", { enumerable: true, get: function () { return envDetector_1.capabilitiesEnvironmentDetector; } });
|
|
37
|
+
Object.defineProperty(exports, "sessionEnvironmentDetector", { enumerable: true, get: function () { return envDetector_1.sessionEnvironmentDetector; } });
|
|
38
|
+
Object.defineProperty(exports, "devtoolsEnvironmentDetector", { enumerable: true, get: function () { return envDetector_1.devtoolsEnvironmentDetector; } });
|
|
39
|
+
const constants_1 = require("./constants");
|
|
40
|
+
Object.defineProperty(exports, "UNICODE_CHARACTERS", { enumerable: true, get: function () { return constants_1.UNICODE_CHARACTERS; } });
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { Services } from '@wdio/types';
|
|
2
|
+
/**
|
|
3
|
+
* initialise WebdriverIO compliant plugins like reporter or services in the following way:
|
|
4
|
+
* 1. if package name is scoped (starts with "@"), require scoped package name
|
|
5
|
+
* 2. otherwise try to require "@wdio/<name>-<type>"
|
|
6
|
+
* 3. otherwise try to require "wdio-<name>-<type>"
|
|
7
|
+
*/
|
|
8
|
+
export default function initialisePlugin(name: string, type?: string): Services.ServicePlugin | Services.RunnerPlugin;
|
|
9
|
+
//# sourceMappingURL=initialisePlugin.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"initialisePlugin.d.ts","sourceRoot":"","sources":["../src/initialisePlugin.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAA;AAItC;;;;;GAKG;AACH,MAAM,CAAC,OAAO,UAAU,gBAAgB,CAAE,IAAI,EAAE,MAAM,EAAE,IAAI,CAAC,EAAE,MAAM,GAAG,QAAQ,CAAC,aAAa,GAAG,QAAQ,CAAC,YAAY,CAqCrH"}
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
const path_1 = __importDefault(require("path"));
|
|
7
|
+
const utils_1 = require("./utils");
|
|
8
|
+
/**
|
|
9
|
+
* initialise WebdriverIO compliant plugins like reporter or services in the following way:
|
|
10
|
+
* 1. if package name is scoped (starts with "@"), require scoped package name
|
|
11
|
+
* 2. otherwise try to require "@wdio/<name>-<type>"
|
|
12
|
+
* 3. otherwise try to require "wdio-<name>-<type>"
|
|
13
|
+
*/
|
|
14
|
+
function initialisePlugin(name, type) {
|
|
15
|
+
/**
|
|
16
|
+
* directly import packages that are scoped or start with an absolute path
|
|
17
|
+
*/
|
|
18
|
+
if (name[0] === '@' || path_1.default.isAbsolute(name)) {
|
|
19
|
+
const service = (0, utils_1.safeRequire)(name);
|
|
20
|
+
if (service) {
|
|
21
|
+
return service;
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
if (typeof type !== 'string') {
|
|
25
|
+
throw new Error('No plugin type provided');
|
|
26
|
+
}
|
|
27
|
+
/**
|
|
28
|
+
* check for scoped version of plugin first (e.g. @wdio/sauce-service)
|
|
29
|
+
*/
|
|
30
|
+
const scopedPlugin = (0, utils_1.safeRequire)(`@wdio/${name.toLowerCase()}-${type}`);
|
|
31
|
+
if (scopedPlugin) {
|
|
32
|
+
return scopedPlugin;
|
|
33
|
+
}
|
|
34
|
+
/**
|
|
35
|
+
* check for old type of
|
|
36
|
+
*/
|
|
37
|
+
const plugin = (0, utils_1.safeRequire)(`wdio-${name.toLowerCase()}-${type}`);
|
|
38
|
+
if (plugin) {
|
|
39
|
+
return plugin;
|
|
40
|
+
}
|
|
41
|
+
throw new Error(`Couldn't find plugin "${name}" ${type}, neither as wdio scoped package ` +
|
|
42
|
+
`"@wdio/${name.toLowerCase()}-${type}" nor as community package ` +
|
|
43
|
+
`"wdio-${name.toLowerCase()}-${type}". Please make sure you have it installed!`);
|
|
44
|
+
}
|
|
45
|
+
exports.default = initialisePlugin;
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import type { Capabilities, Services, Options } from '@wdio/types';
|
|
2
|
+
/**
|
|
3
|
+
* initialise service for launcher process
|
|
4
|
+
* @param {Object} config wdio config
|
|
5
|
+
* @param {Object[]} caps list of capabilities
|
|
6
|
+
* @return {Object} containing a list of launcher services as well
|
|
7
|
+
* as a list of services that don't need to be
|
|
8
|
+
* required in the worker
|
|
9
|
+
*/
|
|
10
|
+
export declare function initialiseLauncherService(config: Omit<Options.Testrunner, 'capabilities' | keyof Services.HookFunctions>, caps: Capabilities.DesiredCapabilities): {
|
|
11
|
+
ignoredWorkerServices: string[];
|
|
12
|
+
launcherServices: Services.ServiceInstance[];
|
|
13
|
+
};
|
|
14
|
+
/**
|
|
15
|
+
* initialise services for worker instance
|
|
16
|
+
* @param {Object} config wdio config
|
|
17
|
+
* @param {Object} caps worker capabilities
|
|
18
|
+
* @param {[type]} ignoredWorkerServices list of services that don't need to be required in a worker
|
|
19
|
+
* as they don't export a service for it
|
|
20
|
+
* @return {Object[]} list if worker initiated worker services
|
|
21
|
+
*/
|
|
22
|
+
export declare function initialiseWorkerService(config: Options.Testrunner, caps: Capabilities.DesiredCapabilities, ignoredWorkerServices?: string[]): Services.ServiceInstance[];
|
|
23
|
+
//# sourceMappingURL=initialiseServices.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"initialiseServices.d.ts","sourceRoot":"","sources":["../src/initialiseServices.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,QAAQ,EAAE,OAAO,EAAE,MAAM,aAAa,CAAA;AAqFlE;;;;;;;GAOG;AACH,wBAAgB,yBAAyB,CAAE,MAAM,EAAE,IAAI,CAAC,OAAO,CAAC,UAAU,EAAE,cAAc,GAAG,MAAM,QAAQ,CAAC,aAAa,CAAC,EAAE,IAAI,EAAE,YAAY,CAAC,mBAAmB;;;EAiDjK;AAED;;;;;;;GAOG;AACH,wBAAgB,uBAAuB,CACnC,MAAM,EAAE,OAAO,CAAC,UAAU,EAC1B,IAAI,EAAE,YAAY,CAAC,mBAAmB,EACtC,qBAAqB,GAAE,MAAM,EAAO,GACrC,QAAQ,CAAC,eAAe,EAAE,CA6B5B"}
|