added all files to project

This commit is contained in:
2022-03-10 10:36:59 +01:00
parent 09dd957b33
commit 46a936d7de
25351 changed files with 3883356 additions and 0 deletions
+49
View File
@@ -0,0 +1,49 @@
WebdriverIO
===========
> Next-gen browser and mobile automation test framework for Node.js
This package provides an easy to manage API and a lot of syntactical sugar on top of the WebDriver specification. You can use WebdriverIO as a standalone package or via a testrunner using [`@wdio/cli`](https://webdriver.io/docs/clioptions.html). WebdriverIO allows to run tests locally using the WebDriver or Chrome DevTools protocol as well as remote user agents using cloud providers like [Sauce Labs](https://saucelabs.com/).
## Installation
You can install WebdriverIO via NPM:
```sh
$ npm install webdriverio
```
## Usage
WebdriverIO by default uses Puppeteer to automate a browser like Chrome, Firefox or Chromium Edge. So if you have Chrome installed, the following script should start a browser for you and get the title of the page:
```js
import { remote } from 'webdriverio'
let browser
;(async () => {
browser = await remote({
capabilities: { browserName: 'chrome' }
})
await browser.navigateTo('https://www.google.com/ncr')
const searchInput = await browser.$('#lst-ib')
await searchInput.setValue('WebdriverIO')
const searchBtn = await browser.$('input[value="Google Search"]')
await searchBtn.click()
console.log(await browser.getTitle()) // outputs "WebdriverIO - Google Search"
await browser.deleteSession()
})().catch((err) => {
console.error(err)
return browser.deleteSession()
})
```
See the raw [protocol example](https://www.npmjs.com/package/webdriver#example) using the `webdriver` package to get a glance on the differences.
For more information on [options](https://webdriver.io/docs/options.html#webdriver-options), [multiremote usage](https://webdriver.io/docs/multiremote.html) or integration into [cloud services](https://webdriver.io/docs/cloudservices.html) please check out the [docs](https://webdriver.io/docs/gettingstarted.html). If you want to use WebdriverIO for testing purposes, it is recommended to use the [WebdriverIO Testrunner](https://webdriver.io/docs/clioptions.html).
+32
View File
@@ -0,0 +1,32 @@
export declare const $$: any;
export declare const $: any;
export declare const call: any;
export declare const custom$$: any;
export declare const custom$: any;
export declare const debug: any;
export declare const deleteCookies: any;
export declare const execute: any;
export declare const executeAsync: any;
export declare const getCookies: any;
export declare const getPuppeteer: any;
export declare const getWindowSize: any;
export declare const keys: any;
export declare const mock: any;
export declare const newWindow: any;
export declare const pause: any;
export declare const react$$: any;
export declare const react$: any;
export declare const reloadSession: any;
export declare const savePDF: any;
export declare const saveRecordingScreen: any;
export declare const saveScreenshot: any;
export declare const setCookies: any;
export declare const setTimeout: any;
export declare const setWindowSize: any;
export declare const switchWindow: any;
export declare const throttle: any;
export declare const touchAction: any;
export declare const uploadFile: any;
export declare const url: any;
export declare const waitUntil: any;
//# sourceMappingURL=browser.d.ts.map
+1
View File
@@ -0,0 +1 @@
{"version":3,"file":"browser.d.ts","sourceRoot":"","sources":["../../src/commands/browser.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,EAAE,KAAkC,CAAA;AACjD,eAAO,MAAM,CAAC,KAAiC,CAAA;AAC/C,eAAO,MAAM,IAAI,KAAoC,CAAA;AACrD,eAAO,MAAM,QAAQ,KAAwC,CAAA;AAC7D,eAAO,MAAM,OAAO,KAAuC,CAAA;AAC3D,eAAO,MAAM,KAAK,KAAqC,CAAA;AACvD,eAAO,MAAM,aAAa,KAA6C,CAAA;AACvE,eAAO,MAAM,OAAO,KAAuC,CAAA;AAC3D,eAAO,MAAM,YAAY,KAA4C,CAAA;AACrE,eAAO,MAAM,UAAU,KAA0C,CAAA;AACjE,eAAO,MAAM,YAAY,KAA4C,CAAA;AACrE,eAAO,MAAM,aAAa,KAA6C,CAAA;AACvE,eAAO,MAAM,IAAI,KAAoC,CAAA;AACrD,eAAO,MAAM,IAAI,KAAoC,CAAA;AACrD,eAAO,MAAM,SAAS,KAAyC,CAAA;AAC/D,eAAO,MAAM,KAAK,KAAqC,CAAA;AACvD,eAAO,MAAM,OAAO,KAAuC,CAAA;AAC3D,eAAO,MAAM,MAAM,KAAsC,CAAA;AACzD,eAAO,MAAM,aAAa,KAA6C,CAAA;AACvE,eAAO,MAAM,OAAO,KAAuC,CAAA;AAC3D,eAAO,MAAM,mBAAmB,KAAmD,CAAA;AACnF,eAAO,MAAM,cAAc,KAA8C,CAAA;AACzE,eAAO,MAAM,UAAU,KAA0C,CAAA;AACjE,eAAO,MAAM,UAAU,KAA0C,CAAA;AACjE,eAAO,MAAM,aAAa,KAA6C,CAAA;AACvE,eAAO,MAAM,YAAY,KAA4C,CAAA;AACrE,eAAO,MAAM,QAAQ,KAAwC,CAAA;AAC7D,eAAO,MAAM,WAAW,KAA2C,CAAA;AACnE,eAAO,MAAM,UAAU,KAA0C,CAAA;AACjE,eAAO,MAAM,GAAG,KAAmC,CAAA;AACnD,eAAO,MAAM,SAAS,KAAyC,CAAA"}
+34
View File
@@ -0,0 +1,34 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.waitUntil = exports.url = exports.uploadFile = exports.touchAction = exports.throttle = exports.switchWindow = exports.setWindowSize = exports.setTimeout = exports.setCookies = exports.saveScreenshot = exports.saveRecordingScreen = exports.savePDF = exports.reloadSession = exports.react$ = exports.react$$ = exports.pause = exports.newWindow = exports.mock = exports.keys = exports.getWindowSize = exports.getPuppeteer = exports.getCookies = exports.executeAsync = exports.execute = exports.deleteCookies = exports.debug = exports.custom$ = exports.custom$$ = exports.call = exports.$ = exports.$$ = void 0;
exports.$$ = require('./browser/$$').default;
exports.$ = require('./browser/$').default;
exports.call = require('./browser/call').default;
exports.custom$$ = require('./browser/custom$$').default;
exports.custom$ = require('./browser/custom$').default;
exports.debug = require('./browser/debug').default;
exports.deleteCookies = require('./browser/deleteCookies').default;
exports.execute = require('./browser/execute').default;
exports.executeAsync = require('./browser/executeAsync').default;
exports.getCookies = require('./browser/getCookies').default;
exports.getPuppeteer = require('./browser/getPuppeteer').default;
exports.getWindowSize = require('./browser/getWindowSize').default;
exports.keys = require('./browser/keys').default;
exports.mock = require('./browser/mock').default;
exports.newWindow = require('./browser/newWindow').default;
exports.pause = require('./browser/pause').default;
exports.react$$ = require('./browser/react$$').default;
exports.react$ = require('./browser/react$').default;
exports.reloadSession = require('./browser/reloadSession').default;
exports.savePDF = require('./browser/savePDF').default;
exports.saveRecordingScreen = require('./browser/saveRecordingScreen').default;
exports.saveScreenshot = require('./browser/saveScreenshot').default;
exports.setCookies = require('./browser/setCookies').default;
exports.setTimeout = require('./browser/setTimeout').default;
exports.setWindowSize = require('./browser/setWindowSize').default;
exports.switchWindow = require('./browser/switchWindow').default;
exports.throttle = require('./browser/throttle').default;
exports.touchAction = require('./browser/touchAction').default;
exports.uploadFile = require('./browser/uploadFile').default;
exports.url = require('./browser/url').default;
exports.waitUntil = require('./browser/waitUntil').default;
+5
View File
@@ -0,0 +1,5 @@
/// <reference types="webdriverio/webdriverio-core" />
/// <reference types="webdriverio" />
/// <reference types="@wdio/cucumber-framework" />
export default function $$(this: WebdriverIO.BrowserObject, selector: string): Promise<import("webdriverio").Element[]>;
//# sourceMappingURL=$$.d.ts.map
+1
View File
@@ -0,0 +1 @@
{"version":3,"file":"$$.d.ts","sourceRoot":"","sources":["../../../src/commands/browser/$$.ts"],"names":[],"mappings":";;;AA6CA,wBAA8B,EAAE,CAC5B,IAAI,EAAE,WAAW,CAAC,aAAa,EAC/B,QAAQ,EAAE,MAAM,4CAKnB"}
+10
View File
@@ -0,0 +1,10 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
const utils_1 = require("../../utils");
const getElementObject_1 = require("../../utils/getElementObject");
async function $$(selector) {
const res = await utils_1.findElements.call(this, selector);
const elements = await getElementObject_1.getElements.call(this, selector, res);
return utils_1.enhanceElementsArray(elements, this, selector);
}
exports.default = $$;
+6
View File
@@ -0,0 +1,6 @@
/// <reference types="webdriverio/webdriverio-core" />
/// <reference types="webdriverio" />
/// <reference types="@wdio/cucumber-framework" />
import type { Selector } from '../../types';
export default function $(this: WebdriverIO.BrowserObject, selector: Selector): Promise<import("webdriverio").Element>;
//# sourceMappingURL=$.d.ts.map
+1
View File
@@ -0,0 +1 @@
{"version":3,"file":"$.d.ts","sourceRoot":"","sources":["../../../src/commands/browser/$.ts"],"names":[],"mappings":";;;AAoDA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAA;AAE3C,wBAA8B,CAAC,CAC3B,IAAI,EAAE,WAAW,CAAC,aAAa,EAC/B,QAAQ,EAAE,QAAQ,0CAYrB"}
+13
View File
@@ -0,0 +1,13 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
const utils_1 = require("../../utils");
const getElementObject_1 = require("../../utils/getElementObject");
const constants_1 = require("../../constants");
async function $(selector) {
if (typeof selector === 'object' && typeof selector[constants_1.ELEMENT_KEY] === 'string') {
return getElementObject_1.getElement.call(this, undefined, selector);
}
const res = await utils_1.findElement.call(this, selector);
return getElementObject_1.getElement.call(this, selector, res);
}
exports.default = $;
+1
View File
@@ -0,0 +1 @@
//# sourceMappingURL=addCommand.d.ts.map
+1
View File
@@ -0,0 +1 @@
{"version":3,"file":"addCommand.d.ts","sourceRoot":"","sources":["../../../src/commands/browser/addCommand.ts"],"names":[],"mappings":""}
+1
View File
@@ -0,0 +1 @@
"use strict";
+2
View File
@@ -0,0 +1,2 @@
export default function call<T>(fn: () => T): T;
//# sourceMappingURL=call.d.ts.map
+1
View File
@@ -0,0 +1 @@
{"version":3,"file":"call.d.ts","sourceRoot":"","sources":["../../../src/commands/browser/call.ts"],"names":[],"mappings":"AAuCA,MAAM,CAAC,OAAO,UAAU,IAAI,CAAC,CAAC,EAAG,EAAE,EAAE,MAAM,CAAC,KAM3C"}
+9
View File
@@ -0,0 +1,9 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
function call(fn) {
if (typeof fn === 'function') {
return fn();
}
throw new Error('Command argument for "call" needs to be a function');
}
exports.default = call;
+5
View File
@@ -0,0 +1,5 @@
/// <reference types="webdriverio/webdriverio-core" />
/// <reference types="webdriverio" />
/// <reference types="@wdio/cucumber-framework" />
export default function custom$$(this: WebdriverIO.BrowserObject, strategyName: string, ...strategyArguments: any[]): Promise<import("webdriverio").ElementArray>;
//# sourceMappingURL=custom$$.d.ts.map
+1
View File
@@ -0,0 +1 @@
{"version":3,"file":"custom$$.d.ts","sourceRoot":"","sources":["../../../src/commands/browser/custom$$.ts"],"names":[],"mappings":";;;AA4BA,wBAA8B,QAAQ,CAClC,IAAI,EAAE,WAAW,CAAC,aAAa,EAC/B,YAAY,EAAE,MAAM,EACpB,GAAG,iBAAiB,EAAE,GAAG,EAAE,+CA0B9B"}
+19
View File
@@ -0,0 +1,19 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
const utils_1 = require("../../utils");
const getElementObject_1 = require("../../utils/getElementObject");
const constants_1 = require("../../constants");
async function custom$$(strategyName, ...strategyArguments) {
const strategy = this.strategies.get(strategyName);
if (!strategy) {
throw Error('No strategy found for ' + strategyName);
}
let res = await this.execute(strategy, ...strategyArguments);
if (!Array.isArray(res)) {
res = [res];
}
res = res.filter(el => !!el && typeof el[constants_1.ELEMENT_KEY] === 'string');
const elements = res.length ? await getElementObject_1.getElements.call(this, strategy.toString(), res) : [];
return utils_1.enhanceElementsArray(elements, this, strategyName, 'custom$$', [strategyArguments]);
}
exports.default = custom$$;
+5
View File
@@ -0,0 +1,5 @@
/// <reference types="webdriverio/webdriverio-core" />
/// <reference types="webdriverio" />
/// <reference types="@wdio/cucumber-framework" />
export default function custom$(this: WebdriverIO.BrowserObject, strategyName: string, ...strategyArguments: any[]): Promise<import("webdriverio").Element>;
//# sourceMappingURL=custom$.d.ts.map
+1
View File
@@ -0,0 +1 @@
{"version":3,"file":"custom$.d.ts","sourceRoot":"","sources":["../../../src/commands/browser/custom$.ts"],"names":[],"mappings":";;;AA2BA,wBAA8B,OAAO,CACjC,IAAI,EAAE,WAAW,CAAC,aAAa,EAC/B,YAAY,EAAE,MAAM,EACpB,GAAG,iBAAiB,EAAE,GAAG,EAAE,0CA2B9B"}
+19
View File
@@ -0,0 +1,19 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
const getElementObject_1 = require("../../utils/getElementObject");
const constants_1 = require("../../constants");
async function custom$(strategyName, ...strategyArguments) {
const strategy = this.strategies.get(strategyName);
if (!strategy) {
throw Error('No strategy found for ' + strategyName);
}
let res = await this.execute(strategy, ...strategyArguments);
if (Array.isArray(res)) {
res = res[0];
}
if (res && typeof res[constants_1.ELEMENT_KEY] === 'string') {
return await getElementObject_1.getElement.call(this, strategy.toString(), res);
}
throw Error('Your locator strategy script must return an element');
}
exports.default = custom$;
+4
View File
@@ -0,0 +1,4 @@
/// <reference types="webdriverio/webdriverio-core" />
/// <reference types="webdriverio" />
export default function debug(this: WebdriverIO.BrowserObject, commandTimeout?: number): Promise<unknown>;
//# sourceMappingURL=debug.d.ts.map
+1
View File
@@ -0,0 +1 @@
{"version":3,"file":"debug.d.ts","sourceRoot":"","sources":["../../../src/commands/browser/debug.ts"],"names":[],"mappings":";;AAkCA,MAAM,CAAC,OAAO,UAAU,KAAK,CACzB,IAAI,EAAE,WAAW,CAAC,aAAa,EAC/B,cAAc,SAAO,oBAgFxB"}
+64
View File
@@ -0,0 +1,64 @@
"use strict";
var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
const serialize_error_1 = require("serialize-error");
const repl_1 = __importDefault(require("@wdio/repl"));
function debug(commandTimeout = 5000) {
const repl = new repl_1.default();
const { introMessage } = repl_1.default;
if (!process.env.WDIO_WORKER || typeof process.send !== 'function') {
console.log(repl_1.default.introMessage);
const context = {
browser: this,
driver: this,
$: this.$.bind(this),
$$: this.$$.bind(this)
};
return repl.start(context);
}
process._debugProcess(process.pid);
process.send({
origin: 'debugger',
name: 'start',
params: { commandTimeout, introMessage }
});
let commandResolve = () => { };
process.on('message', (m) => {
if (m.origin !== 'debugger') {
return;
}
if (m.name === 'stop') {
process._debugEnd(process.pid);
return commandResolve();
}
if (m.name === 'eval') {
repl.eval(m.content.cmd, global, undefined, (err, result) => {
if (typeof process.send !== 'function') {
return;
}
if (err) {
process.send({
origin: 'debugger',
name: 'result',
params: {
error: true,
...serialize_error_1.serializeError(err)
}
});
}
if (typeof result === 'function') {
result = `[Function: ${result.name}]`;
}
process.send({
origin: 'debugger',
name: 'result',
params: { result }
});
});
}
});
return new Promise((resolve) => (commandResolve = resolve));
}
exports.default = debug;
+4
View File
@@ -0,0 +1,4 @@
/// <reference types="webdriverio/webdriverio-core" />
/// <reference types="webdriverio" />
export default function deleteCookies(this: WebdriverIO.BrowserObject, names?: string | string[]): Promise<void> | Promise<void[]>;
//# sourceMappingURL=deleteCookies.d.ts.map
@@ -0,0 +1 @@
{"version":3,"file":"deleteCookies.d.ts","sourceRoot":"","sources":["../../../src/commands/browser/deleteCookies.ts"],"names":[],"mappings":";;AA4CA,MAAM,CAAC,OAAO,UAAU,aAAa,CACjC,IAAI,EAAE,WAAW,CAAC,aAAa,EAC/B,KAAK,CAAC,EAAE,MAAM,GAAG,MAAM,EAAE,mCAa5B"}
+13
View File
@@ -0,0 +1,13 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
function deleteCookies(names) {
if (names === undefined) {
return this.deleteAllCookies();
}
const namesList = Array.isArray(names) ? names : [names];
if (namesList.every(obj => typeof obj !== 'string')) {
return Promise.reject(new Error('Invalid input (see https://webdriver.io/docs/api/browser/deleteCookies.html for documentation.'));
}
return Promise.all(namesList.map(name => this.deleteCookie(name)));
}
exports.default = deleteCookies;
+4
View File
@@ -0,0 +1,4 @@
/// <reference types="webdriverio/webdriverio-core" />
/// <reference types="webdriverio" />
export default function execute(this: WebdriverIO.BrowserObject, script: string | Function, ...args: any[]): Promise<any>;
//# sourceMappingURL=execute.d.ts.map
+1
View File
@@ -0,0 +1 @@
{"version":3,"file":"execute.d.ts","sourceRoot":"","sources":["../../../src/commands/browser/execute.ts"],"names":[],"mappings":";;AAqCA,MAAM,CAAC,OAAO,UAAU,OAAO,CAC3B,IAAI,EAAE,WAAW,CAAC,aAAa,EAC/B,MAAM,EAAE,MAAM,GAAG,QAAQ,EACzB,GAAG,IAAI,EAAE,GAAG,EAAE,gBAkBjB"}
+13
View File
@@ -0,0 +1,13 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
const utils_1 = require("../../utils");
function execute(script, ...args) {
if ((typeof script !== 'string' && typeof script !== 'function')) {
throw new Error('number or type of arguments don\'t agree with execute protocol command');
}
if (typeof script === 'function') {
script = `return (${script}).apply(null, arguments)`;
}
return this.executeScript(script, utils_1.verifyArgsAndStripIfElement(args));
}
exports.default = execute;
+4
View File
@@ -0,0 +1,4 @@
/// <reference types="webdriverio/webdriverio-core" />
/// <reference types="webdriverio" />
export default function executeAsync(this: WebdriverIO.BrowserObject, script: string | Function, ...args: any[]): Promise<any>;
//# sourceMappingURL=executeAsync.d.ts.map
@@ -0,0 +1 @@
{"version":3,"file":"executeAsync.d.ts","sourceRoot":"","sources":["../../../src/commands/browser/executeAsync.ts"],"names":[],"mappings":";;AA6CA,MAAM,CAAC,OAAO,UAAU,YAAY,CAChC,IAAI,EAAE,WAAW,CAAC,aAAa,EAC/B,MAAM,EAAE,MAAM,GAAG,QAAQ,EACzB,GAAG,IAAI,EAAE,GAAG,EAAE,gBAkBjB"}
+13
View File
@@ -0,0 +1,13 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
const utils_1 = require("../../utils");
function executeAsync(script, ...args) {
if ((typeof script !== 'string' && typeof script !== 'function')) {
throw new Error('number or type of arguments don\'t agree with execute protocol command');
}
if (typeof script === 'function') {
script = `return (${script}).apply(null, arguments)`;
}
return this.executeAsyncScript(script, utils_1.verifyArgsAndStripIfElement(args));
}
exports.default = executeAsync;
+5
View File
@@ -0,0 +1,5 @@
/// <reference types="webdriverio/webdriverio-core" />
/// <reference types="webdriverio" />
/// <reference types="webdriver" />
export default function getCookies(this: WebdriverIO.BrowserObject, names?: string | string[]): Promise<WebDriver.Cookie[]>;
//# sourceMappingURL=getCookies.d.ts.map
+1
View File
@@ -0,0 +1 @@
{"version":3,"file":"getCookies.d.ts","sourceRoot":"","sources":["../../../src/commands/browser/getCookies.ts"],"names":[],"mappings":";;;AAgCA,wBAA8B,UAAU,CACpC,IAAI,EAAE,WAAW,CAAC,aAAa,EAC/B,KAAK,CAAC,EAAE,MAAM,GAAG,MAAM,EAAE,+BAc5B"}
+14
View File
@@ -0,0 +1,14 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
async function getCookies(names) {
if (names === undefined) {
return this.getAllCookies();
}
const namesList = Array.isArray(names) ? names : [names];
if (namesList.every(obj => typeof obj !== 'string')) {
throw new Error('Invalid input (see https://webdriver.io/docs/api/browser/getCookies.html for documentation.');
}
const allCookies = await this.getAllCookies();
return allCookies.filter(cookie => namesList.includes(cookie.name));
}
exports.default = getCookies;
+5
View File
@@ -0,0 +1,5 @@
/// <reference types="webdriverio/webdriverio-core" />
/// <reference types="webdriverio" />
import puppeteer from 'puppeteer-core';
export default function getPuppeteer(this: WebdriverIO.BrowserObject): Promise<puppeteer.Browser>;
//# sourceMappingURL=getPuppeteer.d.ts.map
@@ -0,0 +1 @@
{"version":3,"file":"getPuppeteer.d.ts","sourceRoot":"","sources":["../../../src/commands/browser/getPuppeteer.ts"],"names":[],"mappings":";;AASA,OAAO,SAAS,MAAM,gBAAgB,CAAA;AAGtC,wBAA8B,YAAY,CAAE,IAAI,EAAE,WAAW,CAAC,aAAa,8BAsD1E"}
+45
View File
@@ -0,0 +1,45 @@
"use strict";
var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
const puppeteer_core_1 = __importDefault(require("puppeteer-core"));
const constants_1 = require("../../constants");
async function getPuppeteer() {
var _a, _b, _c;
if (this.puppeteer) {
return this.puppeteer;
}
const chromiumOptions = this.capabilities['goog:chromeOptions'] || this.capabilities['ms:edgeOptions'];
if (chromiumOptions && chromiumOptions.debuggerAddress) {
this.puppeteer = await puppeteer_core_1.default.connect({
browserURL: `http://${chromiumOptions.debuggerAddress}`,
defaultViewport: null
});
return this.puppeteer;
}
if (((_a = this.capabilities.browserName) === null || _a === void 0 ? void 0 : _a.toLowerCase()) === 'firefox') {
if (!this.capabilities.browserVersion) {
throw new Error('Can\'t find "browserVersion" in capabilities');
}
const majorVersion = parseInt(this.capabilities.browserVersion.split('.').shift() || '', 10);
if (majorVersion >= 79) {
const ffOptions = this.capabilities['moz:firefoxOptions'];
const ffArgs = (_b = this.requestedCapabilities['moz:firefoxOptions']) === null || _b === void 0 ? void 0 : _b.args;
const rdPort = ffOptions && ffOptions.debuggerAddress
? ffOptions.debuggerAddress
: (_c = ffArgs === null || ffArgs === void 0 ? void 0 : ffArgs[ffArgs.findIndex((arg) => arg === constants_1.FF_REMOTE_DEBUG_ARG) + 1]) !== null && _c !== void 0 ? _c : null;
if (!rdPort) {
throw new Error('Could\'t find remote debug port in Firefox options');
}
this.puppeteer = await puppeteer_core_1.default.connect({
browserURL: `http://localhost:${rdPort}`,
defaultViewport: null
});
return this.puppeteer;
}
}
throw new Error('Using DevTools capabilities is not supported for this session. ' +
'This feature is only supported for local testing on Chrome, Firefox and Chromium Edge.');
}
exports.default = getPuppeteer;
+9
View File
@@ -0,0 +1,9 @@
/// <reference types="webdriverio/webdriverio-core" />
/// <reference types="webdriverio" />
interface BrowserSize {
width: number;
height: number;
}
export default function getWindowSize(this: WebdriverIO.BrowserObject): Promise<BrowserSize>;
export {};
//# sourceMappingURL=getWindowSize.d.ts.map
@@ -0,0 +1 @@
{"version":3,"file":"getWindowSize.d.ts","sourceRoot":"","sources":["../../../src/commands/browser/getWindowSize.ts"],"names":[],"mappings":";;AAqBA,UAAU,WAAW;IACjB,KAAK,EAAE,MAAM,CAAA;IACb,MAAM,EAAE,MAAM,CAAA;CACjB;AAED,wBAA8B,aAAa,CAAC,IAAI,EAAE,WAAW,CAAC,aAAa,wBAS1E"}
+12
View File
@@ -0,0 +1,12 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
const utils_1 = require("../../utils");
async function getWindowSize() {
const browser = utils_1.getBrowserObject(this);
if (!browser.isW3C) {
return browser._getWindowSize();
}
const { width, height } = await browser.getWindowRect();
return { width, height };
}
exports.default = getWindowSize;
+4
View File
@@ -0,0 +1,4 @@
/// <reference types="webdriverio/webdriverio-core" />
/// <reference types="webdriverio" />
export default function keys(this: WebdriverIO.BrowserObject, value: string | string[]): Promise<void>;
//# sourceMappingURL=keys.d.ts.map
+1
View File
@@ -0,0 +1 @@
{"version":3,"file":"keys.d.ts","sourceRoot":"","sources":["../../../src/commands/browser/keys.ts"],"names":[],"mappings":";;AA8BA,MAAM,CAAC,OAAO,UAAU,IAAI,CACxB,IAAI,EAAE,WAAW,CAAC,aAAa,EAC/B,KAAK,EAAE,MAAM,GAAG,MAAM,EAAE,iBAoC3B"}
+29
View File
@@ -0,0 +1,29 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
const utils_1 = require("../../utils");
function keys(value) {
let keySequence = [];
if (typeof value === 'string') {
keySequence = utils_1.checkUnicode(value, this.isDevTools);
}
else if (Array.isArray(value)) {
const charArray = value;
for (const charSet of charArray) {
keySequence = keySequence.concat(utils_1.checkUnicode(charSet, this.isDevTools));
}
}
else {
throw new Error('"keys" command requires a string or array of strings as parameter');
}
if (!this.isW3C) {
return this.sendKeys(keySequence);
}
const keyDownActions = keySequence.map((value) => ({ type: 'keyDown', value }));
const keyUpActions = keySequence.map((value) => ({ type: 'keyUp', value }));
return this.performActions([{
type: 'key',
id: 'keyboard',
actions: [...keyDownActions, ...keyUpActions]
}]).then(() => this.releaseActions());
}
exports.default = keys;
+5
View File
@@ -0,0 +1,5 @@
/// <reference types="webdriverio/webdriverio-core" />
/// <reference types="webdriverio" />
import type Interception from '../../utils/interception/index';
export default function mock(this: WebdriverIO.BrowserObject, url: string, filterOptions?: WebdriverIO.MockFilterOptions): Promise<Interception>;
//# sourceMappingURL=mock.d.ts.map
+1
View File
@@ -0,0 +1 @@
{"version":3,"file":"mock.d.ts","sourceRoot":"","sources":["../../../src/commands/browser/mock.ts"],"names":[],"mappings":";;AAiGA,OAAO,KAAK,YAAY,MAAM,gCAAgC,CAAA;AAO9D,wBAA8B,IAAI,CAC9B,IAAI,EAAE,WAAW,CAAC,aAAa,EAC/B,GAAG,EAAE,MAAM,EACX,aAAa,CAAC,EAAE,WAAW,CAAC,iBAAiB,GAC9C,OAAO,CAAC,YAAY,CAAC,CAwDvB"}
+46
View File
@@ -0,0 +1,46 @@
"use strict";
var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
const devtools_1 = __importDefault(require("../../utils/interception/devtools"));
const webdriver_1 = __importDefault(require("../../utils/interception/webdriver"));
const utils_1 = require("../../utils");
const SESSION_MOCKS = {};
async function mock(url, filterOptions) {
const NetworkInterception = this.isSauce ? webdriver_1.default : devtools_1.default;
if (!this.isSauce) {
await this.getPuppeteer();
}
const browser = utils_1.getBrowserObject(this);
const handle = await browser.getWindowHandle();
if (!SESSION_MOCKS[handle]) {
SESSION_MOCKS[handle] = new Set();
}
if (SESSION_MOCKS[handle].size === 0 && !this.isSauce) {
const pages = await this.puppeteer.pages();
let page;
for (let i = 0; i < pages.length && !page; i++) {
const isHidden = await pages[i].evaluate(() => document.hidden);
if (!isHidden) {
page = pages[i];
}
}
if (!page) {
page = pages[0];
}
const client = await page.target().createCDPSession();
await client.send('Fetch.enable', {
patterns: [{ requestStage: 'Request' }, { requestStage: 'Response' }]
});
client.on('Fetch.requestPaused', NetworkInterception
.handleRequestInterception(client, SESSION_MOCKS[handle]));
}
const networkInterception = new NetworkInterception(url, filterOptions, browser);
SESSION_MOCKS[handle].add(networkInterception);
if (this.isSauce) {
await networkInterception.init();
}
return networkInterception;
}
exports.default = mock;
+4
View File
@@ -0,0 +1,4 @@
/// <reference types="webdriverio/webdriverio-core" />
/// <reference types="webdriverio" />
export default function newWindow(this: WebdriverIO.BrowserObject, url: string, { windowName, windowFeatures }?: WebdriverIO.NewWindowOptions): Promise<string>;
//# sourceMappingURL=newWindow.d.ts.map
+1
View File
@@ -0,0 +1 @@
{"version":3,"file":"newWindow.d.ts","sourceRoot":"","sources":["../../../src/commands/browser/newWindow.ts"],"names":[],"mappings":";;AAsCA,wBAA8B,SAAS,CACnC,IAAI,EAAE,WAAW,CAAC,aAAa,EAC/B,GAAG,EAAE,MAAM,EACX,EAAE,UAAyB,EAAE,cAAmB,EAAE,GAAE,WAAW,CAAC,gBAAqB,mBA2BxF"}
+23
View File
@@ -0,0 +1,23 @@
"use strict";
var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
const newWindow_1 = __importDefault(require("../../scripts/newWindow"));
async function newWindow(url, { windowName = 'New Window', windowFeatures = '' } = {}) {
if (typeof url !== 'string') {
throw new Error('number or type of arguments don\'t agree with newWindow command');
}
if (this.isMobile) {
throw new Error('newWindow command is not supported on mobile platforms');
}
await this.execute(newWindow_1.default, url, windowName, windowFeatures);
const tabs = await this.getWindowHandles();
const newTab = tabs.pop();
if (!newTab) {
throw new Error('No window handle was found to switch to');
}
await this.switchToWindow(newTab);
return newTab;
}
exports.default = newWindow;
@@ -0,0 +1 @@
//# sourceMappingURL=overwriteCommand.d.ts.map
@@ -0,0 +1 @@
{"version":3,"file":"overwriteCommand.d.ts","sourceRoot":"","sources":["../../../src/commands/browser/overwriteCommand.ts"],"names":[],"mappings":""}
+1
View File
@@ -0,0 +1 @@
"use strict";
+4
View File
@@ -0,0 +1,4 @@
/// <reference types="webdriverio/webdriverio-core" />
/// <reference types="webdriverio" />
export default function pause(this: WebdriverIO.BrowserObject, milliseconds?: number): Promise<unknown>;
//# sourceMappingURL=pause.d.ts.map
+1
View File
@@ -0,0 +1 @@
{"version":3,"file":"pause.d.ts","sourceRoot":"","sources":["../../../src/commands/browser/pause.ts"],"names":[],"mappings":";;AAsBA,MAAM,CAAC,OAAO,UAAU,KAAK,CACzB,IAAI,EAAE,WAAW,CAAC,aAAa,EAC/B,YAAY,SAAO,oBAGtB"}
+6
View File
@@ -0,0 +1,6 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
function pause(milliseconds = 1000) {
return new Promise((resolve) => setTimeout(resolve, milliseconds));
}
exports.default = pause;
+5
View File
@@ -0,0 +1,5 @@
/// <reference types="webdriverio/webdriverio-core" />
/// <reference types="webdriverio" />
/// <reference types="@wdio/cucumber-framework" />
export default function react$$(this: WebdriverIO.BrowserObject, selector: string, { props, state }?: WebdriverIO.ReactSelectorOptions): Promise<import("webdriverio").ElementArray>;
//# sourceMappingURL=react$$.d.ts.map
+1
View File
@@ -0,0 +1 @@
{"version":3,"file":"react$$.d.ts","sourceRoot":"","sources":["../../../src/commands/browser/react$$.ts"],"names":[],"mappings":";;;AAkCA,wBAA8B,OAAO,CACjC,IAAI,EAAE,WAAW,CAAC,aAAa,EAC/B,QAAQ,EAAE,MAAM,EAChB,EAAE,KAAU,EAAE,KAAU,EAAE,GAAE,WAAW,CAAC,oBAAyB,+CAUpE"}
+18
View File
@@ -0,0 +1,18 @@
"use strict";
var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
const fs_1 = __importDefault(require("fs"));
const utils_1 = require("../../utils");
const getElementObject_1 = require("../../utils/getElementObject");
const resq_1 = require("../../scripts/resq");
const resqScript = fs_1.default.readFileSync(require.resolve('resq'));
async function react$$(selector, { props = {}, state = {} } = {}) {
await this.executeScript(resqScript.toString(), []);
await this.execute(resq_1.waitToLoadReact);
const res = await this.execute(resq_1.react$$, selector, props, state);
const elements = await getElementObject_1.getElements.call(this, selector, res, true);
return utils_1.enhanceElementsArray(elements, this, selector, 'react$$', [props, state]);
}
exports.default = react$$;
+5
View File
@@ -0,0 +1,5 @@
/// <reference types="webdriverio/webdriverio-core" />
/// <reference types="webdriverio" />
/// <reference types="@wdio/cucumber-framework" />
export default function react$(this: WebdriverIO.BrowserObject, selector: string, { props, state }?: WebdriverIO.ReactSelectorOptions): Promise<import("webdriverio").Element>;
//# sourceMappingURL=react$.d.ts.map
+1
View File
@@ -0,0 +1 @@
{"version":3,"file":"react$.d.ts","sourceRoot":"","sources":["../../../src/commands/browser/react$.ts"],"names":[],"mappings":";;;AA4CA,wBAA8B,MAAM,CAChC,IAAI,EAAE,WAAW,CAAC,aAAa,EAC/B,QAAQ,EAAE,MAAM,EAChB,EAAE,KAAU,EAAE,KAAU,EAAE,GAAE,WAAW,CAAC,oBAAyB,0CASpE"}
+16
View File
@@ -0,0 +1,16 @@
"use strict";
var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
const fs_1 = __importDefault(require("fs"));
const getElementObject_1 = require("../../utils/getElementObject");
const resq_1 = require("../../scripts/resq");
const resqScript = fs_1.default.readFileSync(require.resolve('resq'));
async function react$(selector, { props = {}, state = {} } = {}) {
await this.executeScript(resqScript.toString(), []);
await this.execute(resq_1.waitToLoadReact);
const res = await this.execute(resq_1.react$, selector, props, state);
return getElementObject_1.getElement.call(this, selector, res, true);
}
exports.default = react$;
+4
View File
@@ -0,0 +1,4 @@
/// <reference types="webdriverio/webdriverio-core" />
/// <reference types="webdriverio" />
export default function reloadSession(this: WebdriverIO.BrowserObject): Promise<string>;
//# sourceMappingURL=reloadSession.d.ts.map
@@ -0,0 +1 @@
{"version":3,"file":"reloadSession.d.ts","sourceRoot":"","sources":["../../../src/commands/browser/reloadSession.ts"],"names":[],"mappings":";;AAwBA,wBAA8B,aAAa,CAAE,IAAI,EAAE,WAAW,CAAC,aAAa,mBAyB3E"}
+23
View File
@@ -0,0 +1,23 @@
"use strict";
var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
const logger_1 = __importDefault(require("@wdio/logger"));
const log = logger_1.default('webdriverio');
async function reloadSession() {
const oldSessionId = this.sessionId;
try {
await this.deleteSession();
}
catch (err) {
log.warn(`Suppressing error closing the session: ${err.stack}`);
}
const ProtocolDriver = require(this.options.automationProtocol).default;
await ProtocolDriver.reloadSession(this);
if (Array.isArray(this.options.onReload) && this.options.onReload.length) {
await Promise.all(this.options.onReload.map((hook) => hook(oldSessionId, this.sessionId)));
}
return this.sessionId;
}
exports.default = reloadSession;
+5
View File
@@ -0,0 +1,5 @@
/// <reference types="webdriverio/webdriverio-core" />
/// <reference types="webdriverio" />
/// <reference types="node" />
export default function savePDF(this: WebdriverIO.BrowserObject, filepath: string, options?: WebdriverIO.PDFPrintOptions): Promise<Buffer>;
//# sourceMappingURL=savePDF.d.ts.map
+1
View File
@@ -0,0 +1 @@
{"version":3,"file":"savePDF.d.ts","sourceRoot":"","sources":["../../../src/commands/browser/savePDF.ts"],"names":[],"mappings":";;;AAiCA,wBAA8B,OAAO,CACjC,IAAI,EAAE,WAAW,CAAC,aAAa,EAC/B,QAAQ,EAAE,MAAM,EAChB,OAAO,CAAC,EAAE,WAAW,CAAC,eAAe,mBAmBxC"}
+19
View File
@@ -0,0 +1,19 @@
"use strict";
var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
const fs_1 = __importDefault(require("fs"));
const utils_1 = require("../../utils");
async function savePDF(filepath, options) {
if (typeof filepath != 'string' || !filepath.endsWith('.pdf')) {
throw new Error('savePDF expects a filepath of type string and ".pdf" file ending');
}
const absoluteFilepath = utils_1.getAbsoluteFilepath(filepath);
utils_1.assertDirectoryExists(absoluteFilepath);
const pdf = await this.printPage(options === null || options === void 0 ? void 0 : options.orientation, options === null || options === void 0 ? void 0 : options.scale, options === null || options === void 0 ? void 0 : options.background, options === null || options === void 0 ? void 0 : options.width, options === null || options === void 0 ? void 0 : options.height, options === null || options === void 0 ? void 0 : options.top, options === null || options === void 0 ? void 0 : options.bottom, options === null || options === void 0 ? void 0 : options.left, options === null || options === void 0 ? void 0 : options.right, options === null || options === void 0 ? void 0 : options.shrinkToFit, options === null || options === void 0 ? void 0 : options.pageRanges);
const page = Buffer.from(pdf, 'base64');
fs_1.default.writeFileSync(absoluteFilepath, page);
return page;
}
exports.default = savePDF;
@@ -0,0 +1,5 @@
/// <reference types="webdriverio/webdriverio-core" />
/// <reference types="webdriverio" />
/// <reference types="node" />
export default function saveRecordingScreen(this: WebdriverIO.BrowserObject, filepath: string): Promise<Buffer>;
//# sourceMappingURL=saveRecordingScreen.d.ts.map
@@ -0,0 +1 @@
{"version":3,"file":"saveRecordingScreen.d.ts","sourceRoot":"","sources":["../../../src/commands/browser/saveRecordingScreen.ts"],"names":[],"mappings":";;;AAwBA,wBAA8B,mBAAmB,CAC7C,IAAI,EAAE,WAAW,CAAC,aAAa,EAC/B,QAAQ,EAAE,MAAM,mBAiBnB"}
+19
View File
@@ -0,0 +1,19 @@
"use strict";
var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
const fs_1 = __importDefault(require("fs"));
const utils_1 = require("../../utils");
async function saveRecordingScreen(filepath) {
if (typeof filepath !== 'string') {
throw new Error('saveRecordingScreen expects a filepath');
}
const absoluteFilepath = utils_1.getAbsoluteFilepath(filepath);
utils_1.assertDirectoryExists(absoluteFilepath);
const videoBuffer = await this.stopRecordingScreen();
const video = Buffer.from(videoBuffer, 'base64');
fs_1.default.writeFileSync(absoluteFilepath, video);
return video;
}
exports.default = saveRecordingScreen;
+5
View File
@@ -0,0 +1,5 @@
/// <reference types="webdriverio/webdriverio-core" />
/// <reference types="webdriverio" />
/// <reference types="node" />
export default function saveScreenshot(this: WebdriverIO.BrowserObject, filepath: string): Promise<Buffer>;
//# sourceMappingURL=saveScreenshot.d.ts.map
@@ -0,0 +1 @@
{"version":3,"file":"saveScreenshot.d.ts","sourceRoot":"","sources":["../../../src/commands/browser/saveScreenshot.ts"],"names":[],"mappings":";;;AAuBA,wBAA8B,cAAc,CACxC,IAAI,EAAE,WAAW,CAAC,aAAa,EAC/B,QAAQ,EAAE,MAAM,mBAiBnB"}
+19
View File
@@ -0,0 +1,19 @@
"use strict";
var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
const fs_1 = __importDefault(require("fs"));
const utils_1 = require("../../utils");
async function saveScreenshot(filepath) {
if (typeof filepath !== 'string' || !filepath.endsWith('.png')) {
throw new Error('saveScreenshot expects a filepath of type string and ".png" file ending');
}
const absoluteFilepath = utils_1.getAbsoluteFilepath(filepath);
utils_1.assertDirectoryExists(absoluteFilepath);
const screenBuffer = await this.takeScreenshot();
const screenshot = Buffer.from(screenBuffer, 'base64');
fs_1.default.writeFileSync(absoluteFilepath, screenshot);
return screenshot;
}
exports.default = saveScreenshot;
+5
View File
@@ -0,0 +1,5 @@
/// <reference types="webdriverio/webdriverio-core" />
/// <reference types="webdriverio" />
/// <reference types="webdriver" />
export default function setCookies(this: WebdriverIO.BrowserObject, cookieObjs: WebDriver.Cookie | WebDriver.Cookie[]): Promise<void>;
//# sourceMappingURL=setCookies.d.ts.map
+1
View File
@@ -0,0 +1 @@
{"version":3,"file":"setCookies.d.ts","sourceRoot":"","sources":["../../../src/commands/browser/setCookies.ts"],"names":[],"mappings":";;;AAsDA,wBAA8B,UAAU,CACpC,IAAI,EAAE,WAAW,CAAC,aAAa,EAC/B,UAAU,EAAE,SAAS,CAAC,MAAM,GAAG,SAAS,CAAC,MAAM,EAAE,iBAWpD"}
+12
View File
@@ -0,0 +1,12 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
async function setCookies(cookieObjs) {
const cookieObjsList = !Array.isArray(cookieObjs) ? [cookieObjs] : cookieObjs;
if (cookieObjsList.some(obj => (typeof obj !== 'object'))) {
throw new Error('Invalid input (see https://webdriver.io/docs/api/browser/setCookies.html for documentation.');
}
await Promise.all(cookieObjsList
.map(cookieObj => this.addCookie(cookieObj)));
return;
}
exports.default = setCookies;
+5
View File
@@ -0,0 +1,5 @@
/// <reference types="webdriverio/webdriverio-core" />
/// <reference types="webdriverio" />
/// <reference types="webdriver" />
export default function setTimeout(this: WebdriverIO.BrowserObject, timeouts: Partial<WebDriver.Timeouts>): Promise<void>;
//# sourceMappingURL=setTimeout.d.ts.map
+1
View File
@@ -0,0 +1 @@
{"version":3,"file":"setTimeout.d.ts","sourceRoot":"","sources":["../../../src/commands/browser/setTimeout.ts"],"names":[],"mappings":";;;AA6BA,wBAA8B,UAAU,CACpC,IAAI,EAAE,WAAW,CAAC,aAAa,EAC/B,QAAQ,EAAE,OAAO,CAAC,SAAS,CAAC,QAAQ,CAAC,GACtC,OAAO,CAAC,IAAI,CAAC,CAiCf"}
+25
View File
@@ -0,0 +1,25 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
async function setTimeout(timeouts) {
if (typeof timeouts !== 'object') {
throw new Error('Parameter for "setTimeout" command needs to be an object');
}
const timeoutValues = Object.values(timeouts);
if (timeoutValues.length && timeoutValues.every(timeout => typeof timeout !== 'number' || timeout < 0 || timeout > Number.MAX_SAFE_INTEGER)) {
throw new Error('Specified timeout values are not valid integer (see https://webdriver.io/docs/api/browser/setTimeout.html for documentation).');
}
const implicit = timeouts.implicit;
const pageLoad = timeouts['page load'] || timeouts.pageLoad;
const script = timeouts.script;
const setTimeouts = this.setTimeouts.bind(this);
if (!this.isW3C) {
await Promise.all([
isFinite(implicit) && setTimeouts('implicit', implicit),
isFinite(pageLoad) && setTimeouts('page load', pageLoad),
isFinite(script) && setTimeouts('script', script),
].filter(Boolean));
return;
}
return setTimeouts(implicit, pageLoad, script);
}
exports.default = setTimeout;
+4
View File
@@ -0,0 +1,4 @@
/// <reference types="webdriverio/webdriverio-core" />
/// <reference types="webdriverio" />
export default function setWindowSize(this: WebdriverIO.BrowserObject, width: number, height: number): Promise<void>;
//# sourceMappingURL=setWindowSize.d.ts.map
@@ -0,0 +1 @@
{"version":3,"file":"setWindowSize.d.ts","sourceRoot":"","sources":["../../../src/commands/browser/setWindowSize.ts"],"names":[],"mappings":";;AAwBA,wBAA8B,aAAa,CACvC,IAAI,EAAE,WAAW,CAAC,aAAa,EAC/B,KAAK,EAAE,MAAM,EACb,MAAM,EAAE,MAAM,GACf,OAAO,CAAC,IAAI,CAAC,CAoBf"}
+18
View File
@@ -0,0 +1,18 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
const utils_1 = require("../../utils");
const minWindowSize = 0;
const maxWindowSize = Number.MAX_SAFE_INTEGER;
async function setWindowSize(width, height) {
if (typeof width !== 'number' || typeof height !== 'number') {
throw new Error('setWindowSize expects width and height of type number');
}
if (width < minWindowSize || width > maxWindowSize || height < minWindowSize || height > maxWindowSize) {
throw new Error('setWindowSize expects width and height to be a number in the 0 to 2^31 − 1 range');
}
const browser = utils_1.getBrowserObject(this);
return !browser.isW3C
? browser._setWindowSize(width, height)
: browser.setWindowRect(null, null, width, height);
}
exports.default = setWindowSize;
+4
View File
@@ -0,0 +1,4 @@
/// <reference types="webdriverio/webdriverio-core" />
/// <reference types="webdriverio" />
export default function switchWindow(this: WebdriverIO.BrowserObject, urlOrTitleToMatch: string | RegExp): Promise<string>;
//# sourceMappingURL=switchWindow.d.ts.map
@@ -0,0 +1 @@
{"version":3,"file":"switchWindow.d.ts","sourceRoot":"","sources":["../../../src/commands/browser/switchWindow.ts"],"names":[],"mappings":";;AA6BA,wBAA8B,YAAY,CACtC,IAAI,EAAE,WAAW,CAAC,aAAa,EAC/B,iBAAiB,EAAE,MAAM,GAAG,MAAM,mBAuCrC"}
+27
View File
@@ -0,0 +1,27 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
async function switchWindow(urlOrTitleToMatch) {
if (typeof urlOrTitleToMatch !== 'string' && !(urlOrTitleToMatch instanceof RegExp)) {
throw new Error('Unsupported parameter for switchWindow, required is "string" or an RegExp');
}
const tabs = await this.getWindowHandles();
const matchesTarget = (target) => {
if (typeof urlOrTitleToMatch === 'string') {
return target.includes(urlOrTitleToMatch);
}
return !!target.match(urlOrTitleToMatch);
};
for (const tab of tabs) {
await this.switchToWindow(tab);
const url = await this.getUrl();
if (matchesTarget(url)) {
return tab;
}
const title = await this.getTitle();
if (matchesTarget(title)) {
return tab;
}
}
throw new Error(`No window found with title or url matching "${urlOrTitleToMatch}"`);
}
exports.default = switchWindow;
+4
View File
@@ -0,0 +1,4 @@
/// <reference types="webdriverio/webdriverio-core" />
/// <reference types="webdriverio" />
export default function throttle(this: WebdriverIO.BrowserObject, params: WebdriverIO.ThrottleOptions): Promise<null>;
//# sourceMappingURL=throttle.d.ts.map
+1
View File
@@ -0,0 +1 @@
{"version":3,"file":"throttle.d.ts","sourceRoot":"","sources":["../../../src/commands/browser/throttle.ts"],"names":[],"mappings":";;AAsGA,wBAA8B,QAAQ,CAClC,IAAI,EAAE,WAAW,CAAC,aAAa,EAC/B,MAAM,EAAE,WAAW,CAAC,eAAe,iBAsCtC"}
+85
View File
@@ -0,0 +1,85 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
const utils_1 = require("../../utils");
const NETWORK_PRESETS = {
'offline': {
offline: true,
downloadThroughput: 0,
uploadThroughput: 0,
latency: 1
},
'GPRS': {
offline: false,
downloadThroughput: 50 * 1024 / 8,
uploadThroughput: 20 * 1024 / 8,
latency: 500
},
'Regular2G': {
offline: false,
downloadThroughput: 250 * 1024 / 8,
uploadThroughput: 50 * 1024 / 8,
latency: 300
},
'Good2G': {
offline: false,
downloadThroughput: 450 * 1024 / 8,
uploadThroughput: 150 * 1024 / 8,
latency: 150
},
'Regular3G': {
offline: false,
downloadThroughput: 750 * 1024 / 8,
uploadThroughput: 250 * 1024 / 8,
latency: 100
},
'Good3G': {
offline: false,
downloadThroughput: 1.5 * 1024 * 1024 / 8,
uploadThroughput: 750 * 1024 / 8,
latency: 40
},
'Regular4G': {
offline: false,
downloadThroughput: 4 * 1024 * 1024 / 8,
uploadThroughput: 3 * 1024 * 1024 / 8,
latency: 20
},
'DSL': {
offline: false,
downloadThroughput: 2 * 1024 * 1024 / 8,
uploadThroughput: 1 * 1024 * 1024 / 8,
latency: 5
},
'WiFi': {
offline: false,
downloadThroughput: 30 * 1024 * 1024 / 8,
uploadThroughput: 15 * 1024 * 1024 / 8,
latency: 2
},
'online': {
offline: false,
latency: 0,
downloadThroughput: -1,
uploadThroughput: -1
}
};
const NETWORK_PRESET_TYPES = Object.keys(NETWORK_PRESETS);
async function throttle(params) {
if ((typeof params !== 'string' || !NETWORK_PRESET_TYPES.includes(params)) &&
(typeof params !== 'object')) {
throw new Error(`Invalid parameter for "throttle". Expected it to be typeof object or one of the following values: ${NETWORK_PRESET_TYPES.join(', ')} but found "${params}"`);
}
if (this.isSauce) {
const browser = utils_1.getBrowserObject(this);
await browser.throttleNetwork(params);
return null;
}
await this.getPuppeteer();
const pages = await this.puppeteer.pages();
const client = await pages[0].target().createCDPSession();
await client.send('Network.emulateNetworkConditions', typeof params === 'string'
? NETWORK_PRESETS[params]
: params);
return null;
}
exports.default = throttle;
+4
View File
@@ -0,0 +1,4 @@
/// <reference types="webdriverio/webdriverio-core" />
/// <reference types="webdriverio" />
export default function touchAction(this: WebdriverIO.BrowserObject, ...args: WebdriverIO.TouchAction[]): void;
//# sourceMappingURL=touchAction.d.ts.map
+1
View File
@@ -0,0 +1 @@
{"version":3,"file":"touchAction.d.ts","sourceRoot":"","sources":["../../../src/commands/browser/touchAction.ts"],"names":[],"mappings":";;AA6DA,MAAM,CAAC,OAAO,UAAU,WAAW,CAC/B,IAAI,EAAE,WAAW,CAAC,aAAa,EAC/B,GAAG,IAAI,EAAE,WAAW,CAAC,WAAW,EAAE,QAGrC"}
+7
View File
@@ -0,0 +1,7 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
const constant_1 = require("../constant");
function touchAction(...args) {
return constant_1.touchAction.apply(this, args);
}
exports.default = touchAction;
+4
View File
@@ -0,0 +1,4 @@
/// <reference types="webdriverio/webdriverio-core" />
/// <reference types="webdriverio" />
export default function uploadFile(this: WebdriverIO.BrowserObject, localPath: string): Promise<string>;
//# sourceMappingURL=uploadFile.d.ts.map
+1
View File
@@ -0,0 +1 @@
{"version":3,"file":"uploadFile.d.ts","sourceRoot":"","sources":["../../../src/commands/browser/uploadFile.ts"],"names":[],"mappings":";;AAkCA,wBAA8B,UAAU,CACpC,IAAI,EAAE,WAAW,CAAC,aAAa,EAC/B,SAAS,EAAE,MAAM,GAClB,OAAO,CAAC,MAAM,CAAC,CA4BjB"}
+27
View File
@@ -0,0 +1,27 @@
"use strict";
var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
const fs_1 = __importDefault(require("fs"));
const path_1 = __importDefault(require("path"));
const archiver_1 = __importDefault(require("archiver"));
async function uploadFile(localPath) {
if (typeof localPath !== 'string') {
throw new Error('number or type of arguments don\'t agree with uploadFile command');
}
if (typeof this.file !== 'function') {
throw new Error(`The uploadFile command is not available in ${this.capabilities.browserName}`);
}
let zipData = [];
let source = fs_1.default.createReadStream(localPath);
return new Promise((resolve, reject) => {
archiver_1.default('zip')
.on('error', (err) => reject(err))
.on('data', (data) => zipData.push(data))
.on('end', () => this.file(Buffer.concat(zipData).toString('base64')).then((localPath) => resolve(localPath), reject))
.append(source, { name: path_1.default.basename(localPath) })
.finalize();
});
}
exports.default = uploadFile;
+4
View File
@@ -0,0 +1,4 @@
/// <reference types="webdriverio/webdriverio-core" />
/// <reference types="webdriverio" />
export default function url(this: WebdriverIO.BrowserObject, path: string): Promise<void>;
//# sourceMappingURL=url.d.ts.map
+1
View File
@@ -0,0 +1 @@
{"version":3,"file":"url.d.ts","sourceRoot":"","sources":["../../../src/commands/browser/url.ts"],"names":[],"mappings":";;AAqCA,MAAM,CAAC,OAAO,UAAU,GAAG,CACvB,IAAI,EAAE,WAAW,CAAC,aAAa,EAC/B,IAAI,EAAE,MAAM,iBAWf"}
+17
View File
@@ -0,0 +1,17 @@
"use strict";
var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
const url_1 = __importDefault(require("url"));
const utils_1 = require("../../utils");
function url(path) {
if (typeof path !== 'string') {
throw new Error('Parameter for "url" command needs to be type of string');
}
if (typeof this.options.baseUrl === 'string') {
path = url_1.default.resolve(this.options.baseUrl, path);
}
return this.navigateTo(utils_1.validateUrl(path));
}
exports.default = url;

Some files were not shown because too many files have changed in this diff Show More