@testring/plugin-selenium-driver 0.6.11 → 0.6.13

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.
@@ -14,6 +14,7 @@ const webdriverio_1 = require("webdriverio");
14
14
  const deepmerge = require("deepmerge");
15
15
  const child_process_1 = require("@testring/child-process");
16
16
  const logger_1 = require("@testring/logger");
17
+ const dwnld_collector_crx_1 = require("@testring/dwnld-collector-crx");
17
18
  const devtool_extension_1 = require("@testring/devtool-extension");
18
19
  const code_coverage_client_1 = require("@nullcc/code-coverage-client");
19
20
  // Stupidly needed thing for making our own requests
@@ -32,7 +33,7 @@ const DEFAULT_CONFIG = {
32
33
  args: [],
33
34
  },
34
35
  },
35
- cdpCoverage: false
36
+ cdpCoverage: false,
36
37
  };
37
38
  function delay(timeout) {
38
39
  return new Promise((resolve) => setTimeout(() => resolve(), timeout));
@@ -73,6 +74,7 @@ class SeleniumPlugin {
73
74
  }
74
75
  // eslint-disable-next-line sonarjs/cognitive-complexity
75
76
  createConfig(config) {
77
+ var _a, _b;
76
78
  let mergedConfig = deepmerge.all([DEFAULT_CONFIG, config], {
77
79
  clone: true,
78
80
  });
@@ -127,6 +129,17 @@ class SeleniumPlugin {
127
129
  if (!mergedConfig.hostname && mergedConfig.host) {
128
130
  mergedConfig.hostname = mergedConfig.host;
129
131
  }
132
+ const googleChromeOptions = (_a = mergedConfig.capabilities) === null || _a === void 0 ? void 0 : _a['goog:chromeOptions'];
133
+ if ((_b = googleChromeOptions === null || googleChromeOptions === void 0 ? void 0 : googleChromeOptions.args) === null || _b === void 0 ? void 0 : _b.includes('--headless=new')) {
134
+ const extensions = googleChromeOptions.extensions;
135
+ const dowldMonitorCrx = (0, dwnld_collector_crx_1.getCrxBase64)();
136
+ if (extensions) {
137
+ extensions.push(dowldMonitorCrx);
138
+ }
139
+ else {
140
+ googleChromeOptions.extensions = [dowldMonitorCrx];
141
+ }
142
+ }
130
143
  return mergedConfig;
131
144
  }
132
145
  initIntervals() {
@@ -259,7 +272,11 @@ class SeleniumPlugin {
259
272
  if (this.expiredBrowserClients.has(applicant)) {
260
273
  throw Error(`This session expired in ${this.config.clientTimeout}ms`);
261
274
  }
262
- const _config = deepmerge.all([{}, this.config, config || {}]);
275
+ const _config = deepmerge.all([
276
+ {},
277
+ this.config,
278
+ config || {},
279
+ ]);
263
280
  const client = yield (0, webdriverio_1.remote)(_config);
264
281
  let sessionId;
265
282
  if (client.sessionId) {
@@ -324,7 +341,7 @@ class SeleniumPlugin {
324
341
  // Creating our delete selenium session to be able to close
325
342
  // session if it's id is changed while we are running test
326
343
  client.addCommand('deleteSessionId', function (sessionId) {
327
- const { w3cCaps, jsonwpCaps, } = this.options.requestedCapabilities;
344
+ const { w3cCaps, jsonwpCaps } = this.options.requestedCapabilities;
328
345
  const sessionDeleteRequest = new WebDriverRequest('DELETE', '/session/:sessionId', {
329
346
  capabilities: w3cCaps,
330
347
  desiredCapabilities: jsonwpCaps, // JSONWP compliant
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@testring/plugin-selenium-driver",
3
- "version": "0.6.11",
3
+ "version": "0.6.13",
4
4
  "main": "./dist/index.js",
5
5
  "typings": "./src/index.ts",
6
6
  "repository": {
@@ -11,11 +11,12 @@
11
11
  "license": "MIT",
12
12
  "dependencies": {
13
13
  "@nullcc/code-coverage-client": "1.4.2",
14
- "@testring/child-process": "0.6.11",
15
- "@testring/devtool-extension": "0.6.11",
16
- "@testring/logger": "0.6.11",
17
- "@testring/plugin-api": "0.6.11",
18
- "@testring/types": "0.6.11",
14
+ "@testring/child-process": "0.6.13",
15
+ "@testring/devtool-extension": "0.6.13",
16
+ "@testring/dwnld-collector-crx": "0.6.13",
17
+ "@testring/logger": "0.6.13",
18
+ "@testring/plugin-api": "0.6.13",
19
+ "@testring/types": "0.6.13",
19
20
  "@types/deepmerge": "2.2.0",
20
21
  "@types/node": "18.11.18",
21
22
  "chromedriver": "*",
@@ -8,6 +8,7 @@ import * as deepmerge from 'deepmerge';
8
8
 
9
9
  import {spawn} from '@testring/child-process';
10
10
  import {loggerClient} from '@testring/logger';
11
+ import {getCrxBase64} from '@testring/dwnld-collector-crx';
11
12
  import {absoluteExtensionPath} from '@testring/devtool-extension';
12
13
  import {CDPCoverageCollector} from '@nullcc/code-coverage-client';
13
14
 
@@ -49,7 +50,7 @@ const DEFAULT_CONFIG: SeleniumPluginConfig = {
49
50
  args: [] as string[],
50
51
  },
51
52
  },
52
- cdpCoverage: false
53
+ cdpCoverage: false,
53
54
  };
54
55
 
55
56
  function delay(timeout) {
@@ -185,6 +186,17 @@ export class SeleniumPlugin implements IBrowserProxyPlugin {
185
186
  mergedConfig.hostname = mergedConfig.host;
186
187
  }
187
188
 
189
+ const googleChromeOptions = mergedConfig.capabilities?.['goog:chromeOptions'];
190
+ if (googleChromeOptions?.args?.includes('--headless=new')) {
191
+ const extensions = googleChromeOptions.extensions;
192
+ const dowldMonitorCrx = getCrxBase64();
193
+ if (extensions) {
194
+ extensions.push(dowldMonitorCrx);
195
+ } else {
196
+ googleChromeOptions.extensions = [dowldMonitorCrx];
197
+ }
198
+ }
199
+
188
200
  return mergedConfig;
189
201
  }
190
202
 
@@ -331,7 +343,10 @@ export class SeleniumPlugin implements IBrowserProxyPlugin {
331
343
  }
332
344
  }
333
345
 
334
- private async createClient(applicant: string, config?: Partial<WebdriverIO.Config>): Promise<void> {
346
+ private async createClient(
347
+ applicant: string,
348
+ config?: Partial<WebdriverIO.Config>,
349
+ ): Promise<void> {
335
350
  await this.waitForReadyState;
336
351
  const clientData = this.browserClients.get(applicant);
337
352
 
@@ -350,7 +365,11 @@ export class SeleniumPlugin implements IBrowserProxyPlugin {
350
365
  );
351
366
  }
352
367
 
353
- const _config: any = deepmerge.all([{}, this.config, config as any || {}]);
368
+ const _config: any = deepmerge.all([
369
+ {},
370
+ this.config,
371
+ (config as any) || {},
372
+ ]);
354
373
  const client = await remote(_config);
355
374
 
356
375
  let sessionId: string;
@@ -424,10 +443,8 @@ export class SeleniumPlugin implements IBrowserProxyPlugin {
424
443
  client.addCommand(
425
444
  'deleteSessionId',
426
445
  function (sessionId) {
427
- const {
428
- w3cCaps,
429
- jsonwpCaps,
430
- } = this.options.requestedCapabilities;
446
+ const {w3cCaps, jsonwpCaps} =
447
+ this.options.requestedCapabilities;
431
448
 
432
449
  const sessionDeleteRequest = new WebDriverRequest(
433
450
  'DELETE',
@@ -1189,7 +1206,7 @@ export class SeleniumPlugin implements IBrowserProxyPlugin {
1189
1206
  },
1190
1207
  },
1191
1208
  },
1192
- } as any)
1209
+ } as any);
1193
1210
  }
1194
1211
  }
1195
1212