@testring/plugin-selenium-driver 0.6.13 → 0.6.14-alpha.2
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 +8 -41
- package/package.json +13 -11
- package/src/plugin/index.ts +6 -38
- 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");
|
|
@@ -343,7 +344,7 @@ class SeleniumPlugin {
|
|
|
343
344
|
client.addCommand('deleteSessionId', function (sessionId) {
|
|
344
345
|
const { w3cCaps, jsonwpCaps } = this.options.requestedCapabilities;
|
|
345
346
|
const sessionDeleteRequest = new WebDriverRequest('DELETE', '/session/:sessionId', {
|
|
346
|
-
capabilities: w3cCaps,
|
|
347
|
+
capabilities: w3cCaps, // W3C compliant
|
|
347
348
|
desiredCapabilities: jsonwpCaps, // JSONWP compliant
|
|
348
349
|
});
|
|
349
350
|
return sessionDeleteRequest.makeRequest(this.options, sessionId);
|
|
@@ -445,8 +446,8 @@ class SeleniumPlugin {
|
|
|
445
446
|
this.incrementWinId++;
|
|
446
447
|
return `window-${this.incrementWinId}`;
|
|
447
448
|
}
|
|
448
|
-
newWindow(
|
|
449
|
-
return __awaiter(this,
|
|
449
|
+
newWindow(applicant_1, val_1, windowName_1) {
|
|
450
|
+
return __awaiter(this, arguments, void 0, function* (applicant, val, windowName, windowFeatures = {}) {
|
|
450
451
|
yield this.createClient(applicant);
|
|
451
452
|
const client = this.getBrowserClient(applicant);
|
|
452
453
|
const args = stringifyWindowFeatures(windowFeatures);
|
|
@@ -480,8 +481,8 @@ class SeleniumPlugin {
|
|
|
480
481
|
return selector.isDisplayed();
|
|
481
482
|
});
|
|
482
483
|
}
|
|
483
|
-
moveToObject(
|
|
484
|
-
return __awaiter(this,
|
|
484
|
+
moveToObject(applicant_1, xpath_1) {
|
|
485
|
+
return __awaiter(this, arguments, void 0, function* (applicant, xpath, xOffset = 0, yOffset = 0) {
|
|
485
486
|
yield this.createClient(applicant);
|
|
486
487
|
const client = this.getBrowserClient(applicant);
|
|
487
488
|
const selector = yield client.$(xpath);
|
|
@@ -690,8 +691,8 @@ class SeleniumPlugin {
|
|
|
690
691
|
});
|
|
691
692
|
}
|
|
692
693
|
getCookie(applicant, cookieName) {
|
|
693
|
-
var _a;
|
|
694
694
|
return __awaiter(this, void 0, void 0, function* () {
|
|
695
|
+
var _a;
|
|
695
696
|
yield this.createClient(applicant);
|
|
696
697
|
const client = this.getBrowserClient(applicant);
|
|
697
698
|
if (cookieName) {
|
|
@@ -929,40 +930,7 @@ class SeleniumPlugin {
|
|
|
929
930
|
yield this.createClient(applicant);
|
|
930
931
|
const client = this.getBrowserClient(applicant);
|
|
931
932
|
const mock = yield client.mock(url, filterOptions);
|
|
932
|
-
|
|
933
|
-
mock.respond((res) => {
|
|
934
|
-
overwrites(res);
|
|
935
|
-
this.setMockData(applicant, url, res);
|
|
936
|
-
return res.body;
|
|
937
|
-
}, mockResponseParams);
|
|
938
|
-
}
|
|
939
|
-
else {
|
|
940
|
-
mock.respond(overwrites);
|
|
941
|
-
}
|
|
942
|
-
});
|
|
943
|
-
}
|
|
944
|
-
setMockData(applicant, url, data) {
|
|
945
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
946
|
-
yield this.createClient(applicant);
|
|
947
|
-
const client = this.getBrowserClient(applicant);
|
|
948
|
-
client.mockData = client.mockData || {};
|
|
949
|
-
if (client.mockData[url]) {
|
|
950
|
-
client.mockData[url].push(data);
|
|
951
|
-
}
|
|
952
|
-
else {
|
|
953
|
-
client.mockData[url] = [data];
|
|
954
|
-
}
|
|
955
|
-
return true;
|
|
956
|
-
});
|
|
957
|
-
}
|
|
958
|
-
getMockData(applicant, url) {
|
|
959
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
960
|
-
yield this.createClient(applicant);
|
|
961
|
-
const client = this.getBrowserClient(applicant);
|
|
962
|
-
if (url) {
|
|
963
|
-
return client.mockData[url];
|
|
964
|
-
}
|
|
965
|
-
return client.mockData;
|
|
933
|
+
mock.respond(overwrites, mockResponseParams);
|
|
966
934
|
});
|
|
967
935
|
}
|
|
968
936
|
emulateDevice(applicant, deviceName) {
|
|
@@ -987,4 +955,3 @@ exports.SeleniumPlugin = SeleniumPlugin;
|
|
|
987
955
|
function seleniumProxy(config) {
|
|
988
956
|
return new SeleniumPlugin(config);
|
|
989
957
|
}
|
|
990
|
-
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.2",
|
|
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.2",
|
|
15
|
+
"@testring/devtool-extension": "0.6.14-alpha.2",
|
|
16
|
+
"@testring/dwnld-collector-crx": "0.6.14-alpha.2",
|
|
17
|
+
"@testring/logger": "0.6.14-alpha.2",
|
|
18
|
+
"@testring/plugin-api": "0.6.14-alpha.2",
|
|
19
|
+
"@testring/types": "0.6.14-alpha.2",
|
|
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 = {
|
|
@@ -209,7 +208,7 @@ export class SeleniumPlugin implements IBrowserProxyPlugin {
|
|
|
209
208
|
}
|
|
210
209
|
|
|
211
210
|
process.on('exit', () => {
|
|
212
|
-
clearInterval(this.clientCheckInterval);
|
|
211
|
+
clearInterval(this.clientCheckInterval as NodeJS.Timeout);
|
|
213
212
|
this.stopAllSessions().catch((err) => {
|
|
214
213
|
this.logger.error('Clean process exit failed', err);
|
|
215
214
|
});
|
|
@@ -1150,46 +1149,15 @@ export class SeleniumPlugin implements IBrowserProxyPlugin {
|
|
|
1150
1149
|
public async mock(
|
|
1151
1150
|
applicant: string,
|
|
1152
1151
|
url: string,
|
|
1153
|
-
overwrites:
|
|
1152
|
+
overwrites: string | JsonCompatible | Buffer,
|
|
1154
1153
|
filterOptions?: MockFilterOptions,
|
|
1155
|
-
mockResponseParams?:
|
|
1154
|
+
mockResponseParams?: Omit<RespondWithOptions, 'body'>,
|
|
1156
1155
|
) {
|
|
1157
1156
|
await this.createClient(applicant);
|
|
1158
1157
|
const client = this.getBrowserClient(applicant);
|
|
1159
1158
|
|
|
1160
1159
|
const mock = await client.mock(url, filterOptions);
|
|
1161
|
-
|
|
1162
|
-
mock.respond((res) => {
|
|
1163
|
-
overwrites(res);
|
|
1164
|
-
this.setMockData(applicant, url, res);
|
|
1165
|
-
return res.body;
|
|
1166
|
-
}, mockResponseParams);
|
|
1167
|
-
} else {
|
|
1168
|
-
mock.respond(overwrites);
|
|
1169
|
-
}
|
|
1170
|
-
}
|
|
1171
|
-
|
|
1172
|
-
public async setMockData(applicant: string, url: string, data: Matches) {
|
|
1173
|
-
await this.createClient(applicant);
|
|
1174
|
-
const client = this.getBrowserClient(applicant);
|
|
1175
|
-
|
|
1176
|
-
client.mockData = client.mockData || {};
|
|
1177
|
-
if (client.mockData[url]) {
|
|
1178
|
-
client.mockData[url].push(data);
|
|
1179
|
-
} else {
|
|
1180
|
-
client.mockData[url] = [data];
|
|
1181
|
-
}
|
|
1182
|
-
return true;
|
|
1183
|
-
}
|
|
1184
|
-
|
|
1185
|
-
public async getMockData(applicant: string, url: string) {
|
|
1186
|
-
await this.createClient(applicant);
|
|
1187
|
-
const client = this.getBrowserClient(applicant);
|
|
1188
|
-
|
|
1189
|
-
if (url) {
|
|
1190
|
-
return client.mockData[url];
|
|
1191
|
-
}
|
|
1192
|
-
return client.mockData;
|
|
1160
|
+
mock.respond(overwrites, mockResponseParams);
|
|
1193
1161
|
}
|
|
1194
1162
|
|
|
1195
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
|
};
|