webdriverio 7.20.7 → 7.20.8-alpha.504
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/$$.d.ts +10 -1
- package/build/commands/browser/$$.d.ts.map +1 -1
- package/build/commands/browser/$$.js +16 -9
- package/build/commands/browser/$.js +8 -11
- package/build/commands/browser/action.d.ts +132 -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/addCommand.d.ts +1 -1
- package/build/commands/browser/addCommand.js +1 -1
- package/build/commands/browser/call.d.ts +7 -5
- package/build/commands/browser/call.d.ts.map +1 -1
- package/build/commands/browser/call.js +8 -9
- package/build/commands/browser/custom$$.js +7 -10
- package/build/commands/browser/custom$.d.ts +1 -1
- package/build/commands/browser/custom$.js +6 -9
- package/build/commands/browser/debug.js +8 -14
- package/build/commands/browser/deleteCookies.d.ts +3 -3
- package/build/commands/browser/deleteCookies.js +4 -7
- package/build/commands/browser/execute.d.ts +2 -2
- package/build/commands/browser/execute.js +5 -8
- package/build/commands/browser/executeAsync.js +3 -6
- package/build/commands/browser/getCookies.d.ts +2 -2
- package/build/commands/browser/getCookies.js +3 -6
- 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 +5 -4
- package/build/commands/browser/mock.d.ts.map +1 -1
- package/build/commands/browser/mock.js +16 -22
- 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 +16 -17
- package/build/commands/browser/react$.d.ts.map +1 -1
- package/build/commands/browser/react$.js +13 -14
- package/build/commands/browser/reloadSession.js +5 -12
- package/build/commands/browser/savePDF.d.ts +14 -14
- package/build/commands/browser/savePDF.js +21 -27
- 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.d.ts +1 -1
- package/build/commands/browser/setCookies.d.ts.map +1 -1
- package/build/commands/browser/setCookies.js +5 -7
- 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.d.ts +1 -2
- package/build/commands/browser/waitUntil.d.ts.map +1 -1
- package/build/commands/browser/waitUntil.js +4 -11
- package/build/commands/browser.d.ts +37 -69
- package/build/commands/browser.d.ts.map +1 -1
- package/build/commands/browser.js +37 -44
- 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 +5 -5
- 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.d.ts.map +1 -1
- package/build/commands/element/isClickable.js +10 -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 +16 -16
- package/build/commands/element/react$.d.ts.map +1 -1
- package/build/commands/element/react$.js +15 -14
- package/build/commands/element/saveScreenshot.js +6 -12
- package/build/commands/element/scrollIntoView.d.ts +4 -2
- package/build/commands/element/scrollIntoView.d.ts.map +1 -1
- package/build/commands/element/scrollIntoView.js +33 -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 +2 -3
- package/build/commands/element/waitUntil.d.ts.map +1 -1
- package/build/commands/element/waitUntil.js +3 -9
- package/build/commands/element.d.ts +49 -99
- package/build/commands/element.d.ts.map +1 -1
- package/build/commands/element.js +49 -63
- package/build/constants.d.ts +67 -0
- package/build/constants.d.ts.map +1 -1
- package/build/constants.js +105 -12
- package/build/index.d.ts +65 -6
- package/build/index.d.ts.map +1 -1
- package/build/index.js +48 -86
- package/build/middlewares.d.ts +1 -1
- package/build/middlewares.js +11 -19
- package/build/multiremote.js +18 -24
- 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 +5 -5
- 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 +2 -5
- 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 +5 -9
- 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 +13 -29
- 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 +66 -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.d.ts.map +1 -1
- package/build/utils/findStrategy.js +50 -19
- package/build/utils/getElementObject.d.ts +1 -1
- package/build/utils/getElementObject.d.ts.map +1 -1
- package/build/utils/getElementObject.js +51 -32
- package/build/utils/implicitWait.js +3 -9
- package/build/utils/index.d.ts +8 -7
- package/build/utils/index.d.ts.map +1 -1
- package/build/utils/index.js +125 -148
- 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 -36
- 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 +10 -13
- 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 +6 -11
- package/build/utils/refetchElement.js +3 -9
- package/package.json +27 -17
- package/async.d.ts +0 -24
- package/sync.d.ts +0 -24
|
@@ -1,13 +1,9 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
};
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
const utils_1 = require("../../utils");
|
|
8
|
-
const getElementObject_1 = require("../../utils/getElementObject");
|
|
9
|
-
const resq_1 = require("../../scripts/resq");
|
|
10
|
-
const resqScript = fs_1.default.readFileSync(require.resolve('resq'));
|
|
1
|
+
import fs from 'node:fs/promises';
|
|
2
|
+
import { createRequire } from 'node:module';
|
|
3
|
+
import { enhanceElementsArray } from '../../utils/index.js';
|
|
4
|
+
import { getElements } from '../../utils/getElementObject.js';
|
|
5
|
+
import { waitToLoadReact, react$$ as react$$Script } from '../../scripts/resq.js';
|
|
6
|
+
let resqScript;
|
|
11
7
|
/**
|
|
12
8
|
*
|
|
13
9
|
* The `react$$` command is a useful command to query multiple React Components
|
|
@@ -41,11 +37,14 @@ const resqScript = fs_1.default.readFileSync(require.resolve('resq'));
|
|
|
41
37
|
* @return {ElementArray}
|
|
42
38
|
*
|
|
43
39
|
*/
|
|
44
|
-
async function react$$(selector, { props = {}, state = {} } = {}) {
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
40
|
+
export default async function react$$(selector, { props = {}, state = {} } = {}) {
|
|
41
|
+
if (!resqScript) {
|
|
42
|
+
const require = createRequire(import.meta.url);
|
|
43
|
+
resqScript = (await fs.readFile(require.resolve('resq'))).toString();
|
|
44
|
+
}
|
|
45
|
+
await this.executeScript(resqScript, []);
|
|
46
|
+
await this.execute(waitToLoadReact);
|
|
47
|
+
const res = await this.execute(react$$Script, selector, props, state);
|
|
48
|
+
const elements = await getElements.call(this, selector, res, true);
|
|
49
|
+
return enhanceElementsArray(elements, this, selector, 'react$$', [props, state]);
|
|
50
50
|
}
|
|
51
|
-
exports.default = react$$;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"react$.d.ts","sourceRoot":"","sources":["../../../src/commands/browser/react$.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"react$.d.ts","sourceRoot":"","sources":["../../../src/commands/browser/react$.ts"],"names":[],"mappings":"AAOA,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,aAAa,CAAA;AAIvD;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA0CG;AACH,wBAA8B,MAAM,CAChC,IAAI,EAAE,WAAW,CAAC,OAAO,EACzB,QAAQ,EAAE,MAAM,EAChB,EAAE,KAAU,EAAE,KAAU,EAAE,GAAE,oBAAyB,gCAcxD"}
|
|
@@ -1,12 +1,8 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
};
|
|
5
|
-
|
|
6
|
-
const fs_1 = __importDefault(require("fs"));
|
|
7
|
-
const getElementObject_1 = require("../../utils/getElementObject");
|
|
8
|
-
const resq_1 = require("../../scripts/resq");
|
|
9
|
-
const resqScript = fs_1.default.readFileSync(require.resolve('resq'));
|
|
1
|
+
import fs from 'node:fs/promises';
|
|
2
|
+
import { createRequire } from 'node:module';
|
|
3
|
+
import { getElement } from '../../utils/getElementObject.js';
|
|
4
|
+
import { waitToLoadReact, react$ as react$Script } from '../../scripts/resq.js';
|
|
5
|
+
let resqScript;
|
|
10
6
|
/**
|
|
11
7
|
*
|
|
12
8
|
* The `react$` command is a useful command to query React Components by their
|
|
@@ -50,10 +46,13 @@ const resqScript = fs_1.default.readFileSync(require.resolve('resq'));
|
|
|
50
46
|
* @return {Element}
|
|
51
47
|
*
|
|
52
48
|
*/
|
|
53
|
-
async function react$(selector, { props = {}, state = {} } = {}) {
|
|
49
|
+
export default async function react$(selector, { props = {}, state = {} } = {}) {
|
|
50
|
+
if (!resqScript) {
|
|
51
|
+
const require = createRequire(import.meta.url);
|
|
52
|
+
resqScript = (await fs.readFile(require.resolve('resq'))).toString();
|
|
53
|
+
}
|
|
54
54
|
await this.executeScript(resqScript.toString(), []);
|
|
55
|
-
await this.execute(
|
|
56
|
-
const res = await this.execute(
|
|
57
|
-
return
|
|
55
|
+
await this.execute(waitToLoadReact);
|
|
56
|
+
const res = await this.execute(react$Script, selector, props, state);
|
|
57
|
+
return getElement.call(this, selector, res, true);
|
|
58
58
|
}
|
|
59
|
-
exports.default = react$;
|
|
@@ -1,10 +1,5 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
-
};
|
|
5
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
const logger_1 = __importDefault(require("@wdio/logger"));
|
|
7
|
-
const log = (0, logger_1.default)('webdriverio');
|
|
1
|
+
import logger from '@wdio/logger';
|
|
2
|
+
const log = logger('webdriverio');
|
|
8
3
|
/**
|
|
9
4
|
*
|
|
10
5
|
* Creates a new Selenium session with your current capabilities. This is useful if you
|
|
@@ -26,8 +21,7 @@ const log = (0, logger_1.default)('webdriverio');
|
|
|
26
21
|
* @type utility
|
|
27
22
|
*
|
|
28
23
|
*/
|
|
29
|
-
async function reloadSession() {
|
|
30
|
-
var _a;
|
|
24
|
+
export default async function reloadSession() {
|
|
31
25
|
const oldSessionId = this.sessionId;
|
|
32
26
|
/**
|
|
33
27
|
* end current running session, if session already gone suppress exceptions
|
|
@@ -43,11 +37,11 @@ async function reloadSession() {
|
|
|
43
37
|
*/
|
|
44
38
|
log.warn(`Suppressing error closing the session: ${err.stack}`);
|
|
45
39
|
}
|
|
46
|
-
if (
|
|
40
|
+
if (this.puppeteer?.isConnected()) {
|
|
47
41
|
this.puppeteer.disconnect();
|
|
48
42
|
log.debug('Disconnected puppeteer session');
|
|
49
43
|
}
|
|
50
|
-
const ProtocolDriver =
|
|
44
|
+
const ProtocolDriver = (await import(this.options.automationProtocol)).default;
|
|
51
45
|
await ProtocolDriver.reloadSession(this);
|
|
52
46
|
const options = this.options;
|
|
53
47
|
if (Array.isArray(options.onReload) && options.onReload.length) {
|
|
@@ -55,4 +49,3 @@ async function reloadSession() {
|
|
|
55
49
|
}
|
|
56
50
|
return this.sessionId;
|
|
57
51
|
}
|
|
58
|
-
exports.default = reloadSession;
|
|
@@ -24,20 +24,20 @@ declare type PDFPrintOptions = {
|
|
|
24
24
|
* </example>
|
|
25
25
|
*
|
|
26
26
|
* @alias browser.savePDF
|
|
27
|
-
* @param {String}
|
|
28
|
-
* @param {PDFPrintOptions=} options
|
|
29
|
-
* @param {String=}
|
|
30
|
-
* @param {number=}
|
|
31
|
-
* @param {boolean=}
|
|
32
|
-
* @param {number=}
|
|
33
|
-
* @param {number=}
|
|
34
|
-
* @param {number=}
|
|
35
|
-
* @param {number=}
|
|
36
|
-
* @param {number=}
|
|
37
|
-
* @param {number=}
|
|
38
|
-
* @param {boolean=}
|
|
39
|
-
* @param {object[]
|
|
40
|
-
* @return {Buffer}
|
|
27
|
+
* @param {String} filepath path to the generated pdf (`.pdf` suffix is required) relative to the execution directory
|
|
28
|
+
* @param {PDFPrintOptions=} options Print PDF Options
|
|
29
|
+
* @param {String=} options.orientation Orientation of PDF page
|
|
30
|
+
* @param {number=} options.scale Scale of PDF page
|
|
31
|
+
* @param {boolean=} options.background Include background of PDF page
|
|
32
|
+
* @param {number=} options.width Width of PDF page
|
|
33
|
+
* @param {number=} options.height Height of PDF page
|
|
34
|
+
* @param {number=} options.top Top padding of PDF page
|
|
35
|
+
* @param {number=} options.bottom Bottom padding of PDF page
|
|
36
|
+
* @param {number=} options.left Left padding of PDF page
|
|
37
|
+
* @param {number=} options.right Right padding of PDF page
|
|
38
|
+
* @param {boolean=} options.shrinkToFit Shrink page to fit page
|
|
39
|
+
* @param {object[]} options.pageRanges Range of pages to include in PDF
|
|
40
|
+
* @return {Buffer} screenshot buffer
|
|
41
41
|
* @type utility
|
|
42
42
|
*
|
|
43
43
|
*/
|
|
@@ -1,10 +1,5 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
-
};
|
|
5
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
const fs_1 = __importDefault(require("fs"));
|
|
7
|
-
const utils_1 = require("../../utils");
|
|
1
|
+
import fs from 'node:fs';
|
|
2
|
+
import { getAbsoluteFilepath, assertDirectoryExists } from '../../utils/index.js';
|
|
8
3
|
/**
|
|
9
4
|
*
|
|
10
5
|
* Prints the page of the current browsing context to a PDF file on your OS.
|
|
@@ -17,35 +12,34 @@ const utils_1 = require("../../utils");
|
|
|
17
12
|
* </example>
|
|
18
13
|
*
|
|
19
14
|
* @alias browser.savePDF
|
|
20
|
-
* @param {String}
|
|
21
|
-
* @param {PDFPrintOptions=} options
|
|
22
|
-
* @param {String=}
|
|
23
|
-
* @param {number=}
|
|
24
|
-
* @param {boolean=}
|
|
25
|
-
* @param {number=}
|
|
26
|
-
* @param {number=}
|
|
27
|
-
* @param {number=}
|
|
28
|
-
* @param {number=}
|
|
29
|
-
* @param {number=}
|
|
30
|
-
* @param {number=}
|
|
31
|
-
* @param {boolean=}
|
|
32
|
-
* @param {object[]
|
|
33
|
-
* @return {Buffer}
|
|
15
|
+
* @param {String} filepath path to the generated pdf (`.pdf` suffix is required) relative to the execution directory
|
|
16
|
+
* @param {PDFPrintOptions=} options Print PDF Options
|
|
17
|
+
* @param {String=} options.orientation Orientation of PDF page
|
|
18
|
+
* @param {number=} options.scale Scale of PDF page
|
|
19
|
+
* @param {boolean=} options.background Include background of PDF page
|
|
20
|
+
* @param {number=} options.width Width of PDF page
|
|
21
|
+
* @param {number=} options.height Height of PDF page
|
|
22
|
+
* @param {number=} options.top Top padding of PDF page
|
|
23
|
+
* @param {number=} options.bottom Bottom padding of PDF page
|
|
24
|
+
* @param {number=} options.left Left padding of PDF page
|
|
25
|
+
* @param {number=} options.right Right padding of PDF page
|
|
26
|
+
* @param {boolean=} options.shrinkToFit Shrink page to fit page
|
|
27
|
+
* @param {object[]} options.pageRanges Range of pages to include in PDF
|
|
28
|
+
* @return {Buffer} screenshot buffer
|
|
34
29
|
* @type utility
|
|
35
30
|
*
|
|
36
31
|
*/
|
|
37
|
-
async function savePDF(filepath, options) {
|
|
32
|
+
export default async function savePDF(filepath, options) {
|
|
38
33
|
/**
|
|
39
34
|
* type check
|
|
40
35
|
*/
|
|
41
36
|
if (typeof filepath != 'string' || !filepath.endsWith('.pdf')) {
|
|
42
37
|
throw new Error('savePDF expects a filepath of type string and ".pdf" file ending');
|
|
43
38
|
}
|
|
44
|
-
const absoluteFilepath =
|
|
45
|
-
|
|
46
|
-
const pdf = await this.printPage(options
|
|
39
|
+
const absoluteFilepath = getAbsoluteFilepath(filepath);
|
|
40
|
+
assertDirectoryExists(absoluteFilepath);
|
|
41
|
+
const pdf = await this.printPage(options?.orientation, options?.scale, options?.background, options?.width, options?.height, options?.top, options?.bottom, options?.left, options?.right, options?.shrinkToFit, options?.pageRanges);
|
|
47
42
|
const page = Buffer.from(pdf, 'base64');
|
|
48
|
-
|
|
43
|
+
fs.writeFileSync(absoluteFilepath, page);
|
|
49
44
|
return page;
|
|
50
45
|
}
|
|
51
|
-
exports.default = savePDF;
|
|
@@ -1,10 +1,5 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
-
};
|
|
5
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
const fs_1 = __importDefault(require("fs"));
|
|
7
|
-
const utils_1 = require("../../utils");
|
|
1
|
+
import fs from 'node:fs';
|
|
2
|
+
import { getAbsoluteFilepath, assertDirectoryExists } from '../../utils/index.js';
|
|
8
3
|
/**
|
|
9
4
|
*
|
|
10
5
|
* Save a video started by [`startRecordingScreen`](/docs/api/appium#startrecordingscreen) command to file.
|
|
@@ -30,18 +25,17 @@ const utils_1 = require("../../utils");
|
|
|
30
25
|
* @type utility
|
|
31
26
|
*
|
|
32
27
|
*/
|
|
33
|
-
async function saveRecordingScreen(filepath) {
|
|
28
|
+
export default async function saveRecordingScreen(filepath) {
|
|
34
29
|
/**
|
|
35
30
|
* type check
|
|
36
31
|
*/
|
|
37
32
|
if (typeof filepath !== 'string') {
|
|
38
33
|
throw new Error('saveRecordingScreen expects a filepath');
|
|
39
34
|
}
|
|
40
|
-
const absoluteFilepath =
|
|
41
|
-
|
|
35
|
+
const absoluteFilepath = getAbsoluteFilepath(filepath);
|
|
36
|
+
assertDirectoryExists(absoluteFilepath);
|
|
42
37
|
const videoBuffer = await this.stopRecordingScreen();
|
|
43
38
|
const video = Buffer.from(videoBuffer, 'base64');
|
|
44
|
-
|
|
39
|
+
fs.writeFileSync(absoluteFilepath, video);
|
|
45
40
|
return video;
|
|
46
41
|
}
|
|
47
|
-
exports.default = saveRecordingScreen;
|
|
@@ -1,10 +1,5 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
-
};
|
|
5
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
const fs_1 = __importDefault(require("fs"));
|
|
7
|
-
const utils_1 = require("../../utils");
|
|
1
|
+
import fs from 'node:fs';
|
|
2
|
+
import { getAbsoluteFilepath, assertDirectoryExists } from '../../utils/index.js';
|
|
8
3
|
/**
|
|
9
4
|
*
|
|
10
5
|
* Save a screenshot of the current browsing context to a PNG file on your OS. Be aware that
|
|
@@ -24,18 +19,17 @@ const utils_1 = require("../../utils");
|
|
|
24
19
|
* @type utility
|
|
25
20
|
*
|
|
26
21
|
*/
|
|
27
|
-
async function saveScreenshot(filepath) {
|
|
22
|
+
export default async function saveScreenshot(filepath) {
|
|
28
23
|
/**
|
|
29
24
|
* type check
|
|
30
25
|
*/
|
|
31
26
|
if (typeof filepath !== 'string' || !filepath.endsWith('.png')) {
|
|
32
27
|
throw new Error('saveScreenshot expects a filepath of type string and ".png" file ending');
|
|
33
28
|
}
|
|
34
|
-
const absoluteFilepath =
|
|
35
|
-
|
|
29
|
+
const absoluteFilepath = getAbsoluteFilepath(filepath);
|
|
30
|
+
assertDirectoryExists(absoluteFilepath);
|
|
36
31
|
const screenBuffer = await this.takeScreenshot();
|
|
37
32
|
const screenshot = Buffer.from(screenBuffer, 'base64');
|
|
38
|
-
|
|
33
|
+
fs.writeFileSync(absoluteFilepath, screenshot);
|
|
39
34
|
return screenshot;
|
|
40
35
|
}
|
|
41
|
-
exports.default = saveScreenshot;
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
/**
|
|
2
|
+
*
|
|
3
|
+
* Scroll within the browser viewport. Note that `x` and `y` coordinates are relative to the current
|
|
4
|
+
* scroll positon, therefore `browser.scroll(0, 0)` is a non operation.
|
|
5
|
+
*
|
|
6
|
+
* <example>
|
|
7
|
+
:scroll.js
|
|
8
|
+
it('should demonstrate the scroll command', async () => {
|
|
9
|
+
await browser.url('https://webdriver.io')
|
|
10
|
+
|
|
11
|
+
console.log(await browser.execute(() => window.scrollY)) // returns 0
|
|
12
|
+
await browser.scroll(0, 200)
|
|
13
|
+
console.log(await browser.execute(() => window.scrollY)) // returns 200
|
|
14
|
+
});
|
|
15
|
+
* </example>
|
|
16
|
+
*
|
|
17
|
+
* @alias element.scroll
|
|
18
|
+
* @param {number=} x horizontal scroll position (default: `0`)
|
|
19
|
+
* @param {number=} y vertical scroll position (default: `0`)
|
|
20
|
+
* @uses protocol/execute
|
|
21
|
+
* @type utility
|
|
22
|
+
*
|
|
23
|
+
*/
|
|
24
|
+
export default function scroll(this: WebdriverIO.Browser, x?: number, y?: number): void | Promise<void>;
|
|
25
|
+
//# sourceMappingURL=scroll.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"scroll.d.ts","sourceRoot":"","sources":["../../../src/commands/browser/scroll.ts"],"names":[],"mappings":"AAIA;;;;;;;;;;;;;;;;;;;;;;GAsBG;AACH,MAAM,CAAC,OAAO,UAAU,MAAM,CAC1B,IAAI,EAAE,WAAW,CAAC,OAAO,EACzB,CAAC,SAAI,EACL,CAAC,SAAI,wBAiBR"}
|
|
@@ -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
|
+
}
|
|
@@ -40,7 +40,7 @@ import type { Cookie } from '@wdio/protocols';
|
|
|
40
40
|
* </example>
|
|
41
41
|
*
|
|
42
42
|
* @alias browser.setCookies
|
|
43
|
-
* @param {Array<
|
|
43
|
+
* @param {Array<WebDriverCookie>|WebDriverCookie} cookie cookie object or object array.
|
|
44
44
|
* @param {String=} cookie.name The name of the cookie.
|
|
45
45
|
* @param {String=} cookie.value The cookie value.
|
|
46
46
|
* @param {String=} cookie.path The cookie path. Defaults to "/" if omitted when adding a cookie.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"setCookies.d.ts","sourceRoot":"","sources":["../../../src/commands/browser/setCookies.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,iBAAiB,CAAA;AAE7C;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAqDG;AACH,wBAA8B,UAAU,CACpC,IAAI,EAAE,WAAW,CAAC,OAAO,EACzB,UAAU,EAAE,MAAM,GAAG,MAAM,EAAE,
|
|
1
|
+
{"version":3,"file":"setCookies.d.ts","sourceRoot":"","sources":["../../../src/commands/browser/setCookies.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,iBAAiB,CAAA;AAE7C;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAqDG;AACH,wBAA8B,UAAU,CACpC,IAAI,EAAE,WAAW,CAAC,OAAO,EACzB,UAAU,EAAE,MAAM,GAAG,MAAM,EAAE,iBAYhC"}
|
|
@@ -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
|
|
@@ -41,7 +39,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
41
39
|
* </example>
|
|
42
40
|
*
|
|
43
41
|
* @alias browser.setCookies
|
|
44
|
-
* @param {Array<
|
|
42
|
+
* @param {Array<WebDriverCookie>|WebDriverCookie} cookie cookie object or object array.
|
|
45
43
|
* @param {String=} cookie.name The name of the cookie.
|
|
46
44
|
* @param {String=} cookie.value The cookie value.
|
|
47
45
|
* @param {String=} cookie.path The cookie path. Defaults to "/" if omitted when adding a cookie.
|
|
@@ -54,13 +52,13 @@ 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)');
|
|
61
59
|
}
|
|
62
|
-
|
|
63
|
-
|
|
60
|
+
for (const cookieObj of cookieObjsList) {
|
|
61
|
+
await this.addCookie(cookieObj);
|
|
62
|
+
}
|
|
64
63
|
return;
|
|
65
64
|
}
|
|
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;
|