@testring/plugin-selenium-driver 0.6.11 → 0.6.12

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, _c, _d;
76
78
  let mergedConfig = deepmerge.all([DEFAULT_CONFIG, config], {
77
79
  clone: true,
78
80
  });
@@ -127,6 +129,19 @@ 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 (googleChromeOptions &&
134
+ (((_b = googleChromeOptions.args) === null || _b === void 0 ? void 0 : _b.includes('--headless')) ||
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;
137
+ const dowldMonitorCrx = (0, dwnld_collector_crx_1.getCrxBase64)();
138
+ if (extensions) {
139
+ extensions.push(dowldMonitorCrx);
140
+ }
141
+ else {
142
+ googleChromeOptions.extensions = [dowldMonitorCrx];
143
+ }
144
+ }
130
145
  return mergedConfig;
131
146
  }
132
147
  initIntervals() {
@@ -259,7 +274,11 @@ class SeleniumPlugin {
259
274
  if (this.expiredBrowserClients.has(applicant)) {
260
275
  throw Error(`This session expired in ${this.config.clientTimeout}ms`);
261
276
  }
262
- const _config = deepmerge.all([{}, this.config, config || {}]);
277
+ const _config = deepmerge.all([
278
+ {},
279
+ this.config,
280
+ config || {},
281
+ ]);
263
282
  const client = yield (0, webdriverio_1.remote)(_config);
264
283
  let sessionId;
265
284
  if (client.sessionId) {
@@ -324,7 +343,7 @@ class SeleniumPlugin {
324
343
  // Creating our delete selenium session to be able to close
325
344
  // session if it's id is changed while we are running test
326
345
  client.addCommand('deleteSessionId', function (sessionId) {
327
- const { w3cCaps, jsonwpCaps, } = this.options.requestedCapabilities;
346
+ const { w3cCaps, jsonwpCaps } = this.options.requestedCapabilities;
328
347
  const sessionDeleteRequest = new WebDriverRequest('DELETE', '/session/:sessionId', {
329
348
  capabilities: w3cCaps,
330
349
  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.12",
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.12",
15
+ "@testring/devtool-extension": "0.6.12",
16
+ "@testring/dwnld-collector-crx": "0.6.12",
17
+ "@testring/logger": "0.6.12",
18
+ "@testring/plugin-api": "0.6.12",
19
+ "@testring/types": "0.6.12",
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,23 @@ export class SeleniumPlugin implements IBrowserProxyPlugin {
185
186
  mergedConfig.hostname = mergedConfig.host;
186
187
  }
187
188
 
189
+ const googleChromeOptions = mergedConfig.capabilities?.['goog:chromeOptions'];
190
+ if (
191
+ googleChromeOptions &&
192
+ (
193
+ googleChromeOptions.args?.includes('--headless') ||
194
+ googleChromeOptions.args?.includes('headless')
195
+ )
196
+ ) {
197
+ const extensions = mergedConfig.capabilities?.['goog:chromeOptions'].extensions;
198
+ const dowldMonitorCrx = getCrxBase64();
199
+ if (extensions) {
200
+ extensions.push(dowldMonitorCrx);
201
+ } else {
202
+ googleChromeOptions.extensions = [dowldMonitorCrx];
203
+ }
204
+ }
205
+
188
206
  return mergedConfig;
189
207
  }
190
208
 
@@ -331,7 +349,10 @@ export class SeleniumPlugin implements IBrowserProxyPlugin {
331
349
  }
332
350
  }
333
351
 
334
- private async createClient(applicant: string, config?: Partial<WebdriverIO.Config>): Promise<void> {
352
+ private async createClient(
353
+ applicant: string,
354
+ config?: Partial<WebdriverIO.Config>,
355
+ ): Promise<void> {
335
356
  await this.waitForReadyState;
336
357
  const clientData = this.browserClients.get(applicant);
337
358
 
@@ -350,7 +371,11 @@ export class SeleniumPlugin implements IBrowserProxyPlugin {
350
371
  );
351
372
  }
352
373
 
353
- const _config: any = deepmerge.all([{}, this.config, config as any || {}]);
374
+ const _config: any = deepmerge.all([
375
+ {},
376
+ this.config,
377
+ (config as any) || {},
378
+ ]);
354
379
  const client = await remote(_config);
355
380
 
356
381
  let sessionId: string;
@@ -424,10 +449,8 @@ export class SeleniumPlugin implements IBrowserProxyPlugin {
424
449
  client.addCommand(
425
450
  'deleteSessionId',
426
451
  function (sessionId) {
427
- const {
428
- w3cCaps,
429
- jsonwpCaps,
430
- } = this.options.requestedCapabilities;
452
+ const {w3cCaps, jsonwpCaps} =
453
+ this.options.requestedCapabilities;
431
454
 
432
455
  const sessionDeleteRequest = new WebDriverRequest(
433
456
  'DELETE',
@@ -1189,7 +1212,7 @@ export class SeleniumPlugin implements IBrowserProxyPlugin {
1189
1212
  },
1190
1213
  },
1191
1214
  },
1192
- } as any)
1215
+ } as any);
1193
1216
  }
1194
1217
  }
1195
1218