webdriverio 7.21.0 → 8.0.0-alpha.239
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/cjs/index.d.ts +3 -0
- package/build/cjs/index.d.ts.map +1 -0
- package/build/cjs/index.js +13 -0
- package/build/cjs/package.json +3 -0
- package/build/commands/browser/$$.js +6 -9
- package/build/commands/browser/$.js +8 -11
- package/build/commands/browser/action.d.ts +128 -0
- package/build/commands/browser/action.d.ts.map +1 -0
- package/build/commands/browser/action.js +13 -0
- package/build/commands/browser/actions.d.ts +29 -0
- package/build/commands/browser/actions.d.ts.map +1 -0
- package/build/commands/browser/actions.js +30 -0
- package/build/commands/browser/call.js +1 -4
- package/build/commands/browser/custom$$.js +7 -10
- package/build/commands/browser/custom$.js +5 -8
- package/build/commands/browser/debug.js +8 -14
- package/build/commands/browser/deleteCookies.js +1 -4
- package/build/commands/browser/execute.js +3 -6
- package/build/commands/browser/executeAsync.js +3 -6
- package/build/commands/browser/getCookies.js +1 -4
- package/build/commands/browser/getPuppeteer.d.ts +1 -1
- package/build/commands/browser/getPuppeteer.d.ts.map +1 -1
- package/build/commands/browser/getPuppeteer.js +14 -21
- package/build/commands/browser/getWindowSize.js +3 -6
- package/build/commands/browser/keys.d.ts +20 -10
- package/build/commands/browser/keys.d.ts.map +1 -1
- package/build/commands/browser/keys.js +29 -24
- package/build/commands/browser/mock.d.ts +1 -1
- package/build/commands/browser/mock.d.ts.map +1 -1
- package/build/commands/browser/mock.js +12 -19
- package/build/commands/browser/mockClearAll.js +5 -11
- package/build/commands/browser/mockRestoreAll.js +5 -11
- package/build/commands/browser/newWindow.js +5 -11
- package/build/commands/browser/pause.js +1 -4
- package/build/commands/browser/react$$.d.ts.map +1 -1
- package/build/commands/browser/react$$.js +12 -16
- package/build/commands/browser/react$.d.ts.map +1 -1
- package/build/commands/browser/react$.js +10 -14
- package/build/commands/browser/reloadSession.js +5 -12
- package/build/commands/browser/savePDF.js +7 -13
- package/build/commands/browser/saveRecordingScreen.js +6 -12
- package/build/commands/browser/saveScreenshot.js +6 -12
- package/build/commands/browser/scroll.d.ts +25 -0
- package/build/commands/browser/scroll.d.ts.map +1 -0
- package/build/commands/browser/scroll.js +41 -0
- package/build/commands/browser/setCookies.js +1 -4
- package/build/commands/browser/setTimeout.js +1 -4
- package/build/commands/browser/setWindowSize.js +3 -6
- package/build/commands/browser/switchWindow.js +1 -4
- package/build/commands/browser/throttle.js +3 -6
- package/build/commands/browser/touchAction.d.ts +1 -1
- package/build/commands/browser/touchAction.d.ts.map +1 -1
- package/build/commands/browser/touchAction.js +3 -6
- package/build/commands/browser/uploadFile.d.ts +1 -1
- package/build/commands/browser/uploadFile.d.ts.map +1 -1
- package/build/commands/browser/uploadFile.js +10 -15
- package/build/commands/browser/url.js +3 -6
- package/build/commands/browser/waitUntil.js +3 -9
- package/build/commands/browser.d.ts +39 -33
- package/build/commands/browser.d.ts.map +1 -1
- package/build/commands/browser.js +42 -43
- package/build/commands/constant.d.ts +1 -1
- package/build/commands/constant.d.ts.map +1 -1
- package/build/commands/constant.js +6 -12
- package/build/commands/element/$$.d.ts +1 -1
- package/build/commands/element/$$.d.ts.map +1 -1
- package/build/commands/element/$$.js +2 -7
- package/build/commands/element/$.d.ts +1 -1
- package/build/commands/element/$.d.ts.map +1 -1
- package/build/commands/element/$.js +2 -7
- package/build/commands/element/addValue.d.ts +10 -14
- package/build/commands/element/addValue.d.ts.map +1 -1
- package/build/commands/element/addValue.js +23 -27
- package/build/commands/element/clearValue.d.ts +1 -1
- package/build/commands/element/clearValue.js +2 -5
- package/build/commands/element/click.d.ts +1 -1
- package/build/commands/element/click.d.ts.map +1 -1
- package/build/commands/element/click.js +19 -34
- package/build/commands/element/custom$$.js +9 -11
- package/build/commands/element/custom$.js +8 -10
- package/build/commands/element/doubleClick.d.ts.map +1 -1
- package/build/commands/element/doubleClick.js +11 -17
- package/build/commands/element/dragAndDrop.d.ts.map +1 -1
- package/build/commands/element/dragAndDrop.js +13 -19
- package/build/commands/element/getAttribute.js +1 -4
- package/build/commands/element/getCSSProperty.d.ts +1 -1
- package/build/commands/element/getCSSProperty.d.ts.map +1 -1
- package/build/commands/element/getCSSProperty.js +7 -13
- package/build/commands/element/getComputedLabel.js +1 -4
- package/build/commands/element/getComputedRole.js +1 -4
- package/build/commands/element/getHTML.js +7 -13
- package/build/commands/element/getLocation.js +3 -5
- package/build/commands/element/getProperty.d.ts +8 -8
- package/build/commands/element/getProperty.d.ts.map +1 -1
- package/build/commands/element/getProperty.js +5 -11
- package/build/commands/element/getSize.js +3 -5
- package/build/commands/element/getTagName.js +1 -4
- package/build/commands/element/getText.js +1 -4
- package/build/commands/element/getValue.js +1 -4
- package/build/commands/element/isClickable.js +7 -13
- package/build/commands/element/isDisplayed.js +9 -16
- package/build/commands/element/isDisplayedInViewport.js +7 -13
- package/build/commands/element/isEnabled.js +1 -4
- package/build/commands/element/isEqual.d.ts.map +1 -1
- package/build/commands/element/isEqual.js +9 -9
- package/build/commands/element/isExisting.js +1 -4
- package/build/commands/element/isFocused.js +7 -13
- package/build/commands/element/isSelected.js +1 -4
- package/build/commands/element/moveTo.d.ts.map +1 -1
- package/build/commands/element/moveTo.js +8 -13
- package/build/commands/element/nextElement.js +2 -5
- package/build/commands/element/parentElement.js +2 -5
- package/build/commands/element/previousElement.js +2 -5
- package/build/commands/element/react$$.d.ts.map +1 -1
- package/build/commands/element/react$$.js +13 -16
- package/build/commands/element/react$.d.ts.map +1 -1
- package/build/commands/element/react$.js +12 -14
- package/build/commands/element/saveScreenshot.js +6 -12
- package/build/commands/element/scrollIntoView.d.ts +3 -2
- package/build/commands/element/scrollIntoView.d.ts.map +1 -1
- package/build/commands/element/scrollIntoView.js +32 -12
- package/build/commands/element/selectByAttribute.js +3 -6
- package/build/commands/element/selectByIndex.js +3 -6
- package/build/commands/element/selectByVisibleText.js +3 -6
- package/build/commands/element/setValue.d.ts +13 -14
- package/build/commands/element/setValue.d.ts.map +1 -1
- package/build/commands/element/setValue.js +14 -17
- package/build/commands/element/shadow$$.d.ts +1 -1
- package/build/commands/element/shadow$$.d.ts.map +1 -1
- package/build/commands/element/shadow$$.js +3 -6
- package/build/commands/element/shadow$.js +3 -6
- package/build/commands/element/touchAction.js +3 -6
- package/build/commands/element/waitForClickable.js +1 -4
- package/build/commands/element/waitForDisplayed.js +1 -4
- package/build/commands/element/waitForEnabled.js +1 -4
- package/build/commands/element/waitForExist.js +1 -4
- package/build/commands/element/waitUntil.d.ts +1 -1
- package/build/commands/element/waitUntil.d.ts.map +1 -1
- package/build/commands/element/waitUntil.js +2 -7
- package/build/commands/element.d.ts +48 -48
- package/build/commands/element.d.ts.map +1 -1
- package/build/commands/element.js +57 -62
- package/build/constants.d.ts +66 -0
- package/build/constants.d.ts.map +1 -1
- package/build/constants.js +91 -12
- package/build/index.d.ts +64 -5
- package/build/index.d.ts.map +1 -1
- package/build/index.js +47 -85
- package/build/middlewares.d.ts +1 -1
- package/build/middlewares.js +11 -19
- package/build/multiremote.js +12 -20
- package/build/protocol-stub.d.ts.map +1 -1
- package/build/protocol-stub.js +4 -6
- package/build/scripts/getHTML.js +1 -4
- package/build/scripts/getProperty.d.ts +8 -8
- package/build/scripts/getProperty.d.ts.map +1 -1
- package/build/scripts/getProperty.js +1 -4
- package/build/scripts/isElementClickable.js +1 -4
- package/build/scripts/isElementDisplayed.js +1 -4
- package/build/scripts/isElementInViewport.js +1 -4
- package/build/scripts/isFocused.js +1 -4
- package/build/scripts/newWindow.js +1 -4
- package/build/scripts/resq.js +3 -9
- package/build/scripts/shadowFnFactory.js +2 -6
- package/build/types.d.ts +1 -5
- package/build/types.d.ts.map +1 -1
- package/build/types.js +1 -2
- package/build/utils/SevereServiceError.js +1 -4
- package/build/utils/Timer.d.ts.map +1 -1
- package/build/utils/Timer.js +1 -25
- package/build/utils/actions/base.d.ts +32 -0
- package/build/utils/actions/base.d.ts.map +1 -0
- package/build/utils/actions/base.js +78 -0
- package/build/utils/actions/index.d.ts +6 -0
- package/build/utils/actions/index.d.ts.map +1 -0
- package/build/utils/actions/index.js +5 -0
- package/build/utils/actions/key.d.ts +15 -0
- package/build/utils/actions/key.d.ts.map +1 -0
- package/build/utils/actions/key.js +22 -0
- package/build/utils/actions/pointer.d.ts +62 -0
- package/build/utils/actions/pointer.d.ts.map +1 -0
- package/build/utils/actions/pointer.js +76 -0
- package/build/utils/actions/wheel.d.ts +36 -0
- package/build/utils/actions/wheel.d.ts.map +1 -0
- package/build/utils/actions/wheel.js +20 -0
- package/build/utils/detectBackend.d.ts +1 -1
- package/build/utils/detectBackend.d.ts.map +1 -1
- package/build/utils/detectBackend.js +3 -7
- package/build/utils/findStrategy.js +11 -19
- package/build/utils/getElementObject.d.ts.map +1 -1
- package/build/utils/getElementObject.js +42 -31
- package/build/utils/implicitWait.js +3 -9
- package/build/utils/index.d.ts +2 -6
- package/build/utils/index.d.ts.map +1 -1
- package/build/utils/index.js +92 -142
- package/build/utils/interception/devtools.d.ts +1 -1
- package/build/utils/interception/devtools.d.ts.map +1 -1
- package/build/utils/interception/devtools.js +17 -23
- package/build/utils/interception/index.d.ts +2 -2
- package/build/utils/interception/index.d.ts.map +1 -1
- package/build/utils/interception/index.js +5 -11
- package/build/utils/interception/types.d.ts +1 -1
- package/build/utils/interception/types.d.ts.map +1 -1
- package/build/utils/interception/types.js +1 -2
- package/build/utils/interception/webdriver.d.ts +1 -1
- package/build/utils/interception/webdriver.d.ts.map +1 -1
- package/build/utils/interception/webdriver.js +5 -11
- package/build/utils/refetchElement.js +3 -9
- package/package.json +22 -11
- package/async.d.ts +0 -24
- package/sync.d.ts +0 -24
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import logger from '@wdio/logger';
|
|
2
|
+
const log = logger('webdriverio');
|
|
3
|
+
/**
|
|
4
|
+
*
|
|
5
|
+
* Scroll within the browser viewport. Note that `x` and `y` coordinates are relative to the current
|
|
6
|
+
* scroll positon, therefore `browser.scroll(0, 0)` is a non operation.
|
|
7
|
+
*
|
|
8
|
+
* <example>
|
|
9
|
+
:scroll.js
|
|
10
|
+
it('should demonstrate the scroll command', async () => {
|
|
11
|
+
await browser.url('https://webdriver.io')
|
|
12
|
+
|
|
13
|
+
console.log(await browser.execute(() => window.scrollY)) // returns 0
|
|
14
|
+
await browser.scroll(0, 200)
|
|
15
|
+
console.log(await browser.execute(() => window.scrollY)) // returns 200
|
|
16
|
+
});
|
|
17
|
+
* </example>
|
|
18
|
+
*
|
|
19
|
+
* @alias element.scroll
|
|
20
|
+
* @param {number=} x horizontal scroll position (default: `0`)
|
|
21
|
+
* @param {number=} y vertical scroll position (default: `0`)
|
|
22
|
+
* @uses protocol/execute
|
|
23
|
+
* @type utility
|
|
24
|
+
*
|
|
25
|
+
*/
|
|
26
|
+
export default function scroll(x = 0, y = 0) {
|
|
27
|
+
if (!x && !y) {
|
|
28
|
+
return log.warn('"scroll" command was called with no parameters, skipping execution');
|
|
29
|
+
}
|
|
30
|
+
return this.action('wheel')
|
|
31
|
+
.scroll({
|
|
32
|
+
deltaX: x,
|
|
33
|
+
deltaY: y,
|
|
34
|
+
/**
|
|
35
|
+
* needed otherwise the command finished before
|
|
36
|
+
* scrolling position is reached
|
|
37
|
+
*/
|
|
38
|
+
duration: 200
|
|
39
|
+
})
|
|
40
|
+
.perform();
|
|
41
|
+
}
|
|
@@ -1,5 +1,3 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
1
|
/**
|
|
4
2
|
*
|
|
5
3
|
* Sets one or more [cookies](https://w3c.github.io/webdriver/#cookies) for the current page. Make sure you are
|
|
@@ -54,7 +52,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
54
52
|
* @type cookie
|
|
55
53
|
*
|
|
56
54
|
*/
|
|
57
|
-
async function setCookies(cookieObjs) {
|
|
55
|
+
export default async function setCookies(cookieObjs) {
|
|
58
56
|
const cookieObjsList = !Array.isArray(cookieObjs) ? [cookieObjs] : cookieObjs;
|
|
59
57
|
if (cookieObjsList.some(obj => (typeof obj !== 'object'))) {
|
|
60
58
|
throw new Error('Invalid input (see https://webdriver.io/docs/api/browser/setCookies for documentation)');
|
|
@@ -63,4 +61,3 @@ async function setCookies(cookieObjs) {
|
|
|
63
61
|
.map(cookieObj => this.addCookie(cookieObj)));
|
|
64
62
|
return;
|
|
65
63
|
}
|
|
66
|
-
exports.default = setCookies;
|
|
@@ -1,5 +1,3 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
1
|
/**
|
|
4
2
|
*
|
|
5
3
|
* Sets the timeouts associated with the current session, timeout durations control such
|
|
@@ -35,7 +33,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
35
33
|
* @see https://w3c.github.io/webdriver/#set-timeouts
|
|
36
34
|
*
|
|
37
35
|
*/
|
|
38
|
-
async function setTimeout(timeouts) {
|
|
36
|
+
export default async function setTimeout(timeouts) {
|
|
39
37
|
if (typeof timeouts !== 'object') {
|
|
40
38
|
throw new Error('Parameter for "setTimeout" command needs to be an object');
|
|
41
39
|
}
|
|
@@ -65,4 +63,3 @@ async function setTimeout(timeouts) {
|
|
|
65
63
|
}
|
|
66
64
|
return setTimeouts(implicit, pageLoad, script);
|
|
67
65
|
}
|
|
68
|
-
exports.default = setTimeout;
|
|
@@ -1,6 +1,4 @@
|
|
|
1
|
-
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
const utils_1 = require("../../utils");
|
|
1
|
+
import { getBrowserObject } from '../../utils/index.js';
|
|
4
2
|
const minWindowSize = 0;
|
|
5
3
|
const maxWindowSize = Number.MAX_SAFE_INTEGER;
|
|
6
4
|
/**
|
|
@@ -21,7 +19,7 @@ const maxWindowSize = Number.MAX_SAFE_INTEGER;
|
|
|
21
19
|
* @type window
|
|
22
20
|
*
|
|
23
21
|
*/
|
|
24
|
-
async function setWindowSize(width, height) {
|
|
22
|
+
export default async function setWindowSize(width, height) {
|
|
25
23
|
/**
|
|
26
24
|
* type check
|
|
27
25
|
*/
|
|
@@ -34,10 +32,9 @@ async function setWindowSize(width, height) {
|
|
|
34
32
|
if (width < minWindowSize || width > maxWindowSize || height < minWindowSize || height > maxWindowSize) {
|
|
35
33
|
throw new Error('setWindowSize expects width and height to be a number in the 0 to 2^31 − 1 range');
|
|
36
34
|
}
|
|
37
|
-
const browser =
|
|
35
|
+
const browser = getBrowserObject(this);
|
|
38
36
|
if (!browser.isW3C) {
|
|
39
37
|
return browser._setWindowSize(width, height);
|
|
40
38
|
}
|
|
41
39
|
await browser.setWindowRect(null, null, width, height);
|
|
42
40
|
}
|
|
43
|
-
exports.default = setWindowSize;
|
|
@@ -1,5 +1,3 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
1
|
/**
|
|
4
2
|
*
|
|
5
3
|
* Switch focus to a particular tab / window.
|
|
@@ -28,7 +26,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
28
26
|
* @type window
|
|
29
27
|
*
|
|
30
28
|
*/
|
|
31
|
-
async function switchWindow(matcher) {
|
|
29
|
+
export default async function switchWindow(matcher) {
|
|
32
30
|
/**
|
|
33
31
|
* parameter check
|
|
34
32
|
*/
|
|
@@ -70,4 +68,3 @@ async function switchWindow(matcher) {
|
|
|
70
68
|
}
|
|
71
69
|
throw new Error(`No window found with title, url or name matching "${matcher}"`);
|
|
72
70
|
}
|
|
73
|
-
exports.default = switchWindow;
|
|
@@ -1,5 +1,3 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
1
|
/**
|
|
4
2
|
* Throttle the network capabilities of the browser. This can help to
|
|
5
3
|
* emulate certain scenarios where a user loses their internet connection
|
|
@@ -44,7 +42,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
44
42
|
* @type utility
|
|
45
43
|
*
|
|
46
44
|
*/
|
|
47
|
-
|
|
45
|
+
import { getBrowserObject } from '../../utils/index.js';
|
|
48
46
|
const NETWORK_PRESETS = {
|
|
49
47
|
'offline': {
|
|
50
48
|
offline: true,
|
|
@@ -108,7 +106,7 @@ const NETWORK_PRESETS = {
|
|
|
108
106
|
}
|
|
109
107
|
};
|
|
110
108
|
const NETWORK_PRESET_TYPES = Object.keys(NETWORK_PRESETS);
|
|
111
|
-
async function throttle(params) {
|
|
109
|
+
export default async function throttle(params) {
|
|
112
110
|
if (
|
|
113
111
|
/**
|
|
114
112
|
* check string parameter
|
|
@@ -124,7 +122,7 @@ async function throttle(params) {
|
|
|
124
122
|
* use WebDriver extension if connected with cloud service
|
|
125
123
|
*/
|
|
126
124
|
if (this.isSauce) {
|
|
127
|
-
const browser =
|
|
125
|
+
const browser = getBrowserObject(this);
|
|
128
126
|
await browser.throttleNetwork(params);
|
|
129
127
|
return null;
|
|
130
128
|
}
|
|
@@ -141,4 +139,3 @@ async function throttle(params) {
|
|
|
141
139
|
: params);
|
|
142
140
|
return null;
|
|
143
141
|
}
|
|
144
|
-
exports.default = throttle;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"touchAction.d.ts","sourceRoot":"","sources":["../../../src/commands/browser/touchAction.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,YAAY,EAAE,MAAM,aAAa,CAAA;
|
|
1
|
+
{"version":3,"file":"touchAction.d.ts","sourceRoot":"","sources":["../../../src/commands/browser/touchAction.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,aAAa,CAAA;AAE/C;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAyDG;AACH,MAAM,CAAC,OAAO,UAAU,WAAW,CAC/B,IAAI,EAAE,WAAW,CAAC,OAAO,EACzB,OAAO,EAAE,YAAY,iBAGxB"}
|
|
@@ -1,6 +1,4 @@
|
|
|
1
|
-
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
const constant_1 = require("../constant");
|
|
1
|
+
import { touchAction as touchActionCommand } from '../constant.js';
|
|
4
2
|
/**
|
|
5
3
|
*
|
|
6
4
|
* The Touch Action API provides the basis of all gestures that can be automated in Appium.
|
|
@@ -59,7 +57,6 @@ const constant_1 = require("../constant");
|
|
|
59
57
|
* @for android, ios
|
|
60
58
|
*
|
|
61
59
|
*/
|
|
62
|
-
function touchAction(actions) {
|
|
63
|
-
return
|
|
60
|
+
export default function touchAction(actions) {
|
|
61
|
+
return touchActionCommand.call(this, actions);
|
|
64
62
|
}
|
|
65
|
-
exports.default = touchAction;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"uploadFile.d.ts","sourceRoot":"","sources":["../../../src/commands/browser/uploadFile.ts"],"names":[],"mappings":"AAKA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA6BG;AACH,wBAA8B,UAAU,CACpC,IAAI,EAAE,WAAW,CAAC,OAAO,EACzB,SAAS,EAAE,MAAM,GAClB,OAAO,CAAC,MAAM,CAAC,
|
|
1
|
+
{"version":3,"file":"uploadFile.d.ts","sourceRoot":"","sources":["../../../src/commands/browser/uploadFile.ts"],"names":[],"mappings":"AAKA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA6BG;AACH,wBAA8B,UAAU,CACpC,IAAI,EAAE,WAAW,CAAC,OAAO,EACzB,SAAS,EAAE,MAAM,GAClB,OAAO,CAAC,MAAM,CAAC,CA6BjB"}
|
|
@@ -1,11 +1,6 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
};
|
|
5
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
const fs_1 = __importDefault(require("fs"));
|
|
7
|
-
const path_1 = __importDefault(require("path"));
|
|
8
|
-
const archiver_1 = __importDefault(require("archiver"));
|
|
1
|
+
import fs from 'node:fs';
|
|
2
|
+
import path from 'node:path';
|
|
3
|
+
import archiver from 'archiver';
|
|
9
4
|
/**
|
|
10
5
|
* Uploads a file to the Selenium Standalone server or other browser driver
|
|
11
6
|
* (e.g. Chromedriver) by using the [`file`](https://webdriver.io/docs/api/selenium#file) command.
|
|
@@ -17,7 +12,7 @@ const archiver_1 = __importDefault(require("archiver"));
|
|
|
17
12
|
*
|
|
18
13
|
* <example>
|
|
19
14
|
:uploadFile.js
|
|
20
|
-
|
|
15
|
+
import path from 'node:path'
|
|
21
16
|
|
|
22
17
|
it('should upload a file', async () => {
|
|
23
18
|
await browser.url('https://the-internet.herokuapp.com/upload')
|
|
@@ -36,7 +31,7 @@ const archiver_1 = __importDefault(require("archiver"));
|
|
|
36
31
|
* @uses protocol/file
|
|
37
32
|
* @return {String} remote URL
|
|
38
33
|
*/
|
|
39
|
-
async function uploadFile(localPath) {
|
|
34
|
+
export default async function uploadFile(localPath) {
|
|
40
35
|
/**
|
|
41
36
|
* parameter check
|
|
42
37
|
*/
|
|
@@ -50,14 +45,14 @@ async function uploadFile(localPath) {
|
|
|
50
45
|
throw new Error(`The uploadFile command is not available in ${this.capabilities.browserName}`);
|
|
51
46
|
}
|
|
52
47
|
let zipData = [];
|
|
53
|
-
let source =
|
|
48
|
+
let source = fs.createReadStream(localPath);
|
|
54
49
|
return new Promise((resolve, reject) => {
|
|
55
|
-
(
|
|
50
|
+
archiver('zip')
|
|
56
51
|
.on('error', (err) => reject(err))
|
|
57
52
|
.on('data', (data) => zipData.push(data))
|
|
58
|
-
.on('end', () => this.file(Buffer.concat(zipData).toString('base64'))
|
|
59
|
-
.
|
|
53
|
+
.on('end', () => (this.file(Buffer.concat(zipData).toString('base64'))
|
|
54
|
+
.then((localPath) => resolve(localPath), reject)))
|
|
55
|
+
.append(source, { name: path.basename(localPath) })
|
|
60
56
|
.finalize();
|
|
61
57
|
});
|
|
62
58
|
}
|
|
63
|
-
exports.default = uploadFile;
|
|
@@ -1,6 +1,4 @@
|
|
|
1
|
-
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
const utils_1 = require("../../utils");
|
|
1
|
+
import { validateUrl } from '../../utils/index.js';
|
|
4
2
|
/**
|
|
5
3
|
*
|
|
6
4
|
* Protocol binding to load the URL of the browser. If a baseUrl is
|
|
@@ -37,13 +35,12 @@ const utils_1 = require("../../utils");
|
|
|
37
35
|
* @type protocol
|
|
38
36
|
*
|
|
39
37
|
*/
|
|
40
|
-
function url(path) {
|
|
38
|
+
export default function url(path) {
|
|
41
39
|
if (typeof path !== 'string') {
|
|
42
40
|
throw new Error('Parameter for "url" command needs to be type of string');
|
|
43
41
|
}
|
|
44
42
|
if (typeof this.options.baseUrl === 'string' && this.options.baseUrl) {
|
|
45
43
|
path = (new URL(path, this.options.baseUrl)).href;
|
|
46
44
|
}
|
|
47
|
-
return this.navigateTo(
|
|
45
|
+
return this.navigateTo(validateUrl(path));
|
|
48
46
|
}
|
|
49
|
-
exports.default = url;
|
|
@@ -1,9 +1,4 @@
|
|
|
1
|
-
|
|
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 Timer_1 = __importDefault(require("../../utils/Timer"));
|
|
1
|
+
import Timer from '../../utils/Timer.js';
|
|
7
2
|
/**
|
|
8
3
|
*
|
|
9
4
|
* This wait command is your universal weapon if you want to wait on something. It expects a condition
|
|
@@ -45,7 +40,7 @@ const Timer_1 = __importDefault(require("../../utils/Timer"));
|
|
|
45
40
|
* @type utility
|
|
46
41
|
*
|
|
47
42
|
*/
|
|
48
|
-
function waitUntil(condition, { timeout = this.options.waitforTimeout, interval = this.options.waitforInterval, timeoutMsg } = {}) {
|
|
43
|
+
export default function waitUntil(condition, { timeout = this.options.waitforTimeout, interval = this.options.waitforInterval, timeoutMsg } = {}) {
|
|
49
44
|
if (typeof condition !== 'function') {
|
|
50
45
|
throw new Error('Condition is not a function');
|
|
51
46
|
}
|
|
@@ -59,7 +54,7 @@ function waitUntil(condition, { timeout = this.options.waitforTimeout, interval
|
|
|
59
54
|
interval = this.options.waitforInterval;
|
|
60
55
|
}
|
|
61
56
|
const fn = condition.bind(this);
|
|
62
|
-
let timer = new
|
|
57
|
+
let timer = new Timer(interval, timeout, fn, true);
|
|
63
58
|
return timer.catch((e) => {
|
|
64
59
|
if (e.message === 'timeout') {
|
|
65
60
|
if (typeof timeoutMsg === 'string') {
|
|
@@ -70,4 +65,3 @@ function waitUntil(condition, { timeout = this.options.waitforTimeout, interval
|
|
|
70
65
|
throw new Error(`waitUntil condition failed with the following reason: ${(e && e.message) || e}`);
|
|
71
66
|
});
|
|
72
67
|
}
|
|
73
|
-
exports.default = waitUntil;
|
|
@@ -1,39 +1,44 @@
|
|
|
1
|
-
import $$ from './browser
|
|
2
|
-
import $ from './browser
|
|
3
|
-
import
|
|
4
|
-
import
|
|
5
|
-
import
|
|
6
|
-
import
|
|
7
|
-
import
|
|
8
|
-
import
|
|
9
|
-
import
|
|
10
|
-
import
|
|
11
|
-
import
|
|
12
|
-
import
|
|
13
|
-
import
|
|
14
|
-
import
|
|
15
|
-
import
|
|
16
|
-
import
|
|
17
|
-
import
|
|
18
|
-
import
|
|
19
|
-
import
|
|
20
|
-
import
|
|
21
|
-
import
|
|
22
|
-
import
|
|
23
|
-
import
|
|
24
|
-
import
|
|
25
|
-
import
|
|
26
|
-
import
|
|
27
|
-
import
|
|
28
|
-
import
|
|
29
|
-
import
|
|
30
|
-
import
|
|
31
|
-
import
|
|
32
|
-
import
|
|
33
|
-
import
|
|
1
|
+
import $$ from './browser/$$.js';
|
|
2
|
+
import $ from './browser/$.js';
|
|
3
|
+
import action from './browser/action.js';
|
|
4
|
+
import actions from './browser/actions.js';
|
|
5
|
+
import call from './browser/call.js';
|
|
6
|
+
import custom$$ from './browser/custom$$.js';
|
|
7
|
+
import custom$ from './browser/custom$.js';
|
|
8
|
+
import debug from './browser/debug.js';
|
|
9
|
+
import deleteCookies from './browser/deleteCookies.js';
|
|
10
|
+
import execute from './browser/execute.js';
|
|
11
|
+
import executeAsync from './browser/executeAsync.js';
|
|
12
|
+
import getCookies from './browser/getCookies.js';
|
|
13
|
+
import getPuppeteer from './browser/getPuppeteer.js';
|
|
14
|
+
import getWindowSize from './browser/getWindowSize.js';
|
|
15
|
+
import keys from './browser/keys.js';
|
|
16
|
+
import mock from './browser/mock.js';
|
|
17
|
+
import mockClearAll from './browser/mockClearAll.js';
|
|
18
|
+
import mockRestoreAll from './browser/mockRestoreAll.js';
|
|
19
|
+
import newWindow from './browser/newWindow.js';
|
|
20
|
+
import pause from './browser/pause.js';
|
|
21
|
+
import react$$ from './browser/react$$.js';
|
|
22
|
+
import react$ from './browser/react$.js';
|
|
23
|
+
import reloadSession from './browser/reloadSession.js';
|
|
24
|
+
import savePDF from './browser/savePDF.js';
|
|
25
|
+
import saveRecordingScreen from './browser/saveRecordingScreen.js';
|
|
26
|
+
import saveScreenshot from './browser/saveScreenshot.js';
|
|
27
|
+
import scroll from './browser/scroll.js';
|
|
28
|
+
import setCookies from './browser/setCookies.js';
|
|
29
|
+
import setTimeout from './browser/setTimeout.js';
|
|
30
|
+
import setWindowSize from './browser/setWindowSize.js';
|
|
31
|
+
import switchWindow from './browser/switchWindow.js';
|
|
32
|
+
import throttle from './browser/throttle.js';
|
|
33
|
+
import touchAction from './browser/touchAction.js';
|
|
34
|
+
import uploadFile from './browser/uploadFile.js';
|
|
35
|
+
import url from './browser/url.js';
|
|
36
|
+
import waitUntil from './browser/waitUntil.js';
|
|
34
37
|
declare const _default: {
|
|
35
38
|
$$: typeof $$;
|
|
36
39
|
$: typeof $;
|
|
40
|
+
action: typeof action;
|
|
41
|
+
actions: typeof actions;
|
|
37
42
|
call: typeof call;
|
|
38
43
|
custom$$: typeof custom$$;
|
|
39
44
|
custom$: typeof custom$;
|
|
@@ -56,6 +61,7 @@ declare const _default: {
|
|
|
56
61
|
savePDF: typeof savePDF;
|
|
57
62
|
saveRecordingScreen: typeof saveRecordingScreen;
|
|
58
63
|
saveScreenshot: typeof saveScreenshot;
|
|
64
|
+
scroll: typeof scroll;
|
|
59
65
|
setCookies: typeof setCookies;
|
|
60
66
|
setTimeout: typeof setTimeout;
|
|
61
67
|
setWindowSize: typeof setWindowSize;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"browser.d.ts","sourceRoot":"","sources":["../../src/commands/browser.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,
|
|
1
|
+
{"version":3,"file":"browser.d.ts","sourceRoot":"","sources":["../../src/commands/browser.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,iBAAiB,CAAA;AAChC,OAAO,CAAC,MAAM,gBAAgB,CAAA;AAC9B,OAAO,MAAM,MAAM,qBAAqB,CAAA;AACxC,OAAO,OAAO,MAAM,sBAAsB,CAAA;AAC1C,OAAO,IAAI,MAAM,mBAAmB,CAAA;AACpC,OAAO,QAAQ,MAAM,uBAAuB,CAAA;AAC5C,OAAO,OAAO,MAAM,sBAAsB,CAAA;AAC1C,OAAO,KAAK,MAAM,oBAAoB,CAAA;AACtC,OAAO,aAAa,MAAM,4BAA4B,CAAA;AACtD,OAAO,OAAO,MAAM,sBAAsB,CAAA;AAC1C,OAAO,YAAY,MAAM,2BAA2B,CAAA;AACpD,OAAO,UAAU,MAAM,yBAAyB,CAAA;AAChD,OAAO,YAAY,MAAM,2BAA2B,CAAA;AACpD,OAAO,aAAa,MAAM,4BAA4B,CAAA;AACtD,OAAO,IAAI,MAAM,mBAAmB,CAAA;AACpC,OAAO,IAAI,MAAM,mBAAmB,CAAA;AACpC,OAAO,YAAY,MAAM,2BAA2B,CAAA;AACpD,OAAO,cAAc,MAAM,6BAA6B,CAAA;AACxD,OAAO,SAAS,MAAM,wBAAwB,CAAA;AAC9C,OAAO,KAAK,MAAM,oBAAoB,CAAA;AACtC,OAAO,OAAO,MAAM,sBAAsB,CAAA;AAC1C,OAAO,MAAM,MAAM,qBAAqB,CAAA;AACxC,OAAO,aAAa,MAAM,4BAA4B,CAAA;AACtD,OAAO,OAAO,MAAM,sBAAsB,CAAA;AAC1C,OAAO,mBAAmB,MAAM,kCAAkC,CAAA;AAClE,OAAO,cAAc,MAAM,6BAA6B,CAAA;AACxD,OAAO,MAAM,MAAM,qBAAqB,CAAA;AACxC,OAAO,UAAU,MAAM,yBAAyB,CAAA;AAChD,OAAO,UAAU,MAAM,yBAAyB,CAAA;AAChD,OAAO,aAAa,MAAM,4BAA4B,CAAA;AACtD,OAAO,YAAY,MAAM,2BAA2B,CAAA;AACpD,OAAO,QAAQ,MAAM,uBAAuB,CAAA;AAC5C,OAAO,WAAW,MAAM,0BAA0B,CAAA;AAClD,OAAO,UAAU,MAAM,yBAAyB,CAAA;AAChD,OAAO,GAAG,MAAM,kBAAkB,CAAA;AAClC,OAAO,SAAS,MAAM,wBAAwB,CAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAE9C,wBAMC"}
|
|
@@ -1,44 +1,43 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
setTimeout: setTimeout_1.default, setWindowSize: setWindowSize_1.default, switchWindow: switchWindow_1.default, throttle: throttle_1.default, touchAction: touchAction_1.default, uploadFile: uploadFile_1.default, url: url_1.default, waitUntil: waitUntil_1.default
|
|
1
|
+
import $$ from './browser/$$.js';
|
|
2
|
+
import $ from './browser/$.js';
|
|
3
|
+
import action from './browser/action.js';
|
|
4
|
+
import actions from './browser/actions.js';
|
|
5
|
+
import call from './browser/call.js';
|
|
6
|
+
import custom$$ from './browser/custom$$.js';
|
|
7
|
+
import custom$ from './browser/custom$.js';
|
|
8
|
+
import debug from './browser/debug.js';
|
|
9
|
+
import deleteCookies from './browser/deleteCookies.js';
|
|
10
|
+
import execute from './browser/execute.js';
|
|
11
|
+
import executeAsync from './browser/executeAsync.js';
|
|
12
|
+
import getCookies from './browser/getCookies.js';
|
|
13
|
+
import getPuppeteer from './browser/getPuppeteer.js';
|
|
14
|
+
import getWindowSize from './browser/getWindowSize.js';
|
|
15
|
+
import keys from './browser/keys.js';
|
|
16
|
+
import mock from './browser/mock.js';
|
|
17
|
+
import mockClearAll from './browser/mockClearAll.js';
|
|
18
|
+
import mockRestoreAll from './browser/mockRestoreAll.js';
|
|
19
|
+
import newWindow from './browser/newWindow.js';
|
|
20
|
+
import pause from './browser/pause.js';
|
|
21
|
+
import react$$ from './browser/react$$.js';
|
|
22
|
+
import react$ from './browser/react$.js';
|
|
23
|
+
import reloadSession from './browser/reloadSession.js';
|
|
24
|
+
import savePDF from './browser/savePDF.js';
|
|
25
|
+
import saveRecordingScreen from './browser/saveRecordingScreen.js';
|
|
26
|
+
import saveScreenshot from './browser/saveScreenshot.js';
|
|
27
|
+
import scroll from './browser/scroll.js';
|
|
28
|
+
import setCookies from './browser/setCookies.js';
|
|
29
|
+
import setTimeout from './browser/setTimeout.js';
|
|
30
|
+
import setWindowSize from './browser/setWindowSize.js';
|
|
31
|
+
import switchWindow from './browser/switchWindow.js';
|
|
32
|
+
import throttle from './browser/throttle.js';
|
|
33
|
+
import touchAction from './browser/touchAction.js';
|
|
34
|
+
import uploadFile from './browser/uploadFile.js';
|
|
35
|
+
import url from './browser/url.js';
|
|
36
|
+
import waitUntil from './browser/waitUntil.js';
|
|
37
|
+
export default {
|
|
38
|
+
$$, $, action, actions, call, custom$$, custom$, debug, deleteCookies, execute, executeAsync,
|
|
39
|
+
getCookies, getPuppeteer, getWindowSize, keys, mock, mockClearAll, mockRestoreAll, newWindow,
|
|
40
|
+
pause, react$$, react$, reloadSession, savePDF, saveRecordingScreen, saveScreenshot, scroll,
|
|
41
|
+
setCookies, setTimeout, setWindowSize, switchWindow, throttle, touchAction, uploadFile, url,
|
|
42
|
+
waitUntil
|
|
44
43
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"constant.d.ts","sourceRoot":"","sources":["../../src/commands/constant.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,YAAY,EAAE,MAAM,UAAU,CAAA;
|
|
1
|
+
{"version":3,"file":"constant.d.ts","sourceRoot":"","sources":["../../src/commands/constant.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,YAAY,EAAE,MAAM,UAAU,CAAA;AASzD,UAAU,oBAAqB,SAAQ,IAAI,CAAC,WAAW,EAAE,SAAS,CAAC;IAC/D,OAAO,CAAC,EAAE,MAAM,CAAA;CACnB;AAED,UAAU,gBAAgB;IACtB,MAAM,EAAE,MAAM,CAAA;IACd,OAAO,CAAC,EAAE,oBAAoB,CAAA;CACjC;AAED,eAAO,MAAM,UAAU,UACZ,YAAY,OAAO,GAAG,mBAAmB,WACvC,YAAY,EAAE,KACxB,gBAAgB,EAsClB,CAAA;AAED;;;;;GAKG;AACH,eAAO,MAAM,kBAAkB,WAAY,gBAAgB,SA8B1D,CAAA;AAED,eAAO,MAAM,WAAW,SACd,YAAY,OAAO,GAAG,mBAAmB,WACtC,YAAY,kBAgBxB,CAAA"}
|
|
@@ -1,16 +1,13 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.touchAction = exports.validateParameters = exports.formatArgs = void 0;
|
|
4
1
|
/**
|
|
5
2
|
* Constants around commands
|
|
6
3
|
*/
|
|
7
4
|
const TOUCH_ACTIONS = ['press', 'longPress', 'tap', 'moveTo', 'wait', 'release'];
|
|
8
5
|
const POS_ACTIONS = TOUCH_ACTIONS.slice(0, 4);
|
|
9
6
|
const ACCEPTED_OPTIONS = ['x', 'y', 'element'];
|
|
10
|
-
const formatArgs = function (scope, actions) {
|
|
7
|
+
export const formatArgs = function (scope, actions) {
|
|
11
8
|
return actions.map((action) => {
|
|
12
9
|
if (Array.isArray(action)) {
|
|
13
|
-
return
|
|
10
|
+
return formatArgs(scope, action);
|
|
14
11
|
}
|
|
15
12
|
if (typeof action === 'string') {
|
|
16
13
|
action = { action };
|
|
@@ -43,14 +40,13 @@ const formatArgs = function (scope, actions) {
|
|
|
43
40
|
return formattedAction;
|
|
44
41
|
});
|
|
45
42
|
};
|
|
46
|
-
exports.formatArgs = formatArgs;
|
|
47
43
|
/**
|
|
48
44
|
* Make sure action has proper options before sending command to Appium.
|
|
49
45
|
*
|
|
50
46
|
* @param {Object} params touchAction parameters
|
|
51
47
|
* @return null
|
|
52
48
|
*/
|
|
53
|
-
const validateParameters = (params) => {
|
|
49
|
+
export const validateParameters = (params) => {
|
|
54
50
|
const options = Object.keys(params.options || {});
|
|
55
51
|
if (params.action === 'release' && options.length !== 0) {
|
|
56
52
|
throw new Error('action "release" doesn\'t accept any options ' +
|
|
@@ -72,20 +68,18 @@ const validateParameters = (params) => {
|
|
|
72
68
|
}
|
|
73
69
|
}
|
|
74
70
|
};
|
|
75
|
-
|
|
76
|
-
const touchAction = function (actions) {
|
|
71
|
+
export const touchAction = function (actions) {
|
|
77
72
|
if (!this.multiTouchPerform || !this.touchPerform) {
|
|
78
73
|
throw new Error('touchAction can be used with Appium only.');
|
|
79
74
|
}
|
|
80
75
|
if (!Array.isArray(actions)) {
|
|
81
76
|
actions = [actions];
|
|
82
77
|
}
|
|
83
|
-
const formattedAction =
|
|
78
|
+
const formattedAction = formatArgs(this, actions);
|
|
84
79
|
const protocolCommand = Array.isArray(actions[0])
|
|
85
80
|
// cast old JSONWP
|
|
86
81
|
? this.multiTouchPerform.bind(this)
|
|
87
82
|
: this.touchPerform.bind(this);
|
|
88
|
-
formattedAction.forEach((params) =>
|
|
83
|
+
formattedAction.forEach((params) => validateParameters(params));
|
|
89
84
|
return protocolCommand(formattedAction);
|
|
90
85
|
};
|
|
91
|
-
exports.touchAction = touchAction;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"$$.d.ts","sourceRoot":"","sources":["../../../src/commands/element/$$.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA0CG;AACH,OAAO,EAAE,MAAM,
|
|
1
|
+
{"version":3,"file":"$$.d.ts","sourceRoot":"","sources":["../../../src/commands/element/$$.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA0CG;AACH,OAAO,EAAE,MAAM,kBAAkB,CAAA;AACjC,eAAe,EAAE,CAAA"}
|
|
@@ -1,8 +1,3 @@
|
|
|
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
1
|
/**
|
|
7
2
|
* The `$$` command is a short way to call the [`findElements`](/docs/api/webdriver#findelements) command in order
|
|
8
3
|
* to fetch multiple elements on the page similar to the `$$` command from the browser scope. The difference when calling
|
|
@@ -46,5 +41,5 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
46
41
|
* @type utility
|
|
47
42
|
*
|
|
48
43
|
*/
|
|
49
|
-
|
|
50
|
-
|
|
44
|
+
import $$ from '../browser/$$.js';
|
|
45
|
+
export default $$;
|