@mablhq/mabl-cli 1.12.6 → 1.12.24

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.
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.LifecycleEvent = exports.BrowserLauncherFactory = exports.TimeoutError = exports.RunnerError = exports.RUNNER_ERRORS = exports.PageEvent = exports.BrowserEvent = void 0;
3
+ exports.LifecycleEvent = exports.BrowserLauncherFactory = exports.Frame = exports.TimeoutError = exports.RunnerError = exports.RUNNER_ERRORS = exports.PageEvent = exports.BrowserEvent = void 0;
4
4
  var browserEvent_1 = require("./browserEvent");
5
5
  Object.defineProperty(exports, "BrowserEvent", { enumerable: true, get: function () { return browserEvent_1.BrowserEvent; } });
6
6
  var pageEvent_1 = require("./pageEvent");
@@ -9,6 +9,8 @@ var errors_1 = require("./errors");
9
9
  Object.defineProperty(exports, "RUNNER_ERRORS", { enumerable: true, get: function () { return errors_1.RUNNER_ERRORS; } });
10
10
  Object.defineProperty(exports, "RunnerError", { enumerable: true, get: function () { return errors_1.RunnerError; } });
11
11
  Object.defineProperty(exports, "TimeoutError", { enumerable: true, get: function () { return errors_1.TimeoutError; } });
12
+ var frame_1 = require("./frame");
13
+ Object.defineProperty(exports, "Frame", { enumerable: true, get: function () { return frame_1.Frame; } });
12
14
  var browserLauncherFactory_1 = require("./browserLauncherFactory");
13
15
  Object.defineProperty(exports, "BrowserLauncherFactory", { enumerable: true, get: function () { return browserLauncherFactory_1.BrowserLauncherFactory; } });
14
16
  var types_1 = require("./types");
@@ -1,6 +1,13 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.isElementHandle = void 0;
3
+ exports.isElementHandle = exports.getHighlightColor = exports.MAX_HIGHLIGHT_OPACITY = void 0;
4
+ exports.MAX_HIGHLIGHT_OPACITY = 0.9;
5
+ exports.getHighlightColor = (transparency) => ({
6
+ r: 196,
7
+ g: 68,
8
+ b: 183,
9
+ a: transparency,
10
+ });
4
11
  function isElementHandle(value) {
5
12
  return (value &&
6
13
  typeof value === 'object' &&
@@ -1,2 +1,17 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.Frame = void 0;
4
+ const frameBase_1 = require("./frameBase");
5
+ const loggingProvider_1 = require("../providers/logging/loggingProvider");
6
+ class Frame extends frameBase_1.FrameBase {
7
+ getFrameId() {
8
+ const frameId = this.id();
9
+ if (typeof frameId !== 'string' ||
10
+ frameId.length < 20 ||
11
+ frameId.length > 40) {
12
+ loggingProvider_1.logger.warn(`Warning: The frame ID value is unexpected. It was: ${frameId}`);
13
+ }
14
+ return frameId;
15
+ }
16
+ }
17
+ exports.Frame = Frame;
@@ -1,2 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.FrameBase = void 0;
4
+ class FrameBase {
5
+ }
6
+ exports.FrameBase = FrameBase;
@@ -23,6 +23,8 @@ exports.PlaywrightElementHandle = exports.PlaywrightJsHandle = void 0;
23
23
  const playwright = __importStar(require("@playwright/test"));
24
24
  const utils_1 = require("../utils");
25
25
  const logUtils_1 = require("../../util/logUtils");
26
+ const elementHandle_1 = require("../elementHandle");
27
+ const testsUtil_1 = require("../../commands/tests/testsUtil");
26
28
  class PlaywrightJsHandle {
27
29
  constructor(handle, page) {
28
30
  this.handle = handle;
@@ -51,43 +53,60 @@ class PlaywrightJsHandle {
51
53
  }
52
54
  static unwrapProperties(arg, addSecondaryWorldFlag = false) {
53
55
  if (arg === undefined) {
54
- return addSecondaryWorldFlag ? { useSecondaryWorld: true } : null;
56
+ return addSecondaryWorldFlag ? { secondaryWorldValue: undefined } : null;
55
57
  }
56
- if (addSecondaryWorldFlag &&
57
- (arg instanceof PlaywrightJsHandle || typeof arg !== 'object')) {
58
+ if (addSecondaryWorldFlag && arg instanceof PlaywrightJsHandle) {
58
59
  throw new Error('Unable to setup the secondary world if the argument is a JsHandle. Pass an object instead');
59
60
  }
61
+ let result = arg;
60
62
  if (arg instanceof PlaywrightJsHandle) {
61
- return arg.getPlaywrightHandle();
63
+ result = arg.getPlaywrightHandle();
62
64
  }
63
- if (typeof arg !== 'object') {
64
- return arg;
65
+ else if ((typeof arg !== 'object' || Array.isArray(arg)) &&
66
+ !addSecondaryWorldFlag) {
67
+ result = arg;
65
68
  }
66
- if (addSecondaryWorldFlag) {
67
- arg.useSecondaryWorld = true;
68
- }
69
- if (typeof arg === 'object' &&
69
+ else if (typeof arg === 'object' &&
70
70
  !Object.keys(arg).some(key => arg[key] instanceof PlaywrightJsHandle)) {
71
- return arg;
71
+ result = arg;
72
72
  }
73
- const unwrapped = { ...arg };
74
- Object.keys(arg).forEach(propertyName => {
75
- const propertyValue = unwrapped[propertyName];
76
- if (propertyValue instanceof PlaywrightJsHandle) {
77
- unwrapped[propertyName] = propertyValue.getPlaywrightHandle();
78
- }
79
- });
80
- return unwrapped;
73
+ else if (typeof arg === 'object' && !Array.isArray(arg)) {
74
+ const unwrapped = { ...arg };
75
+ Object.keys(arg).forEach(propertyName => {
76
+ const propertyValue = unwrapped[propertyName];
77
+ if (propertyValue instanceof PlaywrightJsHandle) {
78
+ unwrapped[propertyName] = propertyValue.getPlaywrightHandle();
79
+ }
80
+ });
81
+ result = unwrapped;
82
+ }
83
+ return addSecondaryWorldFlag ? { secondaryWorldValue: result } : result;
81
84
  }
82
85
  }
83
86
  exports.PlaywrightJsHandle = PlaywrightJsHandle;
84
87
  class PlaywrightElementHandle extends PlaywrightJsHandle {
85
88
  constructor(element, page) {
89
+ var _a, _b, _c, _d, _e, _f;
86
90
  super(element, page);
87
91
  this.element = element;
88
92
  this.page = page;
89
93
  try {
90
94
  this.elementImpl = playwright._toImpl(this.element);
95
+ this.cdpSession = (_c = (_b = (_a = this.elementImpl) === null || _a === void 0 ? void 0 : _a._context) === null || _b === void 0 ? void 0 : _b._delegate) === null || _c === void 0 ? void 0 : _c._client;
96
+ if (this.elementImpl === undefined) {
97
+ logUtils_1.logInternal(`Unable to get the Element's internal implementation.
98
+ Some functionality, such as getting the clickable point or element highlighting might not work.`);
99
+ }
100
+ else if (this.cdpSession === undefined) {
101
+ const undefinedField = ((_e = (_d = this.elementImpl) === null || _d === void 0 ? void 0 : _d._context) === null || _e === void 0 ? void 0 : _e._delegate) !== undefined
102
+ ? '_client'
103
+ : ((_f = this.elementImpl) === null || _f === void 0 ? void 0 : _f._context) !== undefined
104
+ ? '_delegate'
105
+ : '_context';
106
+ logUtils_1.logInternal(`Unable to get the CDP Session of the element handle.
107
+ ${undefinedField} is undefined.
108
+ Some functionality, such as element highlighting will not work.`);
109
+ }
91
110
  }
92
111
  catch (e) {
93
112
  logUtils_1.logInternal(`Unable to get the element handle's implementation. Error: ${e}`);
@@ -142,16 +161,71 @@ class PlaywrightElementHandle extends PlaywrightJsHandle {
142
161
  select(value) {
143
162
  return this.element.selectOption(value);
144
163
  }
145
- async type(text) {
164
+ async type(text, options) {
146
165
  await this.element.focus();
147
- await this.element.selectText();
148
- return this.element.type(text);
166
+ await this.element.selectText({ force: true });
167
+ return this.element.type(text, options);
149
168
  }
150
169
  press(key) {
151
170
  return this.element.press(key);
152
171
  }
153
172
  getRemoteObjectId() {
154
- return this.getElementImpl()._objectId;
173
+ var _a, _b, _c;
174
+ if (((_a = this.elementImpl) === null || _a === void 0 ? void 0 : _a._objectId) === undefined) {
175
+ logUtils_1.logInternal('ObjectId of an element handle was not found.');
176
+ }
177
+ return (_c = (_b = this.elementImpl) === null || _b === void 0 ? void 0 : _b._objectId) !== null && _c !== void 0 ? _c : '';
178
+ }
179
+ async highlight(highlightDurationMillis, highlightPhases) {
180
+ await this.enableDom();
181
+ await this.enableOverlay();
182
+ const nodeInfo = await this.makeCdpCall('DOM.describeNode', {
183
+ objectId: this.getRemoteObjectId(),
184
+ depth: -1,
185
+ pierce: true,
186
+ });
187
+ const highlightConfig = {
188
+ backendNodeId: nodeInfo.node.backendNodeId,
189
+ highlightConfig: {
190
+ borderColor: elementHandle_1.getHighlightColor(0),
191
+ contentColor: elementHandle_1.getHighlightColor(1),
192
+ colorFormat: 'rgb',
193
+ },
194
+ };
195
+ await this.fadeInOutHighlight(highlightConfig, highlightDurationMillis, highlightPhases);
196
+ await this.hideHighlight();
197
+ }
198
+ async getValue() {
199
+ return this.element.inputValue();
200
+ }
201
+ async fadeInOutHighlight(highlightConfig, highlightDurationMillis, highlightPhases) {
202
+ var _a;
203
+ if (highlightPhases <= 0) {
204
+ throw new Error('Highlight phases must be greater than 0');
205
+ }
206
+ const phaseIntervalMilliseconds = highlightDurationMillis / highlightPhases;
207
+ for (let iteration = 0; iteration < highlightPhases; iteration++) {
208
+ if (((_a = highlightConfig.highlightConfig.contentColor) === null || _a === void 0 ? void 0 : _a.a) !== undefined) {
209
+ const x = iteration / highlightPhases;
210
+ highlightConfig.highlightConfig.contentColor.a =
211
+ x * (1 - x) * 4 * elementHandle_1.MAX_HIGHLIGHT_OPACITY;
212
+ }
213
+ await this.makeCdpCall('Overlay.highlightNode', highlightConfig);
214
+ await testsUtil_1.sleep(phaseIntervalMilliseconds);
215
+ }
216
+ }
217
+ async enableDom() {
218
+ await this.makeCdpCall('DOM.enable');
219
+ }
220
+ async enableOverlay() {
221
+ await this.makeCdpCall('Overlay.enable');
222
+ }
223
+ async hideHighlight() {
224
+ await this.makeCdpCall('Overlay.hideHighlight');
225
+ }
226
+ async makeCdpCall(method, paramArgs) {
227
+ var _a;
228
+ return ((_a = this.cdpSession) !== null && _a !== void 0 ? _a : (await this.page.getCdpSession())).send(method, paramArgs);
155
229
  }
156
230
  }
157
231
  exports.PlaywrightElementHandle = PlaywrightElementHandle;
@@ -27,8 +27,9 @@ const playwrightHttpResponse_1 = require("./playwrightHttpResponse");
27
27
  const playwrightDom_1 = require("./playwrightDom");
28
28
  const testsUtil_1 = require("../../commands/tests/testsUtil");
29
29
  const WAIT_FOR_CONTEXT_TIMEOUT = 1000;
30
- class PlaywrightFrame {
30
+ class PlaywrightFrame extends browserLauncher_1.Frame {
31
31
  constructor(frame, parentPage) {
32
+ super();
32
33
  this.frame = frame;
33
34
  this.parentPage = parentPage;
34
35
  this.injectSecondaryWorld();
@@ -45,20 +46,23 @@ class PlaywrightFrame {
45
46
  this.utilityWorldAvailable =
46
47
  this._contextData.get('utility').context !== null;
47
48
  }
48
- if ((arg === null || arg === void 0 ? void 0 : arg.useSecondaryWorld) && this.utilityWorldAvailable) {
49
+ if ((arg === null || arg === void 0 ? void 0 : arg.hasOwnProperty('secondaryWorldValue')) &&
50
+ this.utilityWorldAvailable) {
49
51
  forcedWorld = 'utility';
50
- delete arg.useSecondaryWorld;
52
+ arg = arg.secondaryWorldValue;
51
53
  }
52
- return forcedWorld;
54
+ return { world: forcedWorld, value: arg };
53
55
  };
54
56
  const originalEvaluateExpressionFunction = serverFrame.evaluateExpressionAndWaitForSignals.bind(serverFrame);
55
57
  const functionOverride = async function (expression, isFunction, arg, _world) {
56
- return originalEvaluateExpressionFunction(expression, isFunction, arg, await this.checkWorldFunction(arg));
58
+ const { world, value } = await this.checkWorldFunction(arg);
59
+ return originalEvaluateExpressionFunction(expression, isFunction, value, world);
57
60
  };
58
61
  serverFrame.evaluateExpressionAndWaitForSignals = functionOverride.bind(serverFrame);
59
62
  const originalEvaluateExpressionHandleFunction = serverFrame.evaluateExpressionHandleAndWaitForSignals.bind(serverFrame);
60
63
  const functionHandleOverride = async function (expression, isFunction, arg, _world) {
61
- return originalEvaluateExpressionHandleFunction(expression, isFunction, arg, await this.checkWorldFunction(arg));
64
+ const { world, value } = await this.checkWorldFunction(arg);
65
+ return originalEvaluateExpressionHandleFunction(expression, isFunction, value, world);
62
66
  };
63
67
  serverFrame.evaluateExpressionHandleAndWaitForSignals = functionHandleOverride.bind(serverFrame);
64
68
  }
@@ -22,7 +22,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
22
22
  return (mod && mod.__esModule) ? mod : { "default": mod };
23
23
  };
24
24
  Object.defineProperty(exports, "__esModule", { value: true });
25
- exports.PlaywrightPage = exports.highlightColor = exports.MAX_HIGHLIGHT_OPACITY = void 0;
25
+ exports.PlaywrightPage = void 0;
26
26
  const events_1 = __importDefault(require("events"));
27
27
  const browserLauncher_1 = require("../browserLauncher");
28
28
  const playwright = __importStar(require("@playwright/test"));
@@ -32,17 +32,9 @@ const playwrightFrame_1 = require("./playwrightFrame");
32
32
  const playwrightDom_1 = require("./playwrightDom");
33
33
  const utils_1 = require("../utils");
34
34
  const wrappers_1 = require("./wrappers");
35
- const testsUtil_1 = require("../../commands/tests/testsUtil");
36
35
  const path_1 = __importDefault(require("path"));
37
36
  const logUtils_1 = require("../../util/logUtils");
38
37
  const uuid = __importStar(require("uuid"));
39
- exports.MAX_HIGHLIGHT_OPACITY = 0.9;
40
- exports.highlightColor = (transparency) => ({
41
- r: 196,
42
- g: 68,
43
- b: 183,
44
- a: transparency,
45
- });
46
38
  class PlaywrightPage extends events_1.default {
47
39
  constructor(page, browser) {
48
40
  var _a, _b, _c;
@@ -50,7 +42,8 @@ class PlaywrightPage extends events_1.default {
50
42
  this.page = page;
51
43
  this.browser = browser;
52
44
  this.playwrightFrames = new Map();
53
- this.pageId = (_c = (_b = (_a = this.getPageImpl()) === null || _a === void 0 ? void 0 : _a._delegate) === null || _b === void 0 ? void 0 : _b._targetId) !== null && _c !== void 0 ? _c : page._guid;
45
+ const guid = page._guid;
46
+ this.pageId = (_c = (_b = (_a = this.getPageImpl()) === null || _a === void 0 ? void 0 : _a._delegate) === null || _b === void 0 ? void 0 : _b._targetId) !== null && _c !== void 0 ? _c : guid;
54
47
  page.off('dialog', this.acceptDialogs);
55
48
  page.on('dialog', this.acceptDialogs);
56
49
  page.on('close', () => {
@@ -75,7 +68,6 @@ class PlaywrightPage extends events_1.default {
75
68
  });
76
69
  }
77
70
  async waitForInitialization() {
78
- this.client = await this.browser.defaultContext.newCDPSession(this.page);
79
71
  this.openerPage = await utils_1.mapIfNotNull(await this.page.opener(), page => this.browser.getOrCreatePage(page));
80
72
  }
81
73
  on(event, listener) {
@@ -91,9 +83,9 @@ class PlaywrightPage extends events_1.default {
91
83
  wireEvents(event) {
92
84
  if (event === browserLauncher_1.PageEvent.RequestWillBeSentExtraInfo &&
93
85
  !this.listenerCount(event)) {
94
- this.client.on('Network.requestWillBeSentExtraInfo', (event) => {
86
+ void this.getCdpSession().then(session => session.on('Network.requestWillBeSentExtraInfo', (event) => {
95
87
  this.emit(browserLauncher_1.PageEvent.RequestWillBeSentExtraInfo, event);
96
- });
88
+ }));
97
89
  }
98
90
  if (event === browserLauncher_1.PageEvent.Response && !this.listenerCount(event)) {
99
91
  this.page.on('response', (event) => {
@@ -131,14 +123,14 @@ class PlaywrightPage extends events_1.default {
131
123
  });
132
124
  }
133
125
  if (event === browserLauncher_1.PageEvent.TracingBufferUsage && !this.listenerCount(event)) {
134
- this.client.on('Tracing.bufferUsage', (tracing) => {
126
+ void this.getCdpSession().then(session => session.on('Tracing.bufferUsage', (tracing) => {
135
127
  this.emit(browserLauncher_1.PageEvent.TracingBufferUsage, tracing);
136
- });
128
+ }));
137
129
  }
138
130
  if (event === browserLauncher_1.PageEvent.TracingComplete && !this.listenerCount(event)) {
139
- this.client.on('Tracing.tracingComplete', (tracingComplete) => {
131
+ void this.getCdpSession().then(session => session.on('Tracing.tracingComplete', (tracingComplete) => {
140
132
  this.emit(browserLauncher_1.PageEvent.TracingComplete, tracingComplete);
141
- });
133
+ }));
142
134
  }
143
135
  }
144
136
  async screenshot() {
@@ -231,25 +223,6 @@ class PlaywrightPage extends events_1.default {
231
223
  throw new browserLauncher_1.RunnerError(e.message);
232
224
  }
233
225
  }
234
- async highlightElement(element, highlightDurationMillis, highlightPhases) {
235
- await this.enableDom();
236
- await this.enableOverlay();
237
- const nodeInfo = await this.makeCdpCall('DOM.describeNode', {
238
- objectId: element.getRemoteObjectId(),
239
- depth: -1,
240
- pierce: true,
241
- });
242
- const highlightConfig = {
243
- backendNodeId: nodeInfo.node.backendNodeId,
244
- highlightConfig: {
245
- borderColor: exports.highlightColor(0),
246
- contentColor: exports.highlightColor(1),
247
- colorFormat: 'rgb',
248
- },
249
- };
250
- await this.fadeInOutHighlight(highlightConfig, highlightDurationMillis, highlightPhases);
251
- await this.hideHighlight();
252
- }
253
226
  isClosed() {
254
227
  return this.page.isClosed();
255
228
  }
@@ -286,6 +259,7 @@ class PlaywrightPage extends events_1.default {
286
259
  }
287
260
  }
288
261
  async resizeViewport() {
262
+ await this.makeCdpCall('Emulation.clearDeviceMetricsOverride');
289
263
  }
290
264
  async setBrowserBounds(width, height) {
291
265
  const windowInfo = await this.makeCdpCall('Browser.getWindowForTarget');
@@ -355,32 +329,26 @@ class PlaywrightPage extends events_1.default {
355
329
  throw new Error('PlaywrightPage.setExtraHTTPHeaders not implemented');
356
330
  }
357
331
  makeCdpCall(method, paramArgs) {
358
- return this.client.send(method, paramArgs);
359
- }
360
- async enableDom() {
361
- await this.makeCdpCall('DOM.enable');
362
- }
363
- async enableOverlay() {
364
- await this.makeCdpCall('Overlay.enable');
365
- }
366
- async hideHighlight() {
367
- await this.makeCdpCall('Overlay.hideHighlight');
368
- }
369
- async fadeInOutHighlight(highlightConfig, highlightDurationMillis, highlightPhases) {
370
- var _a;
371
- if (highlightPhases === 0) {
372
- throw new Error('Highlight phases must be greater than 0');
332
+ return this.getCdpSession().then(session => session.send(method, paramArgs));
333
+ }
334
+ async getCdpSession() {
335
+ var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k;
336
+ if (((_c = (_b = (_a = this.getPageImpl()) === null || _a === void 0 ? void 0 : _a._delegate) === null || _b === void 0 ? void 0 : _b._mainFrameSession) === null || _c === void 0 ? void 0 : _c._client) === undefined) {
337
+ const undefinedField = ((_e = (_d = this.getPageImpl()) === null || _d === void 0 ? void 0 : _d._delegate) === null || _e === void 0 ? void 0 : _e._mainFrameSession) !== undefined
338
+ ? '_client'
339
+ : ((_f = this.getPageImpl()) === null || _f === void 0 ? void 0 : _f._delegate) !== undefined
340
+ ? '_mainFrameSession'
341
+ : 'pageImpl';
342
+ logUtils_1.logInternal(`Unable to get the CDP Session of the page (${undefinedField} is undefined).
343
+ Creating a fallback session. Some functionality might not work as expected.`);
373
344
  }
374
- const phaseIntervalMilliseconds = highlightDurationMillis / highlightPhases;
375
- for (let iteration = 0; iteration < highlightPhases; iteration++) {
376
- if (((_a = highlightConfig.highlightConfig.contentColor) === null || _a === void 0 ? void 0 : _a.a) !== undefined) {
377
- const x = iteration / highlightPhases;
378
- highlightConfig.highlightConfig.contentColor.a =
379
- x * (1 - x) * 4 * exports.MAX_HIGHLIGHT_OPACITY;
380
- }
381
- await this.makeCdpCall('Overlay.highlightNode', highlightConfig);
382
- await testsUtil_1.sleep(phaseIntervalMilliseconds);
345
+ return ((_k = (_j = (_h = (_g = this.getPageImpl()) === null || _g === void 0 ? void 0 : _g._delegate) === null || _h === void 0 ? void 0 : _h._mainFrameSession) === null || _j === void 0 ? void 0 : _j._client) !== null && _k !== void 0 ? _k : this.getOrCreateFallbackCdpSession());
346
+ }
347
+ async getOrCreateFallbackCdpSession() {
348
+ if (this.fallbackCdpSession === undefined) {
349
+ this.fallbackCdpSession = await this.browser.defaultContext.newCDPSession(this.page);
383
350
  }
351
+ return this.fallbackCdpSession;
384
352
  }
385
353
  async getWindowInfo() {
386
354
  return this.makeCdpCall('Browser.getWindowForTarget', { targetId: this.getPageId() });
@@ -4,6 +4,7 @@ exports.PuppeteerElementHandle = void 0;
4
4
  const puppeteerJsHandle_1 = require("./puppeteerJsHandle");
5
5
  const utils_1 = require("../utils");
6
6
  const testsUtil_1 = require("../../commands/tests/testsUtil");
7
+ const elementHandle_1 = require("../elementHandle");
7
8
  const msBetweenClicks = 100;
8
9
  class PuppeteerElementHandle extends puppeteerJsHandle_1.PuppeteerJsHandle {
9
10
  constructor(element, parentPage) {
@@ -63,5 +64,58 @@ class PuppeteerElementHandle extends puppeteerJsHandle_1.PuppeteerJsHandle {
63
64
  getRemoteObjectId() {
64
65
  return this.element._remoteObject.objectId;
65
66
  }
67
+ async highlight(highlightDurationMillis, highlightPhases) {
68
+ await this.enableDom();
69
+ await this.enableOverlay();
70
+ const nodeInfo = await this.makeCdpCall('DOM.describeNode', {
71
+ objectId: this.getRemoteObjectId(),
72
+ depth: -1,
73
+ pierce: true,
74
+ });
75
+ const highlightConfig = {
76
+ backendNodeId: nodeInfo.node.backendNodeId,
77
+ highlightConfig: {
78
+ borderColor: elementHandle_1.getHighlightColor(0),
79
+ contentColor: elementHandle_1.getHighlightColor(1),
80
+ colorFormat: 'rgb',
81
+ },
82
+ };
83
+ await this.fadeInOutHighlight(highlightConfig, highlightDurationMillis, highlightPhases);
84
+ await this.hideHighlight();
85
+ }
86
+ async enableDom() {
87
+ await this.makeCdpCall('DOM.enable');
88
+ }
89
+ async enableOverlay() {
90
+ await this.makeCdpCall('Overlay.enable');
91
+ }
92
+ async hideHighlight() {
93
+ await this.makeCdpCall('Overlay.hideHighlight');
94
+ }
95
+ async fadeInOutHighlight(highlightConfig, highlightDurationMillis, highlightPhases) {
96
+ var _a;
97
+ if (highlightPhases <= 0) {
98
+ throw new Error('Highlight phases must be greater than 0');
99
+ }
100
+ const phaseIntervalMilliseconds = highlightDurationMillis / highlightPhases;
101
+ for (let iteration = 0; iteration < highlightPhases; iteration++) {
102
+ if (((_a = highlightConfig.highlightConfig.contentColor) === null || _a === void 0 ? void 0 : _a.a) !== undefined) {
103
+ const x = iteration / highlightPhases;
104
+ highlightConfig.highlightConfig.contentColor.a =
105
+ x * (1 - x) * 4 * elementHandle_1.MAX_HIGHLIGHT_OPACITY;
106
+ }
107
+ await this.makeCdpCall('Overlay.highlightNode', highlightConfig);
108
+ await testsUtil_1.sleep(phaseIntervalMilliseconds);
109
+ }
110
+ }
111
+ getCdpClient() {
112
+ return this.element._client;
113
+ }
114
+ makeCdpCall(method, paramArgs) {
115
+ return this.getCdpClient().send(method, paramArgs);
116
+ }
117
+ getValue() {
118
+ return this.element.evaluate(el => el.value);
119
+ }
66
120
  }
67
121
  exports.PuppeteerElementHandle = PuppeteerElementHandle;
@@ -12,8 +12,9 @@ const utils_1 = require("../utils");
12
12
  const puppeteerHttpResponse_1 = require("./puppeteerHttpResponse");
13
13
  const puppeteerElementHandle_1 = require("./puppeteerElementHandle");
14
14
  const puppeteerJsHandle_1 = require("./puppeteerJsHandle");
15
- class PuppeteerFrame {
15
+ class PuppeteerFrame extends browserLauncher_1.Frame {
16
16
  constructor(frame, parentPage) {
17
+ super();
17
18
  this.frame = frame;
18
19
  this.parentPage = parentPage;
19
20
  }
@@ -7,7 +7,6 @@ exports.PuppeteerPage = exports.highlightColor = exports.MAX_HIGHLIGHT_OPACITY =
7
7
  const browserLauncher_1 = require("../browserLauncher");
8
8
  const puppeteer_core_1 = __importDefault(require("puppeteer-core"));
9
9
  const events_1 = __importDefault(require("events"));
10
- const testsUtil_1 = require("../../commands/tests/testsUtil");
11
10
  const puppeteerBrowserLauncher_1 = require("./puppeteerBrowserLauncher");
12
11
  const puppeteerHttpRequest_1 = require("./puppeteerHttpRequest");
13
12
  const puppeteerHttpResponse_1 = require("./puppeteerHttpResponse");
@@ -294,25 +293,6 @@ class PuppeteerPage extends events_1.default {
294
293
  frames() {
295
294
  return this.page.frames().map(frame => this.getOrCreateFrame(frame));
296
295
  }
297
- async highlightElement(element, highlightDurationMillis, highlightPhases) {
298
- await this.enableDom();
299
- await this.enableOverlay();
300
- const nodeInfo = await this.makeCdpCall('DOM.describeNode', {
301
- objectId: element.getRemoteObjectId(),
302
- depth: -1,
303
- pierce: true,
304
- });
305
- const highlightConfig = {
306
- backendNodeId: nodeInfo.node.backendNodeId,
307
- highlightConfig: {
308
- borderColor: exports.highlightColor(0),
309
- contentColor: exports.highlightColor(1),
310
- colorFormat: 'rgb',
311
- },
312
- };
313
- await this.fadeInOutHighlight(highlightConfig, highlightDurationMillis, highlightPhases);
314
- await this.hideHighlight();
315
- }
316
296
  async getBrowserBounds() {
317
297
  const getWindowForTarget = await this.makeCdpCall('Browser.getWindowForTarget', { targetId: this.page.target()._targetId });
318
298
  return getWindowForTarget.bounds;
@@ -323,31 +303,6 @@ class PuppeteerPage extends events_1.default {
323
303
  opener() {
324
304
  return this.openerPage;
325
305
  }
326
- async enableDom() {
327
- await this.makeCdpCall('DOM.enable');
328
- }
329
- async enableOverlay() {
330
- await this.makeCdpCall('Overlay.enable');
331
- }
332
- async hideHighlight() {
333
- await this.makeCdpCall('Overlay.hideHighlight');
334
- }
335
- async fadeInOutHighlight(highlightConfig, highlightDurationMillis, highlightPhases) {
336
- var _a;
337
- if (highlightPhases === 0) {
338
- throw new Error('Highlight phases must be greater than 0');
339
- }
340
- const phaseIntervalMilliseconds = highlightDurationMillis / highlightPhases;
341
- for (let iteration = 0; iteration < highlightPhases; iteration++) {
342
- if (((_a = highlightConfig.highlightConfig.contentColor) === null || _a === void 0 ? void 0 : _a.a) !== undefined) {
343
- const x = iteration / highlightPhases;
344
- highlightConfig.highlightConfig.contentColor.a =
345
- x * (1 - x) * 4 * exports.MAX_HIGHLIGHT_OPACITY;
346
- }
347
- await this.makeCdpCall('Overlay.highlightNode', highlightConfig);
348
- await testsUtil_1.sleep(phaseIntervalMilliseconds);
349
- }
350
- }
351
306
  getOrCreateFrame(frame) {
352
307
  const frameId = frame._id;
353
308
  if (!this.puppeteerFrames.has(frameId)) {
package/cli.js CHANGED
@@ -30,8 +30,6 @@ const env_1 = require("./env/env");
30
30
  const constants_1 = require("./commands/constants");
31
31
  const pureUtil_1 = require("./util/pureUtil");
32
32
  const versionUtil_1 = require("./commands/commandUtil/versionUtil");
33
- const logLineMessaging_1 = require("./core/messaging/logLineMessaging");
34
- const messaging_1 = require("./core/messaging/messaging");
35
33
  const chalk_1 = __importDefault(require("chalk"));
36
34
  const loggingProvider_1 = require("./providers/logging/loggingProvider");
37
35
  const updateNotifier = require('update-notifier');
@@ -67,9 +65,6 @@ yargs
67
65
  .wrap(null)
68
66
  .epilogue('Read full docs @ https://help.mabl.com/docs/mabl-cli')
69
67
  .middleware([
70
- () => {
71
- logLineMessaging_1.registerConsoleLoggerForOutput(messaging_1.mablEventEmitter);
72
- },
73
68
  () => {
74
69
  try {
75
70
  const nodeVersion = versionUtil_1.extractNodeVersionTuple(process.version);
@@ -1,9 +1,10 @@
1
1
  "use strict";
2
2
  var _a;
3
3
  Object.defineProperty(exports, "__esModule", { value: true });
4
- exports.MablCoreProcessAction = exports.MablCoreAction = exports.ExecutionPhase = exports.EventChannelMessageType = exports.getEmitter = exports.mablEventEmitter = exports.MablCoreEventEmitter = void 0;
4
+ exports.getDefaultLogMetadataForInfo = exports.MablCoreProcessAction = exports.MablCoreAction = exports.ExecutionPhase = exports.EventChannelMessageType = exports.getEmitter = exports.mablEventEmitter = exports.MablCoreEventEmitter = void 0;
5
5
  const events_1 = require("events");
6
6
  const loggingProvider_1 = require("../../providers/logging/loggingProvider");
7
+ const NO_ID_PLACEHOLDER = 'NO_ID_PROVIDED';
7
8
  class MablCoreEventEmitter {
8
9
  constructor(debug) {
9
10
  this.messageIndex = -1;
@@ -78,3 +79,15 @@ exports.MablCoreAction = MablCoreAction;
78
79
  class MablCoreProcessAction extends MablCoreAction {
79
80
  }
80
81
  exports.MablCoreProcessAction = MablCoreProcessAction;
82
+ function getDefaultLogMetadataForInfo(testId, testInvariantId) {
83
+ return {
84
+ executionIndex: {
85
+ testId: testId !== null && testId !== void 0 ? testId : NO_ID_PLACEHOLDER,
86
+ testInvariantId: testInvariantId !== null && testInvariantId !== void 0 ? testInvariantId : NO_ID_PLACEHOLDER,
87
+ },
88
+ executionPhase: ExecutionPhase.BEFORE_TEST,
89
+ logLevel: loggingProvider_1.LogLevel.Info,
90
+ timestamp: Date.now(),
91
+ };
92
+ }
93
+ exports.getDefaultLogMetadataForInfo = getDefaultLogMetadataForInfo;