webdriver 7.16.13 → 7.17.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "webdriver",
3
- "version": "7.16.13",
3
+ "version": "7.17.0",
4
4
  "description": "A Node.js bindings implementation for the W3C WebDriver and Mobile JSONWire Protocol",
5
5
  "author": "Christian Bromann <christian@saucelabs.com>",
6
6
  "homepage": "https://github.com/webdriverio/webdriverio/tree/main/packages/webdriver",
@@ -26,14 +26,14 @@
26
26
  },
27
27
  "dependencies": {
28
28
  "@types/node": "^17.0.4",
29
- "@wdio/config": "7.16.13",
29
+ "@wdio/config": "7.16.16",
30
30
  "@wdio/logger": "7.16.0",
31
31
  "@wdio/protocols": "7.16.7",
32
- "@wdio/types": "7.16.13",
33
- "@wdio/utils": "7.16.13",
32
+ "@wdio/types": "7.16.14",
33
+ "@wdio/utils": "7.17.0",
34
34
  "got": "^11.0.2",
35
- "ky": "^0.28.5",
35
+ "ky": "^0.30.0",
36
36
  "lodash.merge": "^4.6.1"
37
37
  },
38
- "gitHead": "a0079123fa5207523e8386e6e5100df0bf2f84ef"
38
+ "gitHead": "e18d2cde6ff979758830bdff4c3bc82ca9818b24"
39
39
  }
@@ -1,5 +0,0 @@
1
- import type { CommandEndpoint } from '@wdio/protocols';
2
- import { WebDriverResponse } from './request';
3
- import { BaseClient } from './types';
4
- export default function (method: string, endpointUri: string, commandInfo: CommandEndpoint, doubleEncodeVariables?: boolean): (this: BaseClient, ...args: any[]) => Promise<WebDriverResponse>;
5
- //# sourceMappingURL=command.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"command.d.ts","sourceRoot":"","sources":["../src/command.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,iBAAiB,CAAA;AAGtD,OAAO,EAAE,iBAAiB,EAAE,MAAM,WAAW,CAAA;AAC7C,OAAO,EAAE,UAAU,EAAE,MAAM,SAAS,CAAA;AAIpC,MAAM,CAAC,OAAO,WACV,MAAM,EAAE,MAAM,EACd,WAAW,EAAE,MAAM,EACnB,WAAW,EAAE,eAAe,EAC5B,qBAAqB,UAAQ,UAIU,UAAU,WAAW,GAAG,EAAE,KAAG,QAAQ,iBAAiB,CAAC,CA0FjG"}
package/build/command.js DELETED
@@ -1,88 +0,0 @@
1
- "use strict";
2
- var __importDefault = (this && this.__importDefault) || function (mod) {
3
- return (mod && mod.__esModule) ? mod : { "default": mod };
4
- };
5
- Object.defineProperty(exports, "__esModule", { value: true });
6
- const logger_1 = __importDefault(require("@wdio/logger"));
7
- const utils_1 = require("@wdio/utils");
8
- const factory_1 = __importDefault(require("./request/factory"));
9
- const log = (0, logger_1.default)('webdriver');
10
- function default_1(method, endpointUri, commandInfo, doubleEncodeVariables = false) {
11
- const { command, ref, parameters, variables = [], isHubCommand = false } = commandInfo;
12
- return function protocolCommand(...args) {
13
- let endpoint = endpointUri; // clone endpointUri in case we change it
14
- const commandParams = [...variables.map((v) => Object.assign(v, {
15
- /**
16
- * url variables are:
17
- */
18
- required: true,
19
- type: 'string' // have to be always type of string
20
- })), ...parameters];
21
- const commandUsage = `${command}(${commandParams.map((p) => p.name).join(', ')})`;
22
- const moreInfo = `\n\nFor more info see ${ref}\n`;
23
- const body = {};
24
- /**
25
- * parameter check
26
- */
27
- const minAllowedParams = commandParams.filter((param) => param.required).length;
28
- if (args.length < minAllowedParams || args.length > commandParams.length) {
29
- const parameterDescription = commandParams.length
30
- ? `\n\nProperty Description:\n${commandParams.map((p) => ` "${p.name}" (${p.type}): ${p.description}`).join('\n')}`
31
- : '';
32
- throw new Error(`Wrong parameters applied for ${command}\n` +
33
- `Usage: ${commandUsage}` +
34
- parameterDescription +
35
- moreInfo);
36
- }
37
- /**
38
- * parameter type check
39
- */
40
- for (const [it, arg] of Object.entries(args)) {
41
- const i = parseInt(it, 10);
42
- const commandParam = commandParams[i];
43
- if (!(0, utils_1.isValidParameter)(arg, commandParam.type)) {
44
- /**
45
- * ignore if argument is not required
46
- */
47
- if (typeof arg === 'undefined' && !commandParam.required) {
48
- continue;
49
- }
50
- const actual = commandParam.type.endsWith('[]')
51
- ? `(${(Array.isArray(arg) ? arg : [arg]).map((a) => (0, utils_1.getArgumentType)(a))})[]`
52
- : (0, utils_1.getArgumentType)(arg);
53
- throw new Error(`Malformed type for "${commandParam.name}" parameter of command ${command}\n` +
54
- `Expected: ${commandParam.type}\n` +
55
- `Actual: ${actual}` +
56
- moreInfo);
57
- }
58
- /**
59
- * inject url variables
60
- */
61
- if (i < variables.length) {
62
- const encodedArg = doubleEncodeVariables ? encodeURIComponent(encodeURIComponent(arg)) : encodeURIComponent(arg);
63
- endpoint = endpoint.replace(`:${commandParams[i].name}`, encodedArg);
64
- continue;
65
- }
66
- /**
67
- * rest of args are part of body payload
68
- */
69
- body[commandParams[i].name] = arg;
70
- }
71
- const request = factory_1.default.getInstance(method, endpoint, body, isHubCommand);
72
- this.emit('command', { method, endpoint, body });
73
- log.info('COMMAND', (0, utils_1.commandCallStructure)(command, args));
74
- return request.makeRequest(this.options, this.sessionId).then((result) => {
75
- if (result.value != null) {
76
- log.info('RESULT', /screenshot|recording/i.test(command)
77
- && typeof result.value === 'string' && result.value.length > 64
78
- ? `${result.value.substr(0, 61)}...` : result.value);
79
- }
80
- this.emit('result', { method, endpoint, body, result });
81
- if (command === 'deleteSession') {
82
- logger_1.default.clearLogger();
83
- }
84
- return result.value;
85
- });
86
- };
87
- }
88
- exports.default = default_1;
@@ -1,8 +0,0 @@
1
- import type { Options } from '@wdio/types';
2
- export declare const DEFAULTS: Options.Definition<Required<Options.WebDriver>>;
3
- export declare const VALID_CAPS: string[];
4
- export declare const REG_EXPS: {
5
- commandName: RegExp;
6
- execFn: RegExp;
7
- };
8
- //# sourceMappingURL=constants.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"constants.d.ts","sourceRoot":"","sources":["../src/constants.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,aAAa,CAAA;AAE1C,eAAO,MAAM,QAAQ,EAAE,OAAO,CAAC,UAAU,CAAC,QAAQ,CAAC,OAAO,CAAC,SAAS,CAAC,CAiJpE,CAAA;AAED,eAAO,MAAM,UAAU,UAItB,CAAA;AAED,eAAO,MAAM,QAAQ;;;CAGpB,CAAA"}
@@ -1,157 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.REG_EXPS = exports.VALID_CAPS = exports.DEFAULTS = void 0;
4
- exports.DEFAULTS = {
5
- /**
6
- * protocol of automation driver
7
- */
8
- protocol: {
9
- type: 'string',
10
- default: 'http',
11
- match: /(http|https)/
12
- },
13
- /**
14
- * hostname of automation driver
15
- */
16
- hostname: {
17
- type: 'string',
18
- default: 'localhost'
19
- },
20
- /**
21
- * port of automation driver
22
- */
23
- port: {
24
- type: 'number',
25
- default: 4444
26
- },
27
- /**
28
- * path to WebDriver endpoints
29
- */
30
- path: {
31
- type: 'string',
32
- validate: (path) => {
33
- if (!path.startsWith('/')) {
34
- throw new TypeError('The option "path" needs to start with a "/"');
35
- }
36
- return true;
37
- },
38
- default: '/'
39
- },
40
- /**
41
- * A key-value store of query parameters to be added to every selenium request
42
- */
43
- queryParams: {
44
- type: 'object'
45
- },
46
- /**
47
- * cloud user if applicable
48
- */
49
- user: {
50
- type: 'string'
51
- },
52
- /**
53
- * access key to user
54
- */
55
- key: {
56
- type: 'string'
57
- },
58
- /**
59
- * capability of WebDriver session
60
- */
61
- capabilities: {
62
- type: 'object',
63
- required: true
64
- },
65
- /**
66
- * Level of logging verbosity
67
- */
68
- logLevel: {
69
- type: 'string',
70
- default: 'info',
71
- match: /(trace|debug|info|warn|error|silent)/
72
- },
73
- /**
74
- * directory for log files
75
- */
76
- outputDir: {
77
- type: 'string'
78
- },
79
- /**
80
- * Timeout for any WebDriver request to a driver or grid
81
- */
82
- connectionRetryTimeout: {
83
- type: 'number',
84
- default: 120000
85
- },
86
- /**
87
- * Count of request retries to the Selenium server
88
- */
89
- connectionRetryCount: {
90
- type: 'number',
91
- default: 3
92
- },
93
- /**
94
- * Override default agent
95
- */
96
- agent: {
97
- type: 'object'
98
- },
99
- /**
100
- * Override default agent
101
- */
102
- logLevels: {
103
- type: 'object'
104
- },
105
- /**
106
- * Pass custom headers
107
- */
108
- headers: {
109
- type: 'object'
110
- },
111
- /**
112
- * Function transforming the request options before the request is made
113
- */
114
- transformRequest: {
115
- type: 'function',
116
- default: (requestOptions) => requestOptions
117
- },
118
- /**
119
- * Function transforming the response object after it is received
120
- */
121
- transformResponse: {
122
- type: 'function',
123
- default: (response) => response
124
- },
125
- /**
126
- * Appium direct connect options server (https://appiumpro.com/editions/86-connecting-directly-to-appium-hosts-in-distributed-environments)
127
- */
128
- directConnectProtocol: {
129
- type: 'string'
130
- },
131
- directConnectHost: {
132
- type: 'string'
133
- },
134
- directConnectPort: {
135
- type: 'number'
136
- },
137
- directConnectPath: {
138
- type: 'string'
139
- },
140
- /**
141
- * Whether it requires SSL certificates to be valid in HTTP/s requests
142
- * for an environment which cannot get process environment well.
143
- */
144
- strictSSL: {
145
- type: 'boolean',
146
- default: true
147
- }
148
- };
149
- exports.VALID_CAPS = [
150
- 'browserName', 'browserVersion', 'platformName', 'acceptInsecureCerts',
151
- 'pageLoadStrategy', 'proxy', 'setWindowRect', 'timeouts', 'strictFileInteractability',
152
- 'unhandledPromptBehavior'
153
- ];
154
- exports.REG_EXPS = {
155
- commandName: /.*\/session\/[0-9a-f-]+\/(.*)/,
156
- execFn: /return \(([\s\S]*)\)\.apply\(null, arguments\)/
157
- };
package/build/index.d.ts DELETED
@@ -1,27 +0,0 @@
1
- import type { Options } from '@wdio/types';
2
- import command from './command';
3
- import { DEFAULTS } from './constants';
4
- import { getPrototype } from './utils';
5
- import type { Client, AttachOptions } from './types';
6
- export default class WebDriver {
7
- static newSession(options: Options.WebDriver, modifier?: (...args: any[]) => any, userPrototype?: {}, customCommandWrapper?: (...args: any[]) => any): Promise<Client>;
8
- /**
9
- * allows user to attach to existing sessions
10
- */
11
- static attachToSession(options?: AttachOptions, modifier?: (...args: any[]) => any, userPrototype?: {}, commandWrapper?: (...args: any[]) => any): Client;
12
- /**
13
- * Changes The instance session id and browser capabilities for the new session
14
- * directly into the passed in browser object
15
- *
16
- * @param {Object} instance the object we get from a new browser session.
17
- * @returns {string} the new session id of the browser
18
- */
19
- static reloadSession(instance: Client): Promise<string>;
20
- static get WebDriver(): typeof WebDriver;
21
- }
22
- /**
23
- * Helper methods consumed by webdriverio package
24
- */
25
- export { getPrototype, DEFAULTS, command };
26
- export * from './types';
27
- //# sourceMappingURL=index.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAKA,OAAO,KAAK,EAAE,OAAO,EAAgB,MAAM,aAAa,CAAA;AAExD,OAAO,OAAO,MAAM,WAAW,CAAA;AAC/B,OAAO,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAA;AACtC,OAAO,EAAyB,YAAY,EAAsB,MAAM,SAAS,CAAA;AACjF,OAAO,KAAK,EAAE,MAAM,EAAE,aAAa,EAAgB,MAAM,SAAS,CAAA;AAIlE,MAAM,CAAC,OAAO,OAAO,SAAS;WACb,UAAU,CACnB,OAAO,EAAE,OAAO,CAAC,SAAS,EAC1B,QAAQ,CAAC,EAAE,CAAC,GAAG,IAAI,EAAE,GAAG,EAAE,KAAK,GAAG,EAClC,aAAa,KAAK,EAClB,oBAAoB,CAAC,EAAE,CAAC,GAAG,IAAI,EAAE,GAAG,EAAE,KAAK,GAAG,GAC/C,OAAO,CAAC,MAAM,CAAC;IAgDlB;;OAEG;IACH,MAAM,CAAC,eAAe,CAClB,OAAO,CAAC,EAAE,aAAa,EACvB,QAAQ,CAAC,EAAE,CAAC,GAAG,IAAI,EAAE,GAAG,EAAE,KAAK,GAAG,EAClC,aAAa,KAAK,EAClB,cAAc,CAAC,EAAE,CAAC,GAAG,IAAI,EAAE,GAAG,EAAE,KAAK,GAAG,GACzC,MAAM;IAwBT;;;;;;MAME;WACW,aAAa,CAAE,QAAQ,EAAE,MAAM;IAW5C,MAAM,KAAK,SAAS,qBAEnB;CACJ;AAED;;GAEG;AACH,OAAO,EAAE,YAAY,EAAE,QAAQ,EAAE,OAAO,EAAE,CAAA;AAC1C,cAAc,SAAS,CAAA"}
package/build/index.js DELETED
@@ -1,111 +0,0 @@
1
- "use strict";
2
- var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
- if (k2 === undefined) k2 = k;
4
- Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
5
- }) : (function(o, m, k, k2) {
6
- if (k2 === undefined) k2 = k;
7
- o[k2] = m[k];
8
- }));
9
- var __exportStar = (this && this.__exportStar) || function(m, exports) {
10
- for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
11
- };
12
- var __importDefault = (this && this.__importDefault) || function (mod) {
13
- return (mod && mod.__esModule) ? mod : { "default": mod };
14
- };
15
- Object.defineProperty(exports, "__esModule", { value: true });
16
- exports.command = exports.DEFAULTS = exports.getPrototype = void 0;
17
- const path_1 = __importDefault(require("path"));
18
- const logger_1 = __importDefault(require("@wdio/logger"));
19
- const utils_1 = require("@wdio/utils");
20
- const config_1 = require("@wdio/config");
21
- const command_1 = __importDefault(require("./command"));
22
- exports.command = command_1.default;
23
- const constants_1 = require("./constants");
24
- Object.defineProperty(exports, "DEFAULTS", { enumerable: true, get: function () { return constants_1.DEFAULTS; } });
25
- const utils_2 = require("./utils");
26
- Object.defineProperty(exports, "getPrototype", { enumerable: true, get: function () { return utils_2.getPrototype; } });
27
- const log = (0, logger_1.default)('webdriver');
28
- class WebDriver {
29
- static async newSession(options, modifier, userPrototype = {}, customCommandWrapper) {
30
- const params = (0, config_1.validateConfig)(constants_1.DEFAULTS, options);
31
- if (!options.logLevels || !options.logLevels.webdriver) {
32
- logger_1.default.setLevel('webdriver', params.logLevel);
33
- }
34
- /**
35
- * Store all log events in a file
36
- */
37
- if (params.outputDir && !process.env.WDIO_LOG_PATH) {
38
- process.env.WDIO_LOG_PATH = path_1.default.join(params.outputDir, 'wdio.log');
39
- }
40
- log.info('Initiate new session using the WebDriver protocol');
41
- /**
42
- * if the server responded with direct connect information, update the
43
- * params to speak directly to the appium host instead of a load
44
- * balancer (see https://github.com/appium/python-client#direct-connect-urls
45
- * for example). But only do this if the user has enabled this
46
- * behavior in the first place.
47
- */
48
- const { directConnectProtocol, directConnectHost, directConnectPort, directConnectPath } = params;
49
- if (directConnectProtocol && directConnectHost && directConnectPort && (directConnectPath || directConnectPath === '')) {
50
- log.info('Found direct connect information in new session response. ' +
51
- `Will connect to server at ${directConnectProtocol}://${directConnectHost}:${directConnectPort}/${directConnectPath}`);
52
- params.protocol = directConnectProtocol;
53
- params.hostname = directConnectHost;
54
- params.port = directConnectPort;
55
- params.path = directConnectPath;
56
- }
57
- const requestedCapabilities = { ...params.capabilities };
58
- const { sessionId, capabilities } = await (0, utils_2.startWebDriverSession)(params);
59
- const environment = (0, utils_1.sessionEnvironmentDetector)({ capabilities, requestedCapabilities });
60
- const environmentPrototype = (0, utils_2.getEnvironmentVars)(environment);
61
- const protocolCommands = (0, utils_2.getPrototype)(environment);
62
- const prototype = { ...protocolCommands, ...environmentPrototype, ...userPrototype };
63
- const monad = (0, utils_1.webdriverMonad)({ ...params, requestedCapabilities }, modifier, prototype);
64
- return monad(sessionId, customCommandWrapper);
65
- }
66
- /**
67
- * allows user to attach to existing sessions
68
- */
69
- static attachToSession(options, modifier, userPrototype = {}, commandWrapper) {
70
- if (!options || typeof options.sessionId !== 'string') {
71
- throw new Error('sessionId is required to attach to existing session');
72
- }
73
- // logLevel can be undefined in watch mode when SIGINT is called
74
- if (options.logLevel) {
75
- logger_1.default.setLevel('webdriver', options.logLevel);
76
- }
77
- options.capabilities = options.capabilities || {};
78
- options.isW3C = options.isW3C === false ? false : true;
79
- options.protocol = options.protocol || constants_1.DEFAULTS.protocol.default;
80
- options.hostname = options.hostname || constants_1.DEFAULTS.hostname.default;
81
- options.port = options.port || constants_1.DEFAULTS.port.default;
82
- options.path = options.path || constants_1.DEFAULTS.path.default;
83
- const environmentPrototype = (0, utils_2.getEnvironmentVars)(options);
84
- const protocolCommands = (0, utils_2.getPrototype)(options);
85
- const prototype = { ...protocolCommands, ...environmentPrototype, ...userPrototype };
86
- const monad = (0, utils_1.webdriverMonad)(options, modifier, prototype);
87
- return monad(options.sessionId, commandWrapper);
88
- }
89
- /**
90
- * Changes The instance session id and browser capabilities for the new session
91
- * directly into the passed in browser object
92
- *
93
- * @param {Object} instance the object we get from a new browser session.
94
- * @returns {string} the new session id of the browser
95
- */
96
- static async reloadSession(instance) {
97
- const params = {
98
- ...instance.options,
99
- capabilities: instance.requestedCapabilities
100
- };
101
- const { sessionId, capabilities } = await (0, utils_2.startWebDriverSession)(params);
102
- instance.sessionId = sessionId;
103
- instance.capabilities = capabilities;
104
- return sessionId;
105
- }
106
- static get WebDriver() {
107
- return WebDriver;
108
- }
109
- }
110
- exports.default = WebDriver;
111
- __exportStar(require("./types"), exports);
@@ -1,14 +0,0 @@
1
- import { Options } from '@wdio/types';
2
- import WebDriverRequest from './index';
3
- declare type RequestLibOptions = Options.RequestLibOptions;
4
- declare type RequestOptions = Omit<Options.WebDriver, 'capabilities'>;
5
- export default class BrowserRequest extends WebDriverRequest {
6
- constructor(method: string, endpoint: string, body?: Record<string, unknown>, isHubCommand?: boolean);
7
- protected _createOptions(options: RequestOptions, sessionId?: string): RequestLibOptions;
8
- protected _libRequest(url: URL, options: RequestLibOptions): Promise<{
9
- statusCode: number;
10
- body: any;
11
- }>;
12
- }
13
- export {};
14
- //# sourceMappingURL=browser.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"browser.d.ts","sourceRoot":"","sources":["../../src/request/browser.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,aAAa,CAAA;AAErC,OAAO,gBAAgB,MAAM,SAAS,CAAA;AAGtC,aAAK,iBAAiB,GAAG,OAAO,CAAC,iBAAiB,CAAA;AAClD,aAAK,cAAc,GAAG,IAAI,CAAC,OAAO,CAAC,SAAS,EAAE,cAAc,CAAC,CAAA;AAU7D,MAAM,CAAC,OAAO,OAAO,cAAe,SAAQ,gBAAgB;gBAE3C,MAAM,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,EAAE,IAAI,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EAAE,YAAY,GAAE,OAAe;IAI5G,SAAS,CAAC,cAAc,CAAE,OAAO,EAAE,cAAc,EAAE,SAAS,CAAC,EAAE,MAAM,GAAG,iBAAiB;cAIzE,WAAW,CAAE,GAAG,EAAE,GAAG,EAAE,OAAO,EAAE,iBAAiB;;;;CA8BpE"}
@@ -1,48 +0,0 @@
1
- "use strict";
2
- var __importDefault = (this && this.__importDefault) || function (mod) {
3
- return (mod && mod.__esModule) ? mod : { "default": mod };
4
- };
5
- Object.defineProperty(exports, "__esModule", { value: true });
6
- const logger_1 = __importDefault(require("@wdio/logger"));
7
- const index_1 = __importDefault(require("./index"));
8
- const ky_1 = __importDefault(require("ky"));
9
- const log = (0, logger_1.default)('webdriver');
10
- const UNSUPPORTED_OPTS = [
11
- 'agent',
12
- 'responseType',
13
- 'searchParams',
14
- ];
15
- class BrowserRequest extends index_1.default {
16
- constructor(method, endpoint, body, isHubCommand = false) {
17
- super(method, endpoint, body, isHubCommand);
18
- }
19
- _createOptions(options, sessionId) {
20
- return super._createOptions(options, sessionId, true);
21
- }
22
- async _libRequest(url, options) {
23
- const kyOptions = {};
24
- for (const opt of Object.keys(options)) {
25
- if (typeof options[opt] !== undefined &&
26
- UNSUPPORTED_OPTS.includes(opt) &&
27
- options[opt] !== this.defaultOptions[opt]) {
28
- log.info(`Browser-based webdriver does not support the '${String(opt)}' option; behavior may be unexpected`);
29
- continue;
30
- }
31
- // @ts-expect-error
32
- kyOptions[opt] = options[opt];
33
- }
34
- if (options.username && options.password) {
35
- const encodedAuth = Buffer.from(`${options.username}:${options.password}`, 'utf8').toString('base64');
36
- kyOptions.headers = {
37
- ...kyOptions.headers,
38
- Authorization: `Basic ${encodedAuth}`
39
- };
40
- }
41
- const res = await (0, ky_1.default)(url, kyOptions);
42
- return {
43
- statusCode: res.status,
44
- body: await res.json(),
45
- };
46
- }
47
- }
48
- exports.default = BrowserRequest;
@@ -1,10 +0,0 @@
1
- /// <reference types="node" />
2
- import WebDriverRequest from './index';
3
- import type { URL as URLType } from 'url';
4
- export default class RequestFactory {
5
- static getInstance(method: string, endpoint: string, body?: Record<string, unknown>, isHubCommand?: boolean): WebDriverRequest;
6
- }
7
- export declare class URLFactory {
8
- static getInstance(uri: string): URLType;
9
- }
10
- //# sourceMappingURL=factory.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"factory.d.ts","sourceRoot":"","sources":["../../src/request/factory.ts"],"names":[],"mappings":";AAAA,OAAO,gBAAgB,MAAM,SAAS,CAAA;AACtC,OAAO,KAAK,EAAE,GAAG,IAAI,OAAO,EAAE,MAAM,KAAK,CAAA;AAEzC,MAAM,CAAC,OAAO,OAAO,cAAc;IAC/B,MAAM,CAAC,WAAW,CACd,MAAM,EAAE,MAAM,EACd,QAAQ,EAAE,MAAM,EAChB,IAAI,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EAC9B,YAAY,GAAE,OAAe,GAC9B,gBAAgB;CAYtB;AAED,qBAAa,UAAU;IACnB,MAAM,CAAC,WAAW,CAAE,GAAG,EAAE,MAAM,GAAG,OAAO;CAO5C"}
@@ -1,29 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.URLFactory = void 0;
4
- class RequestFactory {
5
- static getInstance(method, endpoint, body, isHubCommand = false) {
6
- var _a;
7
- if ((_a = process === null || process === void 0 ? void 0 : process.versions) === null || _a === void 0 ? void 0 : _a.node) {
8
- const reqModule = require('./node');
9
- // we either need to get the default export explicitly in the prod case, or implicitly
10
- // in the case of jest mocking
11
- const NodeJSRequest = reqModule.default || reqModule;
12
- return new NodeJSRequest(method, endpoint, body, isHubCommand);
13
- }
14
- const BrowserRequest = require('./browser').default;
15
- return new BrowserRequest(method, endpoint, body, isHubCommand);
16
- }
17
- }
18
- exports.default = RequestFactory;
19
- class URLFactory {
20
- static getInstance(uri) {
21
- var _a;
22
- if ((_a = process === null || process === void 0 ? void 0 : process.versions) === null || _a === void 0 ? void 0 : _a.node) {
23
- const { URL } = require('url');
24
- return new URL(uri);
25
- }
26
- return new window.URL(uri);
27
- }
28
- }
29
- exports.URLFactory = URLFactory;
@@ -1,44 +0,0 @@
1
- /// <reference types="node" />
2
- import { EventEmitter } from 'events';
3
- import type { URL } from 'url';
4
- import type { Options } from '@wdio/types';
5
- declare type Agents = Options.Agents;
6
- declare type RequestLibOptions = Options.RequestLibOptions;
7
- declare type RequestLibResponse = Options.RequestLibResponse;
8
- declare type RequestOptions = Omit<Options.WebDriver, 'capabilities'>;
9
- export declare class RequestLibError extends Error {
10
- statusCode?: number;
11
- body?: any;
12
- code?: string;
13
- }
14
- export interface WebDriverResponse {
15
- value: any;
16
- /**
17
- * error case
18
- * https://w3c.github.io/webdriver/webdriver-spec.html#dfn-send-an-error
19
- */
20
- error?: string;
21
- message?: string;
22
- stacktrace?: string;
23
- /**
24
- * JSONWP property
25
- */
26
- status?: number;
27
- sessionId?: string;
28
- }
29
- export default abstract class WebDriverRequest extends EventEmitter {
30
- body?: Record<string, unknown>;
31
- method: string;
32
- endpoint: string;
33
- isHubCommand: boolean;
34
- requiresSessionId: boolean;
35
- defaultAgents: Agents | null;
36
- defaultOptions: RequestLibOptions;
37
- constructor(method: string, endpoint: string, body?: Record<string, unknown>, isHubCommand?: boolean);
38
- makeRequest(options: RequestOptions, sessionId?: string): Promise<WebDriverResponse>;
39
- protected _createOptions(options: RequestOptions, sessionId?: string, isBrowser?: boolean): RequestLibOptions;
40
- protected _libRequest(url: URL, options: RequestLibOptions): Promise<RequestLibResponse>;
41
- private _request;
42
- }
43
- export {};
44
- //# sourceMappingURL=index.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/request/index.ts"],"names":[],"mappings":";AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,QAAQ,CAAA;AAErC,OAAO,KAAK,EAAE,GAAG,EAAE,MAAM,KAAK,CAAA;AAK9B,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,aAAa,CAAA;AAM1C,aAAK,MAAM,GAAG,OAAO,CAAC,MAAM,CAAA;AAC5B,aAAK,iBAAiB,GAAG,OAAO,CAAC,iBAAiB,CAAA;AAClD,aAAK,kBAAkB,GAAG,OAAO,CAAC,kBAAkB,CAAA;AACpD,aAAK,cAAc,GAAG,IAAI,CAAC,OAAO,CAAC,SAAS,EAAE,cAAc,CAAC,CAAA;AAE7D,qBAAa,eAAgB,SAAQ,KAAK;IACtC,UAAU,CAAC,EAAE,MAAM,CAAA;IACnB,IAAI,CAAC,EAAE,GAAG,CAAA;IACV,IAAI,CAAC,EAAE,MAAM,CAAA;CAChB;AAED,MAAM,WAAW,iBAAiB;IAC9B,KAAK,EAAE,GAAG,CAAA;IACV;;;OAGG;IACH,KAAK,CAAC,EAAE,MAAM,CAAA;IACd,OAAO,CAAC,EAAE,MAAM,CAAA;IAChB,UAAU,CAAC,EAAE,MAAM,CAAA;IAEnB;;OAEG;IACH,MAAM,CAAC,EAAE,MAAM,CAAA;IACf,SAAS,CAAC,EAAE,MAAM,CAAA;CACrB;AAWD,MAAM,CAAC,OAAO,CAAC,QAAQ,OAAO,gBAAiB,SAAQ,YAAY;IAC/D,IAAI,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAA;IAC9B,MAAM,EAAE,MAAM,CAAA;IACd,QAAQ,EAAE,MAAM,CAAA;IAChB,YAAY,EAAE,OAAO,CAAA;IACrB,iBAAiB,EAAE,OAAO,CAAA;IAC1B,aAAa,EAAE,MAAM,GAAG,IAAI,CAAA;IAC5B,cAAc,EAAE,iBAAiB,CAKhC;gBAEY,MAAM,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,EAAE,IAAI,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EAAE,YAAY,GAAE,OAAe;IAU5G,WAAW,CAAE,OAAO,EAAE,cAAc,EAAE,SAAS,CAAC,EAAE,MAAM;IAYxD,SAAS,CAAC,cAAc,CAAE,OAAO,EAAE,cAAc,EAAE,SAAS,CAAC,EAAE,MAAM,EAAE,SAAS,GAAE,OAAe,GAAG,iBAAiB;cAiErG,WAAW,CAAC,GAAG,EAAE,GAAG,EAAE,OAAO,EAAE,iBAAiB,GAAG,OAAO,CAAC,kBAAkB,CAAC;YAIhF,QAAQ;CA8GzB"}