webdriverio 9.0.0-alpha.114 → 9.0.0-alpha.321
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/commands/browser/downloadFile.d.ts +34 -0
- package/build/commands/browser/downloadFile.d.ts.map +1 -0
- package/build/commands/browser/downloadFile.js +79 -0
- package/build/commands/browser/getCookies.d.ts +2 -1
- package/build/commands/browser/getCookies.d.ts.map +1 -1
- package/build/commands/browser/getPuppeteer.d.ts.map +1 -1
- package/build/commands/browser/getPuppeteer.js +9 -10
- package/build/commands/browser/mock.d.ts +2 -2
- package/build/commands/browser/mock.d.ts.map +1 -1
- package/build/commands/browser/reloadSession.d.ts +20 -0
- package/build/commands/browser/reloadSession.d.ts.map +1 -1
- package/build/commands/browser/reloadSession.js +21 -1
- package/build/commands/browser.d.ts +1 -0
- package/build/commands/browser.d.ts.map +1 -1
- package/build/commands/browser.js +1 -0
- package/build/commands/element/dragAndDrop.d.ts +2 -1
- package/build/commands/element/dragAndDrop.d.ts.map +1 -1
- package/build/commands/element/isExisting.d.ts.map +1 -1
- package/build/commands/element/isExisting.js +3 -1
- package/build/commands/element/nextElement.d.ts +1 -1
- package/build/commands/element/nextElement.d.ts.map +1 -1
- package/build/commands/element/parentElement.d.ts +1 -1
- package/build/commands/element/parentElement.d.ts.map +1 -1
- package/build/commands/element/previousElement.d.ts +1 -1
- package/build/commands/element/previousElement.d.ts.map +1 -1
- package/build/commands/element/shadow$$.d.ts +1 -1
- package/build/commands/element/shadow$$.d.ts.map +1 -1
- package/build/commands/element/shadow$.d.ts +1 -1
- package/build/commands/element/shadow$.d.ts.map +1 -1
- package/build/commands/mock/redirect.d.ts +22 -0
- package/build/commands/mock/redirect.d.ts.map +1 -0
- package/build/commands/mock/redirect.js +22 -0
- package/build/commands/mock/request.d.ts +37 -0
- package/build/commands/mock/request.d.ts.map +1 -0
- package/build/commands/mock/request.js +37 -0
- package/build/commands/mock/requestOnce.d.ts +37 -0
- package/build/commands/mock/requestOnce.d.ts.map +1 -0
- package/build/commands/mock/requestOnce.js +37 -0
- package/build/commands/mock/restore.d.ts +1 -1
- package/build/commands/mock/restore.js +1 -1
- package/build/constants.d.ts +2 -2
- package/build/constants.d.ts.map +1 -1
- package/build/{cjs/index.js → index.cjs} +3 -3
- package/build/index.d.cts +2 -0
- package/build/index.d.cts.map +1 -0
- package/build/index.d.ts +10 -5
- package/build/index.d.ts.map +1 -1
- package/build/index.js +2 -1
- package/build/protocol-stub.d.ts +2 -2
- package/build/protocol-stub.d.ts.map +1 -1
- package/build/protocol-stub.js +4 -3
- package/build/shadowRoot.d.ts.map +1 -1
- package/build/shadowRoot.js +2 -3
- package/build/types.d.ts +34 -25
- package/build/types.d.ts.map +1 -1
- package/build/utils/actions/pointer.d.ts +3 -1
- package/build/utils/actions/pointer.d.ts.map +1 -1
- package/build/utils/actions/wheel.d.ts +1 -1
- package/build/utils/actions/wheel.d.ts.map +1 -1
- package/build/utils/detectBackend.d.ts +1 -1
- package/build/utils/detectBackend.d.ts.map +1 -1
- package/build/utils/detectBackend.js +2 -3
- package/build/utils/driver.d.ts +5 -6
- package/build/utils/driver.d.ts.map +1 -1
- package/build/utils/driver.js +1 -1
- package/build/utils/findStrategy.js +2 -2
- package/build/utils/implicitWait.js +1 -1
- package/build/utils/index.js +1 -1
- package/build/utils/interception/index.d.ts +17 -9
- package/build/utils/interception/index.d.ts.map +1 -1
- package/build/utils/interception/index.js +117 -49
- package/build/utils/interception/types.d.ts +0 -3
- package/build/utils/interception/types.d.ts.map +1 -1
- package/build/utils/interception/utils.d.ts +1 -8
- package/build/utils/interception/utils.d.ts.map +1 -1
- package/build/utils/interception/utils.js +18 -21
- package/build/utils/refetchElement.js +2 -2
- package/package.json +13 -12
- package/build/cjs/index.d.ts +0 -2
- package/build/cjs/index.d.ts.map +0 -1
- package/build/cjs/package.json +0 -5
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
/**
|
|
2
|
+
*
|
|
3
|
+
* Download a file from the remote computer running Selenium node to local file system
|
|
4
|
+
* by using the [`downloadFile`](https://webdriver.io/docs/api/selenium#downloadFile) command.
|
|
5
|
+
*
|
|
6
|
+
* :::info
|
|
7
|
+
* Note that this command is only supported if you use a
|
|
8
|
+
* [Selenium Grid](https://www.selenium.dev/documentation/en/grid/) with Chrome, Edge or Firefox
|
|
9
|
+
* and have the `se:downloadsEnabled` flag set in the capabilities.
|
|
10
|
+
* :::
|
|
11
|
+
*
|
|
12
|
+
* <example>
|
|
13
|
+
:downloadFile.js
|
|
14
|
+
it('should download a file', async () => {
|
|
15
|
+
await browser.url('https://www.selenium.dev/selenium/web/downloads/download.html')
|
|
16
|
+
await $('#file-1').click()
|
|
17
|
+
await browser.waitUntil(async function () {
|
|
18
|
+
return (await browser.getDownloadableFiles()).names.includes('file_1.txt')
|
|
19
|
+
}, {timeout: 5000})
|
|
20
|
+
const files = await browser.getDownloadableFiles()
|
|
21
|
+
const downloaded = await browser.downloadFile(files.names[0], process.cwd())
|
|
22
|
+
await browser.deleteDownloadableFiles()
|
|
23
|
+
})
|
|
24
|
+
* </example>
|
|
25
|
+
*
|
|
26
|
+
* @alias browser.downloadFile
|
|
27
|
+
* @param {string} fileName remote path to file
|
|
28
|
+
* @param {string} targetDirectory target location on local computer
|
|
29
|
+
* @type utility
|
|
30
|
+
* @uses protocol/download
|
|
31
|
+
*
|
|
32
|
+
*/
|
|
33
|
+
export declare function downloadFile(this: WebdriverIO.Browser, fileName: string, targetDirectory: string): Promise<object>;
|
|
34
|
+
//# sourceMappingURL=downloadFile.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"downloadFile.d.ts","sourceRoot":"","sources":["../../../src/commands/browser/downloadFile.ts"],"names":[],"mappings":"AAOA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA+BG;AACH,wBAAsB,YAAY,CAC9B,IAAI,EAAE,WAAW,CAAC,OAAO,EACzB,QAAQ,EAAE,MAAM,EAChB,eAAe,EAAE,MAAM,GACxB,OAAO,CAAC,MAAM,CAAC,CAgDjB"}
|
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
import fs from 'node:fs';
|
|
2
|
+
import path from 'node:path';
|
|
3
|
+
import JSZip from 'jszip';
|
|
4
|
+
import logger from '@wdio/logger';
|
|
5
|
+
const log = logger('webdriverio');
|
|
6
|
+
/**
|
|
7
|
+
*
|
|
8
|
+
* Download a file from the remote computer running Selenium node to local file system
|
|
9
|
+
* by using the [`downloadFile`](https://webdriver.io/docs/api/selenium#downloadFile) command.
|
|
10
|
+
*
|
|
11
|
+
* :::info
|
|
12
|
+
* Note that this command is only supported if you use a
|
|
13
|
+
* [Selenium Grid](https://www.selenium.dev/documentation/en/grid/) with Chrome, Edge or Firefox
|
|
14
|
+
* and have the `se:downloadsEnabled` flag set in the capabilities.
|
|
15
|
+
* :::
|
|
16
|
+
*
|
|
17
|
+
* <example>
|
|
18
|
+
:downloadFile.js
|
|
19
|
+
it('should download a file', async () => {
|
|
20
|
+
await browser.url('https://www.selenium.dev/selenium/web/downloads/download.html')
|
|
21
|
+
await $('#file-1').click()
|
|
22
|
+
await browser.waitUntil(async function () {
|
|
23
|
+
return (await browser.getDownloadableFiles()).names.includes('file_1.txt')
|
|
24
|
+
}, {timeout: 5000})
|
|
25
|
+
const files = await browser.getDownloadableFiles()
|
|
26
|
+
const downloaded = await browser.downloadFile(files.names[0], process.cwd())
|
|
27
|
+
await browser.deleteDownloadableFiles()
|
|
28
|
+
})
|
|
29
|
+
* </example>
|
|
30
|
+
*
|
|
31
|
+
* @alias browser.downloadFile
|
|
32
|
+
* @param {string} fileName remote path to file
|
|
33
|
+
* @param {string} targetDirectory target location on local computer
|
|
34
|
+
* @type utility
|
|
35
|
+
* @uses protocol/download
|
|
36
|
+
*
|
|
37
|
+
*/
|
|
38
|
+
export async function downloadFile(fileName, targetDirectory) {
|
|
39
|
+
/**
|
|
40
|
+
* parameter check
|
|
41
|
+
*/
|
|
42
|
+
if (typeof fileName !== 'string' || typeof targetDirectory !== 'string') {
|
|
43
|
+
throw new Error('number or type of arguments don\'t agree with downloadFile command');
|
|
44
|
+
}
|
|
45
|
+
/**
|
|
46
|
+
* check if command is available
|
|
47
|
+
*/
|
|
48
|
+
if (typeof this.download !== 'function') {
|
|
49
|
+
throw new Error(`The downloadFile command is not available in ${this.capabilities.browserName} and only available when using Selenium Grid`);
|
|
50
|
+
}
|
|
51
|
+
const response = await this.download(fileName);
|
|
52
|
+
const base64Content = response.contents;
|
|
53
|
+
if (!targetDirectory.endsWith('/')) {
|
|
54
|
+
targetDirectory += '/';
|
|
55
|
+
}
|
|
56
|
+
fs.mkdirSync(targetDirectory, { recursive: true });
|
|
57
|
+
const zipFilePath = path.join(targetDirectory, `${fileName}.zip`);
|
|
58
|
+
fs.writeFileSync(zipFilePath, Buffer.from(base64Content, 'base64'));
|
|
59
|
+
const zipData = fs.readFileSync(zipFilePath);
|
|
60
|
+
const filesData = [];
|
|
61
|
+
try {
|
|
62
|
+
const zip = await JSZip.loadAsync(zipData);
|
|
63
|
+
const keys = Object.keys(zip.files);
|
|
64
|
+
// Iterate through each file in the zip archive
|
|
65
|
+
for (let i = 0; i < keys.length; i++) {
|
|
66
|
+
const fileData = await zip.files[keys[i]].async('nodebuffer');
|
|
67
|
+
const dir = path.resolve(targetDirectory, keys[i]);
|
|
68
|
+
fs.writeFileSync(dir, fileData);
|
|
69
|
+
log.info(`File extracted: ${keys[i]}`);
|
|
70
|
+
filesData.push(dir);
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
catch (error) {
|
|
74
|
+
log.error('Error unzipping file:', error);
|
|
75
|
+
}
|
|
76
|
+
return Promise.resolve({
|
|
77
|
+
files: filesData
|
|
78
|
+
});
|
|
79
|
+
}
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import type { Cookie } from '@wdio/protocols';
|
|
1
2
|
/**
|
|
2
3
|
*
|
|
3
4
|
* Retrieve a [cookie](https://w3c.github.io/webdriver/webdriver-spec.html#cookies)
|
|
@@ -30,5 +31,5 @@
|
|
|
30
31
|
* @uses webdriver/getAllCookies
|
|
31
32
|
*
|
|
32
33
|
*/
|
|
33
|
-
export declare function getCookies(this: WebdriverIO.Browser, names?: string | string[]): Promise<
|
|
34
|
+
export declare function getCookies(this: WebdriverIO.Browser, names?: string | string[]): Promise<Cookie[]>;
|
|
34
35
|
//# sourceMappingURL=getCookies.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"getCookies.d.ts","sourceRoot":"","sources":["../../../src/commands/browser/getCookies.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA+BG;AACH,wBAAsB,UAAU,CAC5B,IAAI,EAAE,WAAW,CAAC,OAAO,EACzB,KAAK,CAAC,EAAE,MAAM,GAAG,MAAM,EAAE
|
|
1
|
+
{"version":3,"file":"getCookies.d.ts","sourceRoot":"","sources":["../../../src/commands/browser/getCookies.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,iBAAiB,CAAA;AAC7C;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA+BG;AACH,wBAAsB,UAAU,CAC5B,IAAI,EAAE,WAAW,CAAC,OAAO,EACzB,KAAK,CAAC,EAAE,MAAM,GAAG,MAAM,EAAE,GAC1B,OAAO,CAAC,MAAM,EAAE,CAAC,CAanB"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"getPuppeteer.d.ts","sourceRoot":"","sources":["../../../src/commands/browser/getPuppeteer.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAa,OAAO,IAAI,gBAAgB,EAAE,MAAM,gBAAgB,CAAA;AAM5E;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAkCG;AACH,wBAAsB,YAAY,CAAE,IAAI,EAAE,WAAW,CAAC,OAAO,
|
|
1
|
+
{"version":3,"file":"getPuppeteer.d.ts","sourceRoot":"","sources":["../../../src/commands/browser/getPuppeteer.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAa,OAAO,IAAI,gBAAgB,EAAE,MAAM,gBAAgB,CAAA;AAM5E;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAkCG;AACH,wBAAsB,YAAY,CAAE,IAAI,EAAE,WAAW,CAAC,OAAO,GAAG,OAAO,CAAC,gBAAgB,CAAC,CAwGxF"}
|
|
@@ -47,16 +47,15 @@ export async function getPuppeteer() {
|
|
|
47
47
|
* check if we already connected Puppeteer and if so return
|
|
48
48
|
* that instance
|
|
49
49
|
*/
|
|
50
|
-
if (this.puppeteer?.
|
|
50
|
+
if (this.puppeteer?.connected) {
|
|
51
51
|
log.debug('Reusing existing puppeteer session');
|
|
52
52
|
return this.puppeteer;
|
|
53
53
|
}
|
|
54
54
|
const { headers } = this.options;
|
|
55
|
-
const caps = this.capabilities.alwaysMatch || this.capabilities;
|
|
56
55
|
/**
|
|
57
56
|
* attach to a Selenium 4 CDP Session if it's returned in the capabilities
|
|
58
57
|
*/
|
|
59
|
-
const cdpEndpoint =
|
|
58
|
+
const cdpEndpoint = this.capabilities['se:cdp'];
|
|
60
59
|
if (cdpEndpoint) {
|
|
61
60
|
this.puppeteer = await puppeteer.connect({
|
|
62
61
|
browserWSEndpoint: cdpEndpoint,
|
|
@@ -82,7 +81,7 @@ export async function getPuppeteer() {
|
|
|
82
81
|
/**
|
|
83
82
|
* attach to Chromium debugger session
|
|
84
83
|
*/
|
|
85
|
-
const chromiumOptions =
|
|
84
|
+
const chromiumOptions = this.capabilities['goog:chromeOptions'] || this.capabilities['ms:edgeOptions'];
|
|
86
85
|
if (chromiumOptions && chromiumOptions.debuggerAddress) {
|
|
87
86
|
this.puppeteer = await puppeteer.connect({
|
|
88
87
|
browserURL: `http://${chromiumOptions.debuggerAddress.replace('localhost', '0.0.0.0')}`,
|
|
@@ -93,19 +92,19 @@ export async function getPuppeteer() {
|
|
|
93
92
|
/**
|
|
94
93
|
* attach to Firefox debugger session
|
|
95
94
|
*/
|
|
96
|
-
if (
|
|
97
|
-
if (!
|
|
95
|
+
if (this.capabilities.browserName?.toLowerCase() === 'firefox') {
|
|
96
|
+
if (!this.capabilities.browserVersion) {
|
|
98
97
|
throw new Error('Can\'t find "browserVersion" in capabilities');
|
|
99
98
|
}
|
|
100
|
-
const majorVersion = parseInt(
|
|
99
|
+
const majorVersion = parseInt(this.capabilities.browserVersion.split('.').shift() || '', 10);
|
|
101
100
|
if (majorVersion >= 79) {
|
|
102
101
|
const reqCaps = this.requestedCapabilities.alwaysMatch || this.requestedCapabilities;
|
|
103
102
|
let browserURL;
|
|
104
|
-
if (
|
|
105
|
-
browserURL =
|
|
103
|
+
if (this.capabilities['moz:debuggerAddress']) {
|
|
104
|
+
browserURL = this.capabilities['moz:debuggerAddress'];
|
|
106
105
|
}
|
|
107
106
|
else {
|
|
108
|
-
const ffOptions =
|
|
107
|
+
const ffOptions = this.capabilities['moz:firefoxOptions'];
|
|
109
108
|
const ffArgs = reqCaps['moz:firefoxOptions']?.args || [];
|
|
110
109
|
const rdPort = ffOptions && ffOptions.debuggerAddress
|
|
111
110
|
? ffOptions.debuggerAddress
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type { MockFilterOptions } from '../../utils/interception/types.js';
|
|
2
2
|
import WebDriverInterception from '../../utils/interception/index.js';
|
|
3
3
|
export declare const SESSION_MOCKS: Record<string, Set<WebDriverInterception>>;
|
|
4
4
|
/**
|
|
@@ -107,5 +107,5 @@ export declare const SESSION_MOCKS: Record<string, Set<WebDriverInterception>>;
|
|
|
107
107
|
* @type utility
|
|
108
108
|
*
|
|
109
109
|
*/
|
|
110
|
-
export declare function mock(this: WebdriverIO.Browser, url: string, filterOptions?:
|
|
110
|
+
export declare function mock(this: WebdriverIO.Browser, url: string, filterOptions?: MockFilterOptions): Promise<WebdriverIO.Mock>;
|
|
111
111
|
//# sourceMappingURL=mock.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"mock.d.ts","sourceRoot":"","sources":["../../../src/commands/browser/mock.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,
|
|
1
|
+
{"version":3,"file":"mock.d.ts","sourceRoot":"","sources":["../../../src/commands/browser/mock.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,mCAAmC,CAAA;AAC1E,OAAO,qBAAqB,MAAM,mCAAmC,CAAA;AAErE,eAAO,MAAM,aAAa,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,qBAAqB,CAAC,CAAM,CAAA;AAE3E;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAyGG;AACH,wBAAsB,IAAI,CACtB,IAAI,EAAE,WAAW,CAAC,OAAO,EACzB,GAAG,EAAE,MAAM,EACX,aAAa,CAAC,EAAE,iBAAiB,GAClC,OAAO,CAAC,WAAW,CAAC,IAAI,CAAC,CAa3B"}
|
|
@@ -6,6 +6,14 @@
|
|
|
6
6
|
* Be careful though, this command affects your test time tremendously since spawning
|
|
7
7
|
* new Selenium sessions is very time consuming especially when using cloud services.
|
|
8
8
|
*
|
|
9
|
+
* Connection parameters such as hostname, port, protocol, etc. can be added along side
|
|
10
|
+
* browserName when you want to connect to a different remote service. This is useful
|
|
11
|
+
* in a situation, for example, where you start a test in native app and need to verify
|
|
12
|
+
* data in web app.
|
|
13
|
+
*
|
|
14
|
+
* If you start from remote service, you can pass in 0.0.0.0 for hostname if you want
|
|
15
|
+
* to switch to local drivers.
|
|
16
|
+
*
|
|
9
17
|
* <example>
|
|
10
18
|
:reloadSync.js
|
|
11
19
|
it('should reload my session with current capabilities', async () => {
|
|
@@ -21,6 +29,18 @@
|
|
|
21
29
|
})
|
|
22
30
|
console.log(browser.capabilities.browserName) // outputs: firefox
|
|
23
31
|
})
|
|
32
|
+
|
|
33
|
+
it('should reload my session with new remote', async () => {
|
|
34
|
+
console.log(browser.capabilities.browserName) // outputs: chrome
|
|
35
|
+
await browser.reloadSession({
|
|
36
|
+
protocol: 'https',
|
|
37
|
+
host: '0.0.0.1',
|
|
38
|
+
port: 4444,
|
|
39
|
+
path: '/wd/hub',
|
|
40
|
+
browserName: 'firefox'
|
|
41
|
+
})
|
|
42
|
+
console.log(browser.capabilities.browserName) // outputs: firefox
|
|
43
|
+
})
|
|
24
44
|
* </example>
|
|
25
45
|
*
|
|
26
46
|
* @alias browser.reloadSession
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"reloadSession.d.ts","sourceRoot":"","sources":["../../../src/commands/browser/reloadSession.ts"],"names":[],"mappings":"AAKA
|
|
1
|
+
{"version":3,"file":"reloadSession.d.ts","sourceRoot":"","sources":["../../../src/commands/browser/reloadSession.ts"],"names":[],"mappings":"AAKA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAiDG;AACH,wBAAsB,aAAa,CAAE,IAAI,EAAE,WAAW,CAAC,OAAO,EAAE,eAAe,CAAC,EAAE,WAAW,CAAC,YAAY,mBAoCzG"}
|
|
@@ -8,6 +8,14 @@ const log = logger('webdriverio');
|
|
|
8
8
|
* Be careful though, this command affects your test time tremendously since spawning
|
|
9
9
|
* new Selenium sessions is very time consuming especially when using cloud services.
|
|
10
10
|
*
|
|
11
|
+
* Connection parameters such as hostname, port, protocol, etc. can be added along side
|
|
12
|
+
* browserName when you want to connect to a different remote service. This is useful
|
|
13
|
+
* in a situation, for example, where you start a test in native app and need to verify
|
|
14
|
+
* data in web app.
|
|
15
|
+
*
|
|
16
|
+
* If you start from remote service, you can pass in 0.0.0.0 for hostname if you want
|
|
17
|
+
* to switch to local drivers.
|
|
18
|
+
*
|
|
11
19
|
* <example>
|
|
12
20
|
:reloadSync.js
|
|
13
21
|
it('should reload my session with current capabilities', async () => {
|
|
@@ -23,6 +31,18 @@ const log = logger('webdriverio');
|
|
|
23
31
|
})
|
|
24
32
|
console.log(browser.capabilities.browserName) // outputs: firefox
|
|
25
33
|
})
|
|
34
|
+
|
|
35
|
+
it('should reload my session with new remote', async () => {
|
|
36
|
+
console.log(browser.capabilities.browserName) // outputs: chrome
|
|
37
|
+
await browser.reloadSession({
|
|
38
|
+
protocol: 'https',
|
|
39
|
+
host: '0.0.0.1',
|
|
40
|
+
port: 4444,
|
|
41
|
+
path: '/wd/hub',
|
|
42
|
+
browserName: 'firefox'
|
|
43
|
+
})
|
|
44
|
+
console.log(browser.capabilities.browserName) // outputs: firefox
|
|
45
|
+
})
|
|
26
46
|
* </example>
|
|
27
47
|
*
|
|
28
48
|
* @alias browser.reloadSession
|
|
@@ -50,7 +70,7 @@ export async function reloadSession(newCapabilities) {
|
|
|
50
70
|
*/
|
|
51
71
|
log.warn(`Suppressing error closing the session: ${err.stack}`);
|
|
52
72
|
}
|
|
53
|
-
if (this.puppeteer?.
|
|
73
|
+
if (this.puppeteer?.connected) {
|
|
54
74
|
this.puppeteer.disconnect();
|
|
55
75
|
log.debug('Disconnected puppeteer session');
|
|
56
76
|
}
|
|
@@ -7,6 +7,7 @@ export * from './browser/custom$$.js';
|
|
|
7
7
|
export * from './browser/custom$.js';
|
|
8
8
|
export * from './browser/debug.js';
|
|
9
9
|
export * from './browser/deleteCookies.js';
|
|
10
|
+
export * from './browser/downloadFile.js';
|
|
10
11
|
export * from './browser/emulate.js';
|
|
11
12
|
export * from './browser/execute.js';
|
|
12
13
|
export * from './browser/executeAsync.js';
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"browser.d.ts","sourceRoot":"","sources":["../../src/commands/browser.ts"],"names":[],"mappings":"AAAA,cAAc,iBAAiB,CAAA;AAC/B,cAAc,gBAAgB,CAAA;AAC9B,cAAc,qBAAqB,CAAA;AACnC,cAAc,sBAAsB,CAAA;AACpC,cAAc,mBAAmB,CAAA;AACjC,cAAc,uBAAuB,CAAA;AACrC,cAAc,sBAAsB,CAAA;AACpC,cAAc,oBAAoB,CAAA;AAClC,cAAc,4BAA4B,CAAA;AAC1C,cAAc,sBAAsB,CAAA;AACpC,cAAc,sBAAsB,CAAA;AACpC,cAAc,2BAA2B,CAAA;AACzC,cAAc,yBAAyB,CAAA;AACvC,cAAc,2BAA2B,CAAA;AACzC,cAAc,4BAA4B,CAAA;AAC1C,cAAc,mBAAmB,CAAA;AACjC,cAAc,mBAAmB,CAAA;AACjC,cAAc,2BAA2B,CAAA;AACzC,cAAc,6BAA6B,CAAA;AAC3C,cAAc,wBAAwB,CAAA;AACtC,cAAc,oBAAoB,CAAA;AAClC,cAAc,sBAAsB,CAAA;AACpC,cAAc,qBAAqB,CAAA;AACnC,cAAc,4BAA4B,CAAA;AAC1C,cAAc,sBAAsB,CAAA;AACpC,cAAc,kCAAkC,CAAA;AAChD,cAAc,6BAA6B,CAAA;AAC3C,cAAc,qBAAqB,CAAA;AACnC,cAAc,yBAAyB,CAAA;AACvC,cAAc,yBAAyB,CAAA;AACvC,cAAc,4BAA4B,CAAA;AAC1C,cAAc,2BAA2B,CAAA;AACzC,cAAc,uBAAuB,CAAA;AACrC,cAAc,0BAA0B,CAAA;AACxC,cAAc,8BAA8B,CAAA;AAC5C,cAAc,0BAA0B,CAAA;AACxC,cAAc,yBAAyB,CAAA;AACvC,cAAc,kBAAkB,CAAA;AAChC,cAAc,wBAAwB,CAAA"}
|
|
1
|
+
{"version":3,"file":"browser.d.ts","sourceRoot":"","sources":["../../src/commands/browser.ts"],"names":[],"mappings":"AAAA,cAAc,iBAAiB,CAAA;AAC/B,cAAc,gBAAgB,CAAA;AAC9B,cAAc,qBAAqB,CAAA;AACnC,cAAc,sBAAsB,CAAA;AACpC,cAAc,mBAAmB,CAAA;AACjC,cAAc,uBAAuB,CAAA;AACrC,cAAc,sBAAsB,CAAA;AACpC,cAAc,oBAAoB,CAAA;AAClC,cAAc,4BAA4B,CAAA;AAC1C,cAAc,2BAA2B,CAAA;AACzC,cAAc,sBAAsB,CAAA;AACpC,cAAc,sBAAsB,CAAA;AACpC,cAAc,2BAA2B,CAAA;AACzC,cAAc,yBAAyB,CAAA;AACvC,cAAc,2BAA2B,CAAA;AACzC,cAAc,4BAA4B,CAAA;AAC1C,cAAc,mBAAmB,CAAA;AACjC,cAAc,mBAAmB,CAAA;AACjC,cAAc,2BAA2B,CAAA;AACzC,cAAc,6BAA6B,CAAA;AAC3C,cAAc,wBAAwB,CAAA;AACtC,cAAc,oBAAoB,CAAA;AAClC,cAAc,sBAAsB,CAAA;AACpC,cAAc,qBAAqB,CAAA;AACnC,cAAc,4BAA4B,CAAA;AAC1C,cAAc,sBAAsB,CAAA;AACpC,cAAc,kCAAkC,CAAA;AAChD,cAAc,6BAA6B,CAAA;AAC3C,cAAc,qBAAqB,CAAA;AACnC,cAAc,yBAAyB,CAAA;AACvC,cAAc,yBAAyB,CAAA;AACvC,cAAc,4BAA4B,CAAA;AAC1C,cAAc,2BAA2B,CAAA;AACzC,cAAc,uBAAuB,CAAA;AACrC,cAAc,0BAA0B,CAAA;AACxC,cAAc,8BAA8B,CAAA;AAC5C,cAAc,0BAA0B,CAAA;AACxC,cAAc,yBAAyB,CAAA;AACvC,cAAc,kBAAkB,CAAA;AAChC,cAAc,wBAAwB,CAAA"}
|
|
@@ -7,6 +7,7 @@ export * from './browser/custom$$.js';
|
|
|
7
7
|
export * from './browser/custom$.js';
|
|
8
8
|
export * from './browser/debug.js';
|
|
9
9
|
export * from './browser/deleteCookies.js';
|
|
10
|
+
export * from './browser/downloadFile.js';
|
|
10
11
|
export * from './browser/emulate.js';
|
|
11
12
|
export * from './browser/execute.js';
|
|
12
13
|
export * from './browser/executeAsync.js';
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import type { ChainablePromiseElement } from '../../types.js';
|
|
1
2
|
type DragAndDropOptions = {
|
|
2
3
|
duration?: number;
|
|
3
4
|
};
|
|
@@ -36,6 +37,6 @@ type ElementCoordinates = {
|
|
|
36
37
|
* @param {DragAndDropOptions=} options dragAndDrop command options
|
|
37
38
|
* @param {Number=} options.duration how long the drag should take place
|
|
38
39
|
*/
|
|
39
|
-
export declare function dragAndDrop(this: WebdriverIO.Element, target: WebdriverIO.Element | ElementCoordinates, { duration }?: DragAndDropOptions): Promise<void>;
|
|
40
|
+
export declare function dragAndDrop(this: WebdriverIO.Element, target: WebdriverIO.Element | ChainablePromiseElement | ElementCoordinates, { duration }?: DragAndDropOptions): Promise<void>;
|
|
40
41
|
export {};
|
|
41
42
|
//# sourceMappingURL=dragAndDrop.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"dragAndDrop.d.ts","sourceRoot":"","sources":["../../../src/commands/element/dragAndDrop.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"dragAndDrop.d.ts","sourceRoot":"","sources":["../../../src/commands/element/dragAndDrop.ts"],"names":[],"mappings":"AAKA,OAAO,KAAK,EAAE,uBAAuB,EAAE,MAAM,gBAAgB,CAAA;AAI7D,KAAK,kBAAkB,GAAG;IACtB,QAAQ,CAAC,EAAE,MAAM,CAAA;CACpB,CAAA;AAED,KAAK,kBAAkB,GAAG;IACtB,CAAC,CAAC,EAAE,MAAM,CAAA;IACV,CAAC,CAAC,EAAE,MAAM,CAAA;CACb,CAAA;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA8BG;AACH,wBAAsB,WAAW,CAC7B,IAAI,EAAE,WAAW,CAAC,OAAO,EACzB,MAAM,EAAE,WAAW,CAAC,OAAO,GAAG,uBAAuB,GAAG,kBAAkB,EAC1E,EAAE,QAAa,EAAE,GAAE,kBAAuB,iBAuD7C"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"isExisting.d.ts","sourceRoot":"","sources":["../../../src/commands/element/isExisting.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA8CG;AACH,wBAAsB,UAAU,CAAE,IAAI,EAAE,WAAW,CAAC,OAAO,
|
|
1
|
+
{"version":3,"file":"isExisting.d.ts","sourceRoot":"","sources":["../../../src/commands/element/isExisting.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA8CG;AACH,wBAAsB,UAAU,CAAE,IAAI,EAAE,WAAW,CAAC,OAAO,oBAwB1D"}
|
|
@@ -62,5 +62,7 @@ export async function isExisting() {
|
|
|
62
62
|
: this.isShadowElement
|
|
63
63
|
? this.shadow$$.bind(this.parent)
|
|
64
64
|
: this.parent.$$.bind(this.parent);
|
|
65
|
-
return command(this.selector)
|
|
65
|
+
return command(this.selector)
|
|
66
|
+
.getElements()
|
|
67
|
+
.then((res) => res.length > 0);
|
|
66
68
|
}
|
|
@@ -21,5 +21,5 @@
|
|
|
21
21
|
* @return {Element}
|
|
22
22
|
* @type utility
|
|
23
23
|
*/
|
|
24
|
-
export declare function nextElement(this: WebdriverIO.Element): import("../../types.js").ChainablePromiseElement
|
|
24
|
+
export declare function nextElement(this: WebdriverIO.Element): import("../../types.js").ChainablePromiseElement;
|
|
25
25
|
//# sourceMappingURL=nextElement.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"nextElement.d.ts","sourceRoot":"","sources":["../../../src/commands/element/nextElement.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;GAsBG;AAEH,wBAAgB,WAAW,CAAE,IAAI,EAAE,WAAW,CAAC,OAAO,
|
|
1
|
+
{"version":3,"file":"nextElement.d.ts","sourceRoot":"","sources":["../../../src/commands/element/nextElement.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;GAsBG;AAEH,wBAAgB,WAAW,CAAE,IAAI,EAAE,WAAW,CAAC,OAAO,oDAIrD"}
|
|
@@ -21,5 +21,5 @@
|
|
|
21
21
|
* @return {Element}
|
|
22
22
|
* @type utility
|
|
23
23
|
*/
|
|
24
|
-
export declare function parentElement(this: WebdriverIO.Element): import("../../types.js").ChainablePromiseElement
|
|
24
|
+
export declare function parentElement(this: WebdriverIO.Element): import("../../types.js").ChainablePromiseElement;
|
|
25
25
|
//# sourceMappingURL=parentElement.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"parentElement.d.ts","sourceRoot":"","sources":["../../../src/commands/element/parentElement.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;GAsBG;AACH,wBAAgB,aAAa,CAAE,IAAI,EAAE,WAAW,CAAC,OAAO,
|
|
1
|
+
{"version":3,"file":"parentElement.d.ts","sourceRoot":"","sources":["../../../src/commands/element/parentElement.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;GAsBG;AACH,wBAAgB,aAAa,CAAE,IAAI,EAAE,WAAW,CAAC,OAAO,oDAIvD"}
|
|
@@ -21,5 +21,5 @@
|
|
|
21
21
|
* @return {Element}
|
|
22
22
|
* @type utility
|
|
23
23
|
*/
|
|
24
|
-
export declare function previousElement(this: WebdriverIO.Element): import("../../types.js").ChainablePromiseElement
|
|
24
|
+
export declare function previousElement(this: WebdriverIO.Element): import("../../types.js").ChainablePromiseElement;
|
|
25
25
|
//# sourceMappingURL=previousElement.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"previousElement.d.ts","sourceRoot":"","sources":["../../../src/commands/element/previousElement.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;GAsBG;AACH,wBAAgB,eAAe,CAAE,IAAI,EAAE,WAAW,CAAC,OAAO,
|
|
1
|
+
{"version":3,"file":"previousElement.d.ts","sourceRoot":"","sources":["../../../src/commands/element/previousElement.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;GAsBG;AACH,wBAAgB,eAAe,CAAE,IAAI,EAAE,WAAW,CAAC,OAAO,oDAIzD"}
|
|
@@ -18,5 +18,5 @@
|
|
|
18
18
|
* @type utility
|
|
19
19
|
*
|
|
20
20
|
*/
|
|
21
|
-
export declare function shadow$$(this: WebdriverIO.Element, selector: string): Promise<WebdriverIO.ElementArray>;
|
|
21
|
+
export declare function shadow$$(this: WebdriverIO.Element, selector: string): Promise<WebdriverIO.ElementArray | import("../../types.js").ChainablePromiseArray>;
|
|
22
22
|
//# sourceMappingURL=shadow$$.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"shadow$$.d.ts","sourceRoot":"","sources":["../../../src/commands/element/shadow$$.ts"],"names":[],"mappings":"AAYA;;;;;;;;;;;;;;;;;;;GAmBG;AACH,wBAAsB,QAAQ,CAC1B,IAAI,EAAE,WAAW,CAAC,OAAO,EACzB,QAAQ,EAAE,MAAM,
|
|
1
|
+
{"version":3,"file":"shadow$$.d.ts","sourceRoot":"","sources":["../../../src/commands/element/shadow$$.ts"],"names":[],"mappings":"AAYA;;;;;;;;;;;;;;;;;;;GAmBG;AACH,wBAAsB,QAAQ,CAC1B,IAAI,EAAE,WAAW,CAAC,OAAO,EACzB,QAAQ,EAAE,MAAM,sFAiBnB"}
|
|
@@ -18,5 +18,5 @@
|
|
|
18
18
|
* @type utility
|
|
19
19
|
*
|
|
20
20
|
*/
|
|
21
|
-
export declare function shadow$(this: WebdriverIO.Element, selector: string): Promise<WebdriverIO.Element>;
|
|
21
|
+
export declare function shadow$(this: WebdriverIO.Element, selector: string): Promise<WebdriverIO.Element | import("../../types.js").ChainablePromiseElement>;
|
|
22
22
|
//# sourceMappingURL=shadow$.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"shadow$.d.ts","sourceRoot":"","sources":["../../../src/commands/element/shadow$.ts"],"names":[],"mappings":"AAUA;;;;;;;;;;;;;;;;;;;GAmBG;AACH,wBAAsB,OAAO,CACzB,IAAI,EAAE,WAAW,CAAC,OAAO,EACzB,QAAQ,EAAE,MAAM,
|
|
1
|
+
{"version":3,"file":"shadow$.d.ts","sourceRoot":"","sources":["../../../src/commands/element/shadow$.ts"],"names":[],"mappings":"AAUA;;;;;;;;;;;;;;;;;;;GAmBG;AACH,wBAAsB,OAAO,CACzB,IAAI,EAAE,WAAW,CAAC,OAAO,EACzB,QAAQ,EAAE,MAAM,mFAenB"}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
export {};
|
|
2
|
+
/**
|
|
3
|
+
* Sets up a redirect for a given mock. This allows you to redirect a request to another URL.
|
|
4
|
+
* Note: these redirects only apply to requests made by a script in the browser, not when calling the `url` command.
|
|
5
|
+
*
|
|
6
|
+
* <example>
|
|
7
|
+
:respond.js
|
|
8
|
+
it('redirects all my API request to my staging server', async () => {
|
|
9
|
+
const mock = await browser.mock('https://application.com/api/*')
|
|
10
|
+
mock.redirect('https://staging.application.com/api/*')
|
|
11
|
+
|
|
12
|
+
// is the same as
|
|
13
|
+
mock.request({ url: 'https://staging.application.com/api/*' })
|
|
14
|
+
|
|
15
|
+
// ...
|
|
16
|
+
})
|
|
17
|
+
* </example>
|
|
18
|
+
*
|
|
19
|
+
* @alias mock.request
|
|
20
|
+
* @param {string} url target resource to redirect requests to
|
|
21
|
+
*/
|
|
22
|
+
//# sourceMappingURL=redirect.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"redirect.d.ts","sourceRoot":"","sources":["../../../src/commands/mock/redirect.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;;;;;;GAmBG"}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
export {};
|
|
2
|
+
/**
|
|
3
|
+
* Sets up a redirect for a given mock. This allows you to redirect a request to another URL.
|
|
4
|
+
* Note: these redirects only apply to requests made by a script in the browser, not when calling the `url` command.
|
|
5
|
+
*
|
|
6
|
+
* <example>
|
|
7
|
+
:respond.js
|
|
8
|
+
it('redirects all my API request to my staging server', async () => {
|
|
9
|
+
const mock = await browser.mock('https://application.com/api/*')
|
|
10
|
+
mock.redirect('https://staging.application.com/api/*')
|
|
11
|
+
|
|
12
|
+
// is the same as
|
|
13
|
+
mock.request({ url: 'https://staging.application.com/api/*' })
|
|
14
|
+
|
|
15
|
+
// ...
|
|
16
|
+
})
|
|
17
|
+
* </example>
|
|
18
|
+
*
|
|
19
|
+
* @alias mock.request
|
|
20
|
+
* @param {string} url target resource to redirect requests to
|
|
21
|
+
*/
|
|
22
|
+
// actual implementation is located in packages/webdriverio/src/utils/interception
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
export {};
|
|
2
|
+
/**
|
|
3
|
+
* Allows you do modify requests the browser makes during the session. This can be useful for the following use cases:
|
|
4
|
+
*
|
|
5
|
+
* - validating if your application sends correct request payloads
|
|
6
|
+
* - passing through authorization headers to test protected resources
|
|
7
|
+
* - setting session cookies to test user authentication
|
|
8
|
+
* - modifying requests to test edge cases
|
|
9
|
+
*
|
|
10
|
+
* <example>
|
|
11
|
+
:respond.js
|
|
12
|
+
it('adds an auth header to my API requests', async () => {
|
|
13
|
+
const mock = await browser.mock('https://application.com/api', {
|
|
14
|
+
method: 'get'
|
|
15
|
+
})
|
|
16
|
+
|
|
17
|
+
mock.request({
|
|
18
|
+
headers: { 'Authorization': 'Bearer token' }
|
|
19
|
+
})
|
|
20
|
+
|
|
21
|
+
await browser.url('https://application.com')
|
|
22
|
+
// ...
|
|
23
|
+
})
|
|
24
|
+
* </example>
|
|
25
|
+
*
|
|
26
|
+
* @alias mock.request
|
|
27
|
+
* @param {MockOverwrite} overwrites payload to overwrite the response
|
|
28
|
+
* @param {Record<string, string> overwrites.header overwrite specific headers
|
|
29
|
+
* @param {Record<string, string> overwrites.cookies overwrite request cookies
|
|
30
|
+
* @param {string} overwrites.method overwrite request method
|
|
31
|
+
* @param {string} overwrites.url overwrite request url to initiate a redirect
|
|
32
|
+
* @param {MockResponseParams=} params additional respond parameters to overwrite
|
|
33
|
+
* @param {Object=} params.header overwrite specific headers
|
|
34
|
+
* @param {Number=} params.statusCode overwrite response status code
|
|
35
|
+
* @param {Boolean=} params.fetchResponse fetch real response before responding with mocked data
|
|
36
|
+
*/
|
|
37
|
+
//# sourceMappingURL=request.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"request.d.ts","sourceRoot":"","sources":["../../../src/commands/mock/request.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAkCG"}
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
export {};
|
|
2
|
+
/**
|
|
3
|
+
* Allows you do modify requests the browser makes during the session. This can be useful for the following use cases:
|
|
4
|
+
*
|
|
5
|
+
* - validating if your application sends correct request payloads
|
|
6
|
+
* - passing through authorization headers to test protected resources
|
|
7
|
+
* - setting session cookies to test user authentication
|
|
8
|
+
* - modifying requests to test edge cases
|
|
9
|
+
*
|
|
10
|
+
* <example>
|
|
11
|
+
:respond.js
|
|
12
|
+
it('adds an auth header to my API requests', async () => {
|
|
13
|
+
const mock = await browser.mock('https://application.com/api', {
|
|
14
|
+
method: 'get'
|
|
15
|
+
})
|
|
16
|
+
|
|
17
|
+
mock.request({
|
|
18
|
+
headers: { 'Authorization': 'Bearer token' }
|
|
19
|
+
})
|
|
20
|
+
|
|
21
|
+
await browser.url('https://application.com')
|
|
22
|
+
// ...
|
|
23
|
+
})
|
|
24
|
+
* </example>
|
|
25
|
+
*
|
|
26
|
+
* @alias mock.request
|
|
27
|
+
* @param {MockOverwrite} overwrites payload to overwrite the response
|
|
28
|
+
* @param {Record<string, string> overwrites.header overwrite specific headers
|
|
29
|
+
* @param {Record<string, string> overwrites.cookies overwrite request cookies
|
|
30
|
+
* @param {string} overwrites.method overwrite request method
|
|
31
|
+
* @param {string} overwrites.url overwrite request url to initiate a redirect
|
|
32
|
+
* @param {MockResponseParams=} params additional respond parameters to overwrite
|
|
33
|
+
* @param {Object=} params.header overwrite specific headers
|
|
34
|
+
* @param {Number=} params.statusCode overwrite response status code
|
|
35
|
+
* @param {Boolean=} params.fetchResponse fetch real response before responding with mocked data
|
|
36
|
+
*/
|
|
37
|
+
// actual implementation is located in packages/webdriverio/src/utils/interception
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
export {};
|
|
2
|
+
/**
|
|
3
|
+
* Only change request parameter once with given overwrite for the next request. You can call `requestOnce` multiple
|
|
4
|
+
* consecutive times and it will apply the overwrites in order. If you only use `requestOnce` and the resource is called
|
|
5
|
+
* more times a mock has been defined than it defaults back to the original resource.
|
|
6
|
+
*
|
|
7
|
+
* <example>
|
|
8
|
+
:respond.js
|
|
9
|
+
it('adds different auth headers to my API requests', async () => {
|
|
10
|
+
const mock = await browser.mock('https://application.com/api', {
|
|
11
|
+
method: 'get'
|
|
12
|
+
})
|
|
13
|
+
|
|
14
|
+
mock.requestOnce({
|
|
15
|
+
headers: { 'Authorization': 'Bearer token' }
|
|
16
|
+
})
|
|
17
|
+
mock.requestOnce({
|
|
18
|
+
headers: { 'Authorization': 'Another bearer token' }
|
|
19
|
+
})
|
|
20
|
+
|
|
21
|
+
await browser.url('https://application.com')
|
|
22
|
+
// ...
|
|
23
|
+
})
|
|
24
|
+
* </example>
|
|
25
|
+
*
|
|
26
|
+
* @alias mock.requestOnce
|
|
27
|
+
* @param {MockOverwrite} overwrites payload to overwrite the response
|
|
28
|
+
* @param {Record<string, string> overwrites.header overwrite specific headers
|
|
29
|
+
* @param {Record<string, string> overwrites.cookies overwrite request cookies
|
|
30
|
+
* @param {string} overwrites.method overwrite request method
|
|
31
|
+
* @param {string} overwrites.url overwrite request url to initiate a redirect
|
|
32
|
+
* @param {MockResponseParams=} params additional respond parameters to overwrite
|
|
33
|
+
* @param {Object=} params.header overwrite specific headers
|
|
34
|
+
* @param {Number=} params.statusCode overwrite response status code
|
|
35
|
+
* @param {Boolean=} params.fetchResponse fetch real response before responding with mocked data
|
|
36
|
+
*/
|
|
37
|
+
//# sourceMappingURL=requestOnce.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"requestOnce.d.ts","sourceRoot":"","sources":["../../../src/commands/mock/requestOnce.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAkCG"}
|