@mablhq/mabl-cli 1.12.9 → 1.12.38
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/api/basicApiClient.js +1 -1
- package/api/mablApiClient.js +9 -9
- package/auth/AuthClient.js +1 -4
- package/browserLauncher/browserLauncher.js +3 -1
- package/browserLauncher/browserLauncherFactory.js +6 -2
- package/browserLauncher/elementHandle.js +8 -1
- package/browserLauncher/frame.js +15 -0
- package/browserLauncher/frameBase.js +4 -0
- package/browserLauncher/playwrightBrowserLauncher/playwrightBrowser.js +2 -2
- package/browserLauncher/playwrightBrowserLauncher/playwrightBrowserLauncher.js +1 -0
- package/browserLauncher/playwrightBrowserLauncher/playwrightDom.js +119 -31
- package/browserLauncher/playwrightBrowserLauncher/playwrightFrame.js +32 -21
- package/browserLauncher/playwrightBrowserLauncher/playwrightHttpResponse.js +3 -0
- package/browserLauncher/playwrightBrowserLauncher/playwrightPage.js +43 -75
- package/browserLauncher/playwrightBrowserLauncher/wrappers.js +1 -1
- package/browserLauncher/puppeteerBrowserLauncher/puppeteerBrowser.js +3 -3
- package/browserLauncher/puppeteerBrowserLauncher/puppeteerElementHandle.js +59 -5
- package/browserLauncher/puppeteerBrowserLauncher/puppeteerFrame.js +9 -8
- package/browserLauncher/puppeteerBrowserLauncher/puppeteerHttpRequest.js +1 -1
- package/browserLauncher/puppeteerBrowserLauncher/puppeteerHttpResponse.js +4 -1
- package/browserLauncher/puppeteerBrowserLauncher/puppeteerJsHandle.js +3 -3
- package/browserLauncher/puppeteerBrowserLauncher/puppeteerPage.js +23 -61
- package/browserLauncher/puppeteerBrowserLauncher/wrappers.js +1 -1
- package/cli.js +6 -4
- package/commands/applications/applications_cmds/list.js +1 -1
- package/commands/branches/branches_cmds/create.js +1 -1
- package/commands/branches/branches_cmds/list.js +1 -1
- package/commands/branches/branches_cmds/merge.js +1 -1
- package/commands/commandUtil/awaitCompletion.js +2 -2
- package/commands/commandUtil/codeInsights.js +6 -6
- package/commands/commandUtil/fileUtil.js +1 -1
- package/commands/commandUtil/util.js +12 -12
- package/commands/config/config_cmds/list.js +1 -1
- package/commands/constants.js +1 -1
- package/commands/credentials/credentials_cmds/list.js +1 -1
- package/commands/deploy/deploy_cmds/create.js +2 -2
- package/commands/deploy/deploy_cmds/executionResultPresenter.js +7 -7
- package/commands/deploy/deploy_cmds/list.js +1 -1
- package/commands/environments/environments_cmds/create.js +3 -3
- package/commands/environments/environments_cmds/list.js +1 -1
- package/commands/environments/environments_cmds/urls_cmds/add.js +1 -1
- package/commands/flows/flows_cmds/list.js +1 -1
- package/commands/plans/plans_cmds/list.js +1 -1
- package/commands/test-runs/test-runs_cmds/export.js +1 -1
- package/commands/tests/executionUtil.js +1 -1
- package/commands/tests/testsUtil.js +16 -20
- package/commands/tests/tests_cmds/edit.js +1 -1
- package/commands/tests/tests_cmds/export.js +1 -1
- package/commands/tests/tests_cmds/import.js +13 -13
- package/commands/tests/tests_cmds/list.js +2 -2
- package/commands/tests/tests_cmds/run-alpha.js +1 -1
- package/commands/tests/tests_cmds/run-cloud.js +7 -7
- package/commands/tests/tests_cmds/run-legacy.js +2 -2
- package/commands/tests/tests_cmds/run.js +25 -7
- package/commands/workspaces/workspace_cmds/copy.js +1 -1
- package/commands/workspaces/workspace_cmds/list.js +1 -1
- package/configGenerators/flowConfigGenerator.js +3 -3
- package/configGenerators/selIdeGenerator.js +1 -1
- package/configGenerators/testConfigGenerator.js +7 -8
- package/core/execution/ApiTestUtils.js +2 -2
- package/core/messaging/messaging.js +14 -1
- package/core/trainer/openUtils.js +47 -0
- package/core/trainer/trainingSessions.js +36 -61
- package/env/defaultEnv.js +2 -1
- package/env/dev.js +2 -1
- package/env/env.js +3 -1
- package/env/local.js +2 -1
- package/env/prod.js +2 -1
- package/execution/index.js +1 -1
- package/index.d.ts +7 -0
- package/mablApi/index.js +1 -1
- package/mablscript/MablStep.js +11 -7
- package/mablscript/actions/ConditionAction.js +2 -4
- package/mablscript/actions/FindAction.js +4 -4
- package/mablscript/importer.js +16 -14
- package/mablscript/steps/AccessibilityCheck.js +88 -0
- package/mablscript/steps/AssertStep.js +6 -5
- package/mablscript/steps/CreateVariableStep.js +2 -3
- package/mablscript/steps/DownloadStep.js +1 -2
- package/mablscript/steps/EnterTextStep.js +2 -1
- package/mablscript/steps/IfConditionStep.js +3 -3
- package/mablscript/steps/SendHttpRequestStep.js +2 -2
- package/mablscript/steps/SendKeyStep.js +2 -2
- package/mablscript/steps/SetFilesStep.js +1 -1
- package/mablscript/steps/SwitchContextStep.js +2 -1
- package/mablscript/types/AccessibilityCheckStepDescriptor.js +2 -0
- package/mablscript/types/AccessibilityCheckTypes.js +9 -0
- package/mablscript/types/VariableDataType.js +1 -8
- package/mablscript/types/VariableNamespace.js +1 -1
- package/mablscriptFind/index.js +1 -1
- package/package.json +6 -4
- package/popupDismissal/index.js +13 -12
- package/providers/authenticationProvider.js +2 -3
- package/providers/cliConfigProvider.js +1 -1
- package/providers/exportRequestProvider.js +1 -1
- package/providers/logging/loggingProvider.js +2 -2
- package/providers/scmContextProvider.js +1 -1
- package/reporters/mochAwesome/mochAwesomeReporter.js +10 -6
- package/reporters/reporter.js +1 -1
- package/resources/mablFind.js +1 -1
- package/resources/popupDismissal.js +1 -1
- package/util/RichPromise.js +2 -2
- package/util/actionabilityUtil.js +44 -14
- package/util/downloadUtil.js +1 -1
- package/util/logUtils.js +20 -1
- package/util/markdownUtil.js +3 -3
- package/util/pureUtil.js +6 -6
- package/util/resourceUtil.js +14 -1
- package/core/trainer/trainerBrowserUtil.js +0 -33
|
@@ -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 =
|
|
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
|
-
|
|
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,8 +68,7 @@ class PlaywrightPage extends events_1.default {
|
|
|
75
68
|
});
|
|
76
69
|
}
|
|
77
70
|
async waitForInitialization() {
|
|
78
|
-
this.
|
|
79
|
-
this.openerPage = await utils_1.mapIfNotNull(await this.page.opener(), page => this.browser.getOrCreatePage(page));
|
|
71
|
+
this.openerPage = await utils_1.mapIfNotNull(await this.page.opener(), (page) => this.browser.getOrCreatePage(page));
|
|
80
72
|
}
|
|
81
73
|
on(event, listener) {
|
|
82
74
|
this.wireEvents(event);
|
|
@@ -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.
|
|
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) => {
|
|
@@ -101,7 +93,7 @@ class PlaywrightPage extends events_1.default {
|
|
|
101
93
|
});
|
|
102
94
|
}
|
|
103
95
|
if (event === browserLauncher_1.PageEvent.Request && !this.listenerCount(event)) {
|
|
104
|
-
void this.page.route('**/*', route => {
|
|
96
|
+
void this.page.route('**/*', (route) => {
|
|
105
97
|
this.emit(browserLauncher_1.PageEvent.Request, new playwrightHttpRequest_1.PlaywrightHttpRequest(this, route.request(), route));
|
|
106
98
|
});
|
|
107
99
|
}
|
|
@@ -116,33 +108,33 @@ class PlaywrightPage extends events_1.default {
|
|
|
116
108
|
});
|
|
117
109
|
}
|
|
118
110
|
if (event === browserLauncher_1.PageEvent.Console && !this.listenerCount(event)) {
|
|
119
|
-
this.page.on('console', console => {
|
|
111
|
+
this.page.on('console', (console) => {
|
|
120
112
|
this.emit(browserLauncher_1.PageEvent.Console, new wrappers_1.PlaywrightWrappedConsoleMessage(console, this));
|
|
121
113
|
});
|
|
122
114
|
}
|
|
123
115
|
if (event === browserLauncher_1.PageEvent.PageError && !this.listenerCount(event)) {
|
|
124
|
-
this.page.on('pageerror', error => {
|
|
116
|
+
this.page.on('pageerror', (error) => {
|
|
125
117
|
this.emit(browserLauncher_1.PageEvent.PageError, error);
|
|
126
118
|
});
|
|
127
119
|
}
|
|
128
120
|
if (event === browserLauncher_1.PageEvent.Error && !this.listenerCount(event)) {
|
|
129
|
-
this.page.on('crash', error => {
|
|
121
|
+
this.page.on('crash', (error) => {
|
|
130
122
|
this.emit(browserLauncher_1.PageEvent.Error, error);
|
|
131
123
|
});
|
|
132
124
|
}
|
|
133
125
|
if (event === browserLauncher_1.PageEvent.TracingBufferUsage && !this.listenerCount(event)) {
|
|
134
|
-
this.
|
|
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.
|
|
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
|
-
async screenshot() {
|
|
145
|
-
return { data: (await this.page.screenshot()).toString('base64') };
|
|
136
|
+
async screenshot(clip) {
|
|
137
|
+
return { data: (await this.page.screenshot({ clip })).toString('base64') };
|
|
146
138
|
}
|
|
147
139
|
sendCharacter(key) {
|
|
148
140
|
return this.page.keyboard.insertText(key);
|
|
@@ -190,7 +182,7 @@ class PlaywrightPage extends events_1.default {
|
|
|
190
182
|
return result;
|
|
191
183
|
}
|
|
192
184
|
async $x(xpathQuery) {
|
|
193
|
-
return (await this.page.$$(`xpath=${xpathQuery}`)).map(element => new playwrightDom_1.PlaywrightElementHandle(element, this));
|
|
185
|
+
return (await this.page.$$(`xpath=${xpathQuery}`)).map((element) => new playwrightDom_1.PlaywrightElementHandle(element, this));
|
|
194
186
|
}
|
|
195
187
|
authenticate(_credentials) {
|
|
196
188
|
throw new Error('PlaywrightPage.authenticate not implemented');
|
|
@@ -202,7 +194,7 @@ class PlaywrightPage extends events_1.default {
|
|
|
202
194
|
return this.page.context().cookies();
|
|
203
195
|
}
|
|
204
196
|
async deleteCookie(...cookies) {
|
|
205
|
-
const finalCookies = (await this.cookies()).filter((cookie) => !cookies.find(c => c.name === cookie.name && c.domain === cookie.domain));
|
|
197
|
+
const finalCookies = (await this.cookies()).filter((cookie) => !cookies.find((c) => c.name === cookie.name && c.domain === cookie.domain));
|
|
206
198
|
await this.page.context().clearCookies();
|
|
207
199
|
await this.page.context().addCookies(finalCookies);
|
|
208
200
|
}
|
|
@@ -213,7 +205,7 @@ class PlaywrightPage extends events_1.default {
|
|
|
213
205
|
return new playwrightDom_1.PlaywrightJsHandle(await this.page.evaluateHandle(code, playwrightDom_1.PlaywrightJsHandle.unwrapProperties(arg, true)), this);
|
|
214
206
|
}
|
|
215
207
|
frames() {
|
|
216
|
-
return this.page.frames().map(frame => this.getOrCreateFrame(frame));
|
|
208
|
+
return this.page.frames().map((frame) => this.getOrCreateFrame(frame));
|
|
217
209
|
}
|
|
218
210
|
async getBrowserBounds() {
|
|
219
211
|
const windowInfo = await this.getWindowInfo();
|
|
@@ -222,7 +214,7 @@ class PlaywrightPage extends events_1.default {
|
|
|
222
214
|
async goto(url, options) {
|
|
223
215
|
try {
|
|
224
216
|
const response = await this.page.goto(url, options);
|
|
225
|
-
return utils_1.mapIfNotNull(response, response => new playwrightHttpResponse_1.PlaywrightHttpResponse(this, response));
|
|
217
|
+
return utils_1.mapIfNotNull(response, (response) => new playwrightHttpResponse_1.PlaywrightHttpResponse(this, response));
|
|
226
218
|
}
|
|
227
219
|
catch (e) {
|
|
228
220
|
if (e instanceof playwright.errors.TimeoutError) {
|
|
@@ -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
|
}
|
|
@@ -276,7 +249,7 @@ class PlaywrightPage extends events_1.default {
|
|
|
276
249
|
}
|
|
277
250
|
async reload(options) {
|
|
278
251
|
try {
|
|
279
|
-
return utils_1.mapIfNotNull(await this.page.reload(options), response => new playwrightHttpResponse_1.PlaywrightHttpResponse(this, response));
|
|
252
|
+
return utils_1.mapIfNotNull(await this.page.reload(options), (response) => new playwrightHttpResponse_1.PlaywrightHttpResponse(this, response));
|
|
280
253
|
}
|
|
281
254
|
catch (e) {
|
|
282
255
|
if (e instanceof playwright.errors.TimeoutError) {
|
|
@@ -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');
|
|
@@ -301,7 +275,7 @@ class PlaywrightPage extends events_1.default {
|
|
|
301
275
|
async setCookie(...cookies) {
|
|
302
276
|
const pageUrl = this.url();
|
|
303
277
|
const startsWithHTTP = pageUrl.startsWith('http');
|
|
304
|
-
await this.page.context().addCookies(cookies.map(cookie => {
|
|
278
|
+
await this.page.context().addCookies(cookies.map((cookie) => {
|
|
305
279
|
const item = { ...cookie };
|
|
306
280
|
if (!item.url && startsWithHTTP) {
|
|
307
281
|
item.url = pageUrl;
|
|
@@ -333,7 +307,7 @@ class PlaywrightPage extends events_1.default {
|
|
|
333
307
|
async waitForNavigation(options) {
|
|
334
308
|
try {
|
|
335
309
|
const result = await this.page.waitForNavigation(options);
|
|
336
|
-
return utils_1.mapIfNotNull(result, result => new playwrightHttpResponse_1.PlaywrightHttpResponse(this, result));
|
|
310
|
+
return utils_1.mapIfNotNull(result, (result) => new playwrightHttpResponse_1.PlaywrightHttpResponse(this, result));
|
|
337
311
|
}
|
|
338
312
|
catch (e) {
|
|
339
313
|
if (e instanceof playwright.errors.TimeoutError) {
|
|
@@ -343,7 +317,7 @@ class PlaywrightPage extends events_1.default {
|
|
|
343
317
|
}
|
|
344
318
|
}
|
|
345
319
|
async waitForSelector(selector, options) {
|
|
346
|
-
return utils_1.mapIfNotNull(await this.page.waitForSelector(selector, options), handle => new playwrightDom_1.PlaywrightElementHandle(handle, this));
|
|
320
|
+
return utils_1.mapIfNotNull(await this.page.waitForSelector(selector, options), (handle) => new playwrightDom_1.PlaywrightElementHandle(handle, this));
|
|
347
321
|
}
|
|
348
322
|
acceptDialogs(dialog) {
|
|
349
323
|
return dialog.accept();
|
|
@@ -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.
|
|
359
|
-
}
|
|
360
|
-
async
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
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
|
-
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
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() });
|
|
@@ -13,7 +13,7 @@ class PlaywrightWrappedConsoleMessage {
|
|
|
13
13
|
args() {
|
|
14
14
|
return this.message
|
|
15
15
|
.args()
|
|
16
|
-
.map(handle => new playwrightDom_1.PlaywrightJsHandle(handle, this.page));
|
|
16
|
+
.map((handle) => new playwrightDom_1.PlaywrightJsHandle(handle, this.page));
|
|
17
17
|
}
|
|
18
18
|
type() {
|
|
19
19
|
return this.message.type();
|
|
@@ -71,11 +71,11 @@ class PuppeteerBrowser extends events_1.default {
|
|
|
71
71
|
}
|
|
72
72
|
async pages() {
|
|
73
73
|
const pages = await this.browser.pages();
|
|
74
|
-
return Promise.all(pages.map(page => this.getOrCreatePage(page)));
|
|
74
|
+
return Promise.all(pages.map((page) => this.getOrCreatePage(page)));
|
|
75
75
|
}
|
|
76
76
|
async getExtensionBackgroundPage(extensionId) {
|
|
77
77
|
const targets = this.browser.targets();
|
|
78
|
-
const target = targets.find(target => target.type() === 'background_page' &&
|
|
78
|
+
const target = targets.find((target) => target.type() === 'background_page' &&
|
|
79
79
|
target.url().includes(extensionId));
|
|
80
80
|
if (target) {
|
|
81
81
|
const backgroundPage = await target.page();
|
|
@@ -89,7 +89,7 @@ class PuppeteerBrowser extends events_1.default {
|
|
|
89
89
|
async waitForPage(opener, options) {
|
|
90
90
|
try {
|
|
91
91
|
const pageTarget = opener.getPuppeteerPage().target();
|
|
92
|
-
const newTarget = await this.browser.waitForTarget(target => target.opener() === pageTarget, puppeteerBrowserLauncher_1.convertWaitForOptions(options));
|
|
92
|
+
const newTarget = await this.browser.waitForTarget((target) => target.opener() === pageTarget, puppeteerBrowserLauncher_1.convertWaitForOptions(options));
|
|
93
93
|
return this.getOrCreatePage((await newTarget.page()));
|
|
94
94
|
}
|
|
95
95
|
catch (e) {
|
|
@@ -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) {
|
|
@@ -16,7 +17,7 @@ class PuppeteerElementHandle extends puppeteerJsHandle_1.PuppeteerJsHandle {
|
|
|
16
17
|
}
|
|
17
18
|
async contentFrame() {
|
|
18
19
|
const frame = await this.element.contentFrame();
|
|
19
|
-
return utils_1.mapIfNotNull(frame, frame => this.parentPage.getOrCreateFrame(frame));
|
|
20
|
+
return utils_1.mapIfNotNull(frame, (frame) => this.parentPage.getOrCreateFrame(frame));
|
|
20
21
|
}
|
|
21
22
|
focus() {
|
|
22
23
|
return this.element.focus();
|
|
@@ -42,20 +43,20 @@ class PuppeteerElementHandle extends puppeteerJsHandle_1.PuppeteerJsHandle {
|
|
|
42
43
|
return this.element.click({ clickCount: 2 });
|
|
43
44
|
}
|
|
44
45
|
asElement() {
|
|
45
|
-
return utils_1.mapIfNotNull(this.handle.asElement(), handle => new PuppeteerElementHandle(handle, this.parentPage));
|
|
46
|
+
return utils_1.mapIfNotNull(this.handle.asElement(), (handle) => new PuppeteerElementHandle(handle, this.parentPage));
|
|
46
47
|
}
|
|
47
48
|
type(text, options) {
|
|
48
49
|
return this.element.type(text, options);
|
|
49
50
|
}
|
|
50
51
|
async $x(xpathQuery) {
|
|
51
|
-
return (await this.element.$x(xpathQuery)).map(element => new PuppeteerElementHandle(element, this.parentPage));
|
|
52
|
+
return (await this.element.$x(xpathQuery)).map((element) => new PuppeteerElementHandle(element, this.parentPage));
|
|
52
53
|
}
|
|
53
54
|
async boundingBox() {
|
|
54
55
|
const boundingBox = await this.element.boundingBox();
|
|
55
|
-
return utils_1.mapIfNotNull(boundingBox, boundingBox => boundingBox);
|
|
56
|
+
return utils_1.mapIfNotNull(boundingBox, (boundingBox) => boundingBox);
|
|
56
57
|
}
|
|
57
58
|
frame() {
|
|
58
|
-
return Promise.resolve(utils_1.mapIfNotNull(this.element.executionContext().frame(), frame => this.parentPage.getOrCreateFrame(frame)));
|
|
59
|
+
return Promise.resolve(utils_1.mapIfNotNull(this.element.executionContext().frame(), (frame) => this.parentPage.getOrCreateFrame(frame)));
|
|
59
60
|
}
|
|
60
61
|
press(key) {
|
|
61
62
|
return this.element.press(key);
|
|
@@ -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
|
}
|
|
@@ -30,7 +31,7 @@ class PuppeteerFrame {
|
|
|
30
31
|
childFrames() {
|
|
31
32
|
return this.frame
|
|
32
33
|
.childFrames()
|
|
33
|
-
.map(frame => this.parentPage.getOrCreateFrame(frame));
|
|
34
|
+
.map((frame) => this.parentPage.getOrCreateFrame(frame));
|
|
34
35
|
}
|
|
35
36
|
async $eval(selector, pageFunction, arg) {
|
|
36
37
|
const result = await this.frame.$eval(selector, pageFunction, puppeteerJsHandle_1.PuppeteerJsHandle.unwrapProperties(arg));
|
|
@@ -42,13 +43,13 @@ class PuppeteerFrame {
|
|
|
42
43
|
}
|
|
43
44
|
async $(selector) {
|
|
44
45
|
const handle = await this.frame.$(selector);
|
|
45
|
-
return utils_1.mapIfNotNull(handle, handle => new puppeteerElementHandle_1.PuppeteerElementHandle(handle, this.parentPage));
|
|
46
|
+
return utils_1.mapIfNotNull(handle, (handle) => new puppeteerElementHandle_1.PuppeteerElementHandle(handle, this.parentPage));
|
|
46
47
|
}
|
|
47
48
|
async $$(selector) {
|
|
48
|
-
return (await this.frame.$$(selector)).map(element => new puppeteerElementHandle_1.PuppeteerElementHandle(element, this.parentPage));
|
|
49
|
+
return (await this.frame.$$(selector)).map((element) => new puppeteerElementHandle_1.PuppeteerElementHandle(element, this.parentPage));
|
|
49
50
|
}
|
|
50
51
|
async $x(xpathQuery) {
|
|
51
|
-
return (await this.frame.$x(xpathQuery)).map(element => new puppeteerElementHandle_1.PuppeteerElementHandle(element, this.parentPage));
|
|
52
|
+
return (await this.frame.$x(xpathQuery)).map((element) => new puppeteerElementHandle_1.PuppeteerElementHandle(element, this.parentPage));
|
|
52
53
|
}
|
|
53
54
|
id() {
|
|
54
55
|
return this.frame._id;
|
|
@@ -62,7 +63,7 @@ class PuppeteerFrame {
|
|
|
62
63
|
async goto(url, options) {
|
|
63
64
|
try {
|
|
64
65
|
const response = await this.frame.goto(url, puppeteerBrowserLauncher_1.convertWaitForOptions(options));
|
|
65
|
-
return utils_1.mapIfNotNull(response, response => new puppeteerHttpResponse_1.PuppeteerHttpResponse(response, this.parentPage));
|
|
66
|
+
return utils_1.mapIfNotNull(response, (response) => new puppeteerHttpResponse_1.PuppeteerHttpResponse(response, this.parentPage));
|
|
66
67
|
}
|
|
67
68
|
catch (e) {
|
|
68
69
|
if (e instanceof puppeteer_core_1.default.errors.TimeoutError) {
|
|
@@ -72,7 +73,7 @@ class PuppeteerFrame {
|
|
|
72
73
|
}
|
|
73
74
|
}
|
|
74
75
|
parentFrame() {
|
|
75
|
-
return utils_1.mapIfNotNull(this.frame.parentFrame(), frame => this.parentPage.getOrCreateFrame(frame));
|
|
76
|
+
return utils_1.mapIfNotNull(this.frame.parentFrame(), (frame) => this.parentPage.getOrCreateFrame(frame));
|
|
76
77
|
}
|
|
77
78
|
evaluate(pageFunction, arg) {
|
|
78
79
|
return this.frame.evaluate(pageFunction, puppeteerJsHandle_1.PuppeteerJsHandle.unwrapProperties(arg));
|
|
@@ -98,7 +99,7 @@ class PuppeteerFrame {
|
|
|
98
99
|
}
|
|
99
100
|
async waitForSelector(selector, options) {
|
|
100
101
|
const handle = await this.frame.waitForSelector(selector, puppeteerBrowserLauncher_1.convertWaitForOptions(options));
|
|
101
|
-
return utils_1.mapIfNotNull(handle, handle => new puppeteerElementHandle_1.PuppeteerElementHandle(handle, this.parentPage));
|
|
102
|
+
return utils_1.mapIfNotNull(handle, (handle) => new puppeteerElementHandle_1.PuppeteerElementHandle(handle, this.parentPage));
|
|
102
103
|
}
|
|
103
104
|
async getFrameOwnerElement() {
|
|
104
105
|
const parentFrame = this.parentFrame();
|
|
@@ -23,7 +23,7 @@ class PuppeteerHttpRequest {
|
|
|
23
23
|
});
|
|
24
24
|
}
|
|
25
25
|
frame() {
|
|
26
|
-
return utils_1.mapIfNotNull(this.request.frame(), frame => this.parentPage.getOrCreateFrame(frame));
|
|
26
|
+
return utils_1.mapIfNotNull(this.request.frame(), (frame) => this.parentPage.getOrCreateFrame(frame));
|
|
27
27
|
}
|
|
28
28
|
url() {
|
|
29
29
|
return this.request.url();
|
|
@@ -15,10 +15,13 @@ class PuppeteerHttpResponse {
|
|
|
15
15
|
return this.response.url();
|
|
16
16
|
}
|
|
17
17
|
frame() {
|
|
18
|
-
return utils_1.mapIfNotNull(this.response.frame(), frame => this.parentPage.getOrCreateFrame(frame));
|
|
18
|
+
return utils_1.mapIfNotNull(this.response.frame(), (frame) => this.parentPage.getOrCreateFrame(frame));
|
|
19
19
|
}
|
|
20
20
|
request() {
|
|
21
21
|
return new puppeteerHttpRequest_1.PuppeteerHttpRequest(this.response.request(), this.parentPage);
|
|
22
22
|
}
|
|
23
|
+
json() {
|
|
24
|
+
return this.response.json();
|
|
25
|
+
}
|
|
23
26
|
}
|
|
24
27
|
exports.PuppeteerHttpResponse = PuppeteerHttpResponse;
|
|
@@ -10,16 +10,16 @@ class PuppeteerJsHandle {
|
|
|
10
10
|
}
|
|
11
11
|
async evaluateHandle(code, arg) {
|
|
12
12
|
const handle = await this.handle.evaluateHandle(code, PuppeteerJsHandle.unwrapProperties(arg));
|
|
13
|
-
return utils_1.mapIfNotNull(handle, handle => new PuppeteerJsHandle(handle, this.parentPage));
|
|
13
|
+
return utils_1.mapIfNotNull(handle, (handle) => new PuppeteerJsHandle(handle, this.parentPage));
|
|
14
14
|
}
|
|
15
15
|
asElement() {
|
|
16
|
-
return utils_1.mapIfNotNull(this.handle.asElement(), handle => new puppeteerElementHandle_1.PuppeteerElementHandle(handle, this.parentPage));
|
|
16
|
+
return utils_1.mapIfNotNull(this.handle.asElement(), (handle) => new puppeteerElementHandle_1.PuppeteerElementHandle(handle, this.parentPage));
|
|
17
17
|
}
|
|
18
18
|
jsonValue() {
|
|
19
19
|
return this.handle.jsonValue();
|
|
20
20
|
}
|
|
21
21
|
async getProperty(propertyName) {
|
|
22
|
-
return utils_1.mapIfNotNull(await this.handle.getProperty(propertyName), handle => new PuppeteerJsHandle(handle, this.parentPage));
|
|
22
|
+
return utils_1.mapIfNotNull(await this.handle.getProperty(propertyName), (handle) => new PuppeteerJsHandle(handle, this.parentPage));
|
|
23
23
|
}
|
|
24
24
|
evaluate(pageFunction, arg) {
|
|
25
25
|
return this.handle.evaluate(pageFunction, PuppeteerJsHandle.unwrapProperties(arg));
|