@testring/plugin-selenium-driver 0.6.12 → 0.6.14-alpha.1
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/dist/index.js +1 -1
- package/dist/plugin/index.js +11 -46
- package/package.json +13 -11
- package/src/plugin/index.ts +8 -46
- package/src/types.ts +3 -3
package/dist/index.js
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.default = seleniumPlugin;
|
|
3
4
|
const path = require("path");
|
|
4
5
|
function seleniumPlugin(pluginAPI, userConfig) {
|
|
5
6
|
const pluginPath = path.join(__dirname, './plugin');
|
|
6
7
|
const browserProxy = pluginAPI.getBrowserProxy();
|
|
7
8
|
browserProxy.proxyPlugin(pluginPath, userConfig || {});
|
|
8
9
|
}
|
|
9
|
-
exports.default = seleniumPlugin;
|
package/dist/plugin/index.js
CHANGED
|
@@ -10,6 +10,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
10
10
|
};
|
|
11
11
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
12
|
exports.SeleniumPlugin = void 0;
|
|
13
|
+
exports.default = seleniumProxy;
|
|
13
14
|
const webdriverio_1 = require("webdriverio");
|
|
14
15
|
const deepmerge = require("deepmerge");
|
|
15
16
|
const child_process_1 = require("@testring/child-process");
|
|
@@ -74,7 +75,7 @@ class SeleniumPlugin {
|
|
|
74
75
|
}
|
|
75
76
|
// eslint-disable-next-line sonarjs/cognitive-complexity
|
|
76
77
|
createConfig(config) {
|
|
77
|
-
var _a, _b
|
|
78
|
+
var _a, _b;
|
|
78
79
|
let mergedConfig = deepmerge.all([DEFAULT_CONFIG, config], {
|
|
79
80
|
clone: true,
|
|
80
81
|
});
|
|
@@ -130,10 +131,8 @@ class SeleniumPlugin {
|
|
|
130
131
|
mergedConfig.hostname = mergedConfig.host;
|
|
131
132
|
}
|
|
132
133
|
const googleChromeOptions = (_a = mergedConfig.capabilities) === null || _a === void 0 ? void 0 : _a['goog:chromeOptions'];
|
|
133
|
-
if (googleChromeOptions
|
|
134
|
-
|
|
135
|
-
((_c = googleChromeOptions.args) === null || _c === void 0 ? void 0 : _c.includes('headless')))) {
|
|
136
|
-
const extensions = (_d = mergedConfig.capabilities) === null || _d === void 0 ? void 0 : _d['goog:chromeOptions'].extensions;
|
|
134
|
+
if ((_b = googleChromeOptions === null || googleChromeOptions === void 0 ? void 0 : googleChromeOptions.args) === null || _b === void 0 ? void 0 : _b.includes('--headless=new')) {
|
|
135
|
+
const extensions = googleChromeOptions.extensions;
|
|
137
136
|
const dowldMonitorCrx = (0, dwnld_collector_crx_1.getCrxBase64)();
|
|
138
137
|
if (extensions) {
|
|
139
138
|
extensions.push(dowldMonitorCrx);
|
|
@@ -345,7 +344,7 @@ class SeleniumPlugin {
|
|
|
345
344
|
client.addCommand('deleteSessionId', function (sessionId) {
|
|
346
345
|
const { w3cCaps, jsonwpCaps } = this.options.requestedCapabilities;
|
|
347
346
|
const sessionDeleteRequest = new WebDriverRequest('DELETE', '/session/:sessionId', {
|
|
348
|
-
capabilities: w3cCaps,
|
|
347
|
+
capabilities: w3cCaps, // W3C compliant
|
|
349
348
|
desiredCapabilities: jsonwpCaps, // JSONWP compliant
|
|
350
349
|
});
|
|
351
350
|
return sessionDeleteRequest.makeRequest(this.options, sessionId);
|
|
@@ -447,8 +446,8 @@ class SeleniumPlugin {
|
|
|
447
446
|
this.incrementWinId++;
|
|
448
447
|
return `window-${this.incrementWinId}`;
|
|
449
448
|
}
|
|
450
|
-
newWindow(
|
|
451
|
-
return __awaiter(this,
|
|
449
|
+
newWindow(applicant_1, val_1, windowName_1) {
|
|
450
|
+
return __awaiter(this, arguments, void 0, function* (applicant, val, windowName, windowFeatures = {}) {
|
|
452
451
|
yield this.createClient(applicant);
|
|
453
452
|
const client = this.getBrowserClient(applicant);
|
|
454
453
|
const args = stringifyWindowFeatures(windowFeatures);
|
|
@@ -482,8 +481,8 @@ class SeleniumPlugin {
|
|
|
482
481
|
return selector.isDisplayed();
|
|
483
482
|
});
|
|
484
483
|
}
|
|
485
|
-
moveToObject(
|
|
486
|
-
return __awaiter(this,
|
|
484
|
+
moveToObject(applicant_1, xpath_1) {
|
|
485
|
+
return __awaiter(this, arguments, void 0, function* (applicant, xpath, xOffset = 0, yOffset = 0) {
|
|
487
486
|
yield this.createClient(applicant);
|
|
488
487
|
const client = this.getBrowserClient(applicant);
|
|
489
488
|
const selector = yield client.$(xpath);
|
|
@@ -692,8 +691,8 @@ class SeleniumPlugin {
|
|
|
692
691
|
});
|
|
693
692
|
}
|
|
694
693
|
getCookie(applicant, cookieName) {
|
|
695
|
-
var _a;
|
|
696
694
|
return __awaiter(this, void 0, void 0, function* () {
|
|
695
|
+
var _a;
|
|
697
696
|
yield this.createClient(applicant);
|
|
698
697
|
const client = this.getBrowserClient(applicant);
|
|
699
698
|
if (cookieName) {
|
|
@@ -931,40 +930,7 @@ class SeleniumPlugin {
|
|
|
931
930
|
yield this.createClient(applicant);
|
|
932
931
|
const client = this.getBrowserClient(applicant);
|
|
933
932
|
const mock = yield client.mock(url, filterOptions);
|
|
934
|
-
|
|
935
|
-
mock.respond((res) => {
|
|
936
|
-
overwrites(res);
|
|
937
|
-
this.setMockData(applicant, url, res);
|
|
938
|
-
return res.body;
|
|
939
|
-
}, mockResponseParams);
|
|
940
|
-
}
|
|
941
|
-
else {
|
|
942
|
-
mock.respond(overwrites);
|
|
943
|
-
}
|
|
944
|
-
});
|
|
945
|
-
}
|
|
946
|
-
setMockData(applicant, url, data) {
|
|
947
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
948
|
-
yield this.createClient(applicant);
|
|
949
|
-
const client = this.getBrowserClient(applicant);
|
|
950
|
-
client.mockData = client.mockData || {};
|
|
951
|
-
if (client.mockData[url]) {
|
|
952
|
-
client.mockData[url].push(data);
|
|
953
|
-
}
|
|
954
|
-
else {
|
|
955
|
-
client.mockData[url] = [data];
|
|
956
|
-
}
|
|
957
|
-
return true;
|
|
958
|
-
});
|
|
959
|
-
}
|
|
960
|
-
getMockData(applicant, url) {
|
|
961
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
962
|
-
yield this.createClient(applicant);
|
|
963
|
-
const client = this.getBrowserClient(applicant);
|
|
964
|
-
if (url) {
|
|
965
|
-
return client.mockData[url];
|
|
966
|
-
}
|
|
967
|
-
return client.mockData;
|
|
933
|
+
mock.respond(overwrites, mockResponseParams);
|
|
968
934
|
});
|
|
969
935
|
}
|
|
970
936
|
emulateDevice(applicant, deviceName) {
|
|
@@ -989,4 +955,3 @@ exports.SeleniumPlugin = SeleniumPlugin;
|
|
|
989
955
|
function seleniumProxy(config) {
|
|
990
956
|
return new SeleniumPlugin(config);
|
|
991
957
|
}
|
|
992
|
-
exports.default = seleniumProxy;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@testring/plugin-selenium-driver",
|
|
3
|
-
"version": "0.6.
|
|
3
|
+
"version": "0.6.14-alpha.1",
|
|
4
4
|
"main": "./dist/index.js",
|
|
5
5
|
"typings": "./src/index.ts",
|
|
6
6
|
"repository": {
|
|
@@ -11,17 +11,19 @@
|
|
|
11
11
|
"license": "MIT",
|
|
12
12
|
"dependencies": {
|
|
13
13
|
"@nullcc/code-coverage-client": "1.4.2",
|
|
14
|
-
"@testring/child-process": "0.6.
|
|
15
|
-
"@testring/devtool-extension": "0.6.
|
|
16
|
-
"@testring/dwnld-collector-crx": "0.6.
|
|
17
|
-
"@testring/logger": "0.6.
|
|
18
|
-
"@testring/plugin-api": "0.6.
|
|
19
|
-
"@testring/types": "0.6.
|
|
20
|
-
"@types/deepmerge": "2.2.
|
|
21
|
-
"@types/node": "
|
|
14
|
+
"@testring/child-process": "0.6.14-alpha.1",
|
|
15
|
+
"@testring/devtool-extension": "0.6.14-alpha.1",
|
|
16
|
+
"@testring/dwnld-collector-crx": "0.6.14-alpha.1",
|
|
17
|
+
"@testring/logger": "0.6.14-alpha.1",
|
|
18
|
+
"@testring/plugin-api": "0.6.14-alpha.1",
|
|
19
|
+
"@testring/types": "0.6.14-alpha.1",
|
|
20
|
+
"@types/deepmerge": "2.2.3",
|
|
21
|
+
"@types/node": "22.8.5",
|
|
22
|
+
"@wdio/types": "9.2.2",
|
|
22
23
|
"chromedriver": "*",
|
|
23
|
-
"deepmerge": "4.
|
|
24
|
+
"deepmerge": "4.3.1",
|
|
25
|
+
"puppeteer-core": "22.3.0",
|
|
24
26
|
"selenium-server": "3.141.59",
|
|
25
|
-
"webdriverio": "
|
|
27
|
+
"webdriverio": "9.2.6"
|
|
26
28
|
}
|
|
27
29
|
}
|
package/src/plugin/index.ts
CHANGED
|
@@ -16,9 +16,9 @@ import type {Cookie} from '@wdio/protocols';
|
|
|
16
16
|
import type {
|
|
17
17
|
ClickOptions,
|
|
18
18
|
MockFilterOptions,
|
|
19
|
-
MockResponseParams,
|
|
20
|
-
Matches,
|
|
21
19
|
} from 'webdriverio';
|
|
20
|
+
import type {JsonCompatible} from '@wdio/types';
|
|
21
|
+
import type {RespondWithOptions} from 'webdriverio/build/utils/interception/types';
|
|
22
22
|
|
|
23
23
|
// Stupidly needed thing for making our own requests
|
|
24
24
|
const _webdriverReq = require('webdriver/build/request');
|
|
@@ -27,7 +27,6 @@ const WebDriverRequest = _webdriverReq.default;
|
|
|
27
27
|
type BrowserObjectCustom = WebdriverIO.Browser & {
|
|
28
28
|
sessionId: string;
|
|
29
29
|
deleteSessionId: (sessionId: string) => Promise<void>;
|
|
30
|
-
mockData: Record<string, Matches[]>;
|
|
31
30
|
};
|
|
32
31
|
|
|
33
32
|
type browserClientItem = {
|
|
@@ -187,14 +186,8 @@ export class SeleniumPlugin implements IBrowserProxyPlugin {
|
|
|
187
186
|
}
|
|
188
187
|
|
|
189
188
|
const googleChromeOptions = mergedConfig.capabilities?.['goog:chromeOptions'];
|
|
190
|
-
if (
|
|
191
|
-
|
|
192
|
-
(
|
|
193
|
-
googleChromeOptions.args?.includes('--headless') ||
|
|
194
|
-
googleChromeOptions.args?.includes('headless')
|
|
195
|
-
)
|
|
196
|
-
) {
|
|
197
|
-
const extensions = mergedConfig.capabilities?.['goog:chromeOptions'].extensions;
|
|
189
|
+
if (googleChromeOptions?.args?.includes('--headless=new')) {
|
|
190
|
+
const extensions = googleChromeOptions.extensions;
|
|
198
191
|
const dowldMonitorCrx = getCrxBase64();
|
|
199
192
|
if (extensions) {
|
|
200
193
|
extensions.push(dowldMonitorCrx);
|
|
@@ -215,7 +208,7 @@ export class SeleniumPlugin implements IBrowserProxyPlugin {
|
|
|
215
208
|
}
|
|
216
209
|
|
|
217
210
|
process.on('exit', () => {
|
|
218
|
-
clearInterval(this.clientCheckInterval);
|
|
211
|
+
clearInterval(this.clientCheckInterval as NodeJS.Timeout);
|
|
219
212
|
this.stopAllSessions().catch((err) => {
|
|
220
213
|
this.logger.error('Clean process exit failed', err);
|
|
221
214
|
});
|
|
@@ -1156,46 +1149,15 @@ export class SeleniumPlugin implements IBrowserProxyPlugin {
|
|
|
1156
1149
|
public async mock(
|
|
1157
1150
|
applicant: string,
|
|
1158
1151
|
url: string,
|
|
1159
|
-
overwrites:
|
|
1152
|
+
overwrites: string | JsonCompatible | Buffer,
|
|
1160
1153
|
filterOptions?: MockFilterOptions,
|
|
1161
|
-
mockResponseParams?:
|
|
1154
|
+
mockResponseParams?: Omit<RespondWithOptions, 'body'>,
|
|
1162
1155
|
) {
|
|
1163
1156
|
await this.createClient(applicant);
|
|
1164
1157
|
const client = this.getBrowserClient(applicant);
|
|
1165
1158
|
|
|
1166
1159
|
const mock = await client.mock(url, filterOptions);
|
|
1167
|
-
|
|
1168
|
-
mock.respond((res) => {
|
|
1169
|
-
overwrites(res);
|
|
1170
|
-
this.setMockData(applicant, url, res);
|
|
1171
|
-
return res.body;
|
|
1172
|
-
}, mockResponseParams);
|
|
1173
|
-
} else {
|
|
1174
|
-
mock.respond(overwrites);
|
|
1175
|
-
}
|
|
1176
|
-
}
|
|
1177
|
-
|
|
1178
|
-
public async setMockData(applicant: string, url: string, data: Matches) {
|
|
1179
|
-
await this.createClient(applicant);
|
|
1180
|
-
const client = this.getBrowserClient(applicant);
|
|
1181
|
-
|
|
1182
|
-
client.mockData = client.mockData || {};
|
|
1183
|
-
if (client.mockData[url]) {
|
|
1184
|
-
client.mockData[url].push(data);
|
|
1185
|
-
} else {
|
|
1186
|
-
client.mockData[url] = [data];
|
|
1187
|
-
}
|
|
1188
|
-
return true;
|
|
1189
|
-
}
|
|
1190
|
-
|
|
1191
|
-
public async getMockData(applicant: string, url: string) {
|
|
1192
|
-
await this.createClient(applicant);
|
|
1193
|
-
const client = this.getBrowserClient(applicant);
|
|
1194
|
-
|
|
1195
|
-
if (url) {
|
|
1196
|
-
return client.mockData[url];
|
|
1197
|
-
}
|
|
1198
|
-
return client.mockData;
|
|
1160
|
+
mock.respond(overwrites, mockResponseParams);
|
|
1199
1161
|
}
|
|
1200
1162
|
|
|
1201
1163
|
public async emulateDevice(applicant: string, deviceName) {
|
package/src/types.ts
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { Capabilities } from '@wdio/types';
|
|
2
2
|
|
|
3
|
-
export type SeleniumPluginConfig =
|
|
3
|
+
export type SeleniumPluginConfig = Capabilities.RemoteConfig & {
|
|
4
4
|
chromeDriverPath?: string;
|
|
5
5
|
recorderExtension: boolean;
|
|
6
6
|
clientCheckInterval: number;
|
|
7
7
|
clientTimeout: number;
|
|
8
8
|
host?: string; // fallback for configuration. In WebdriverIO 5 field host renamed to hostname
|
|
9
|
-
desiredCapabilities?:
|
|
9
|
+
desiredCapabilities?: Capabilities.RequestedStandaloneCapabilities[]; // fallback for configuration. In WebdriverIO 5 field renamed
|
|
10
10
|
cdpCoverage: boolean;
|
|
11
11
|
};
|