@testring/plugin-selenium-driver 0.6.7 → 0.6.8
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/plugin/index.js +20 -2
- package/package.json +6 -6
- package/src/plugin/index.ts +20 -2
package/dist/plugin/index.js
CHANGED
|
@@ -248,7 +248,7 @@ class SeleniumPlugin {
|
|
|
248
248
|
}
|
|
249
249
|
});
|
|
250
250
|
}
|
|
251
|
-
createClient(applicant) {
|
|
251
|
+
createClient(applicant, config) {
|
|
252
252
|
return __awaiter(this, void 0, void 0, function* () {
|
|
253
253
|
yield this.waitForReadyState;
|
|
254
254
|
const clientData = this.browserClients.get(applicant);
|
|
@@ -259,7 +259,8 @@ class SeleniumPlugin {
|
|
|
259
259
|
if (this.expiredBrowserClients.has(applicant)) {
|
|
260
260
|
throw Error(`This session expired in ${this.config.clientTimeout}ms`);
|
|
261
261
|
}
|
|
262
|
-
const
|
|
262
|
+
const _config = deepmerge.all([{}, this.config, config || {}]);
|
|
263
|
+
const client = yield (0, webdriverio_1.remote)(_config);
|
|
263
264
|
let sessionId;
|
|
264
265
|
if (client.sessionId) {
|
|
265
266
|
sessionId = client.sessionId;
|
|
@@ -947,6 +948,23 @@ class SeleniumPlugin {
|
|
|
947
948
|
return client.mockData;
|
|
948
949
|
});
|
|
949
950
|
}
|
|
951
|
+
emulateDevice(applicant, deviceName) {
|
|
952
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
953
|
+
yield this.createClient(applicant);
|
|
954
|
+
const client = this.getBrowserClient(applicant);
|
|
955
|
+
yield client.deleteSession();
|
|
956
|
+
this.browserClients.delete(applicant);
|
|
957
|
+
yield this.createClient(applicant, {
|
|
958
|
+
capabilities: {
|
|
959
|
+
'goog:chromeOptions': {
|
|
960
|
+
mobileEmulation: {
|
|
961
|
+
deviceName,
|
|
962
|
+
},
|
|
963
|
+
},
|
|
964
|
+
},
|
|
965
|
+
});
|
|
966
|
+
});
|
|
967
|
+
}
|
|
950
968
|
}
|
|
951
969
|
exports.SeleniumPlugin = SeleniumPlugin;
|
|
952
970
|
function seleniumProxy(config) {
|
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.8",
|
|
4
4
|
"main": "./dist/index.js",
|
|
5
5
|
"typings": "./src/index.ts",
|
|
6
6
|
"repository": {
|
|
@@ -11,11 +11,11 @@
|
|
|
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/logger": "0.6.
|
|
17
|
-
"@testring/plugin-api": "0.6.
|
|
18
|
-
"@testring/types": "0.6.
|
|
14
|
+
"@testring/child-process": "0.6.8",
|
|
15
|
+
"@testring/devtool-extension": "0.6.8",
|
|
16
|
+
"@testring/logger": "0.6.8",
|
|
17
|
+
"@testring/plugin-api": "0.6.8",
|
|
18
|
+
"@testring/types": "0.6.8",
|
|
19
19
|
"@types/deepmerge": "2.2.0",
|
|
20
20
|
"@types/node": "18.11.18",
|
|
21
21
|
"chromedriver": "*",
|
package/src/plugin/index.ts
CHANGED
|
@@ -331,7 +331,7 @@ export class SeleniumPlugin implements IBrowserProxyPlugin {
|
|
|
331
331
|
}
|
|
332
332
|
}
|
|
333
333
|
|
|
334
|
-
private async createClient(applicant: string): Promise<void> {
|
|
334
|
+
private async createClient(applicant: string, config?: Partial<WebdriverIO.Config>): Promise<void> {
|
|
335
335
|
await this.waitForReadyState;
|
|
336
336
|
const clientData = this.browserClients.get(applicant);
|
|
337
337
|
|
|
@@ -350,7 +350,8 @@ export class SeleniumPlugin implements IBrowserProxyPlugin {
|
|
|
350
350
|
);
|
|
351
351
|
}
|
|
352
352
|
|
|
353
|
-
const
|
|
353
|
+
const _config: any = deepmerge.all([{}, this.config, config as any || {}]);
|
|
354
|
+
const client = await remote(_config);
|
|
354
355
|
|
|
355
356
|
let sessionId: string;
|
|
356
357
|
if (client.sessionId) {
|
|
@@ -1173,6 +1174,23 @@ export class SeleniumPlugin implements IBrowserProxyPlugin {
|
|
|
1173
1174
|
}
|
|
1174
1175
|
return client.mockData;
|
|
1175
1176
|
}
|
|
1177
|
+
|
|
1178
|
+
public async emulateDevice(applicant: string, deviceName) {
|
|
1179
|
+
await this.createClient(applicant);
|
|
1180
|
+
const client = this.getBrowserClient(applicant);
|
|
1181
|
+
|
|
1182
|
+
await client.deleteSession();
|
|
1183
|
+
this.browserClients.delete(applicant);
|
|
1184
|
+
await this.createClient(applicant, {
|
|
1185
|
+
capabilities: {
|
|
1186
|
+
'goog:chromeOptions': {
|
|
1187
|
+
mobileEmulation: {
|
|
1188
|
+
deviceName,
|
|
1189
|
+
},
|
|
1190
|
+
},
|
|
1191
|
+
},
|
|
1192
|
+
} as any)
|
|
1193
|
+
}
|
|
1176
1194
|
}
|
|
1177
1195
|
|
|
1178
1196
|
export default function seleniumProxy(config: SeleniumPluginConfig) {
|