@mablhq/mabl-cli 2.51.1 → 2.51.4
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/featureSet.js +2 -2
- package/browserLauncher/index.js +8 -0
- package/browserLauncher/index.js.LICENSE.txt +28 -0
- package/commands/tests/testsUtil.js +1 -1
- package/commands/tests/tests_cmds/import_cmds/import_playwright.js +7 -1
- package/core/execution/ApiTestUtils.js +81 -1
- package/execution/index.js +1 -1
- package/package.json +1 -1
- package/browserLauncher/browser.js +0 -2
- package/browserLauncher/browserEvent.js +0 -11
- package/browserLauncher/browserLauncher.js +0 -17
- package/browserLauncher/browserLauncherEventEmitter.js +0 -2
- package/browserLauncher/browserLauncherFactory.js +0 -30
- package/browserLauncher/elementHandle.js +0 -30
- package/browserLauncher/errors.js +0 -26
- package/browserLauncher/frame.js +0 -17
- package/browserLauncher/frameBase.js +0 -10
- package/browserLauncher/httpRequest.js +0 -2
- package/browserLauncher/httpResponse.js +0 -2
- package/browserLauncher/jsHandle.js +0 -2
- package/browserLauncher/page.js +0 -2
- package/browserLauncher/pageEvent.js +0 -17
- package/browserLauncher/playwrightBrowserLauncher/browserDelegate.js +0 -2
- package/browserLauncher/playwrightBrowserLauncher/chromium/chromiumBrowserDelegate.js +0 -61
- package/browserLauncher/playwrightBrowserLauncher/chromium/chromiumElementHandleDelegate.js +0 -129
- package/browserLauncher/playwrightBrowserLauncher/chromium/chromiumFrameDelegate.js +0 -24
- package/browserLauncher/playwrightBrowserLauncher/chromium/chromiumPageDelegate.js +0 -145
- package/browserLauncher/playwrightBrowserLauncher/elementHandleDelegate.js +0 -2
- package/browserLauncher/playwrightBrowserLauncher/firefox/firefoxBrowserDelegate.js +0 -50
- package/browserLauncher/playwrightBrowserLauncher/firefox/firefoxElementHandleDelegate.js +0 -11
- package/browserLauncher/playwrightBrowserLauncher/firefox/firefoxFrameDelegate.js +0 -26
- package/browserLauncher/playwrightBrowserLauncher/firefox/firefoxPageDelegate.js +0 -15
- package/browserLauncher/playwrightBrowserLauncher/frameDelegate.js +0 -2
- package/browserLauncher/playwrightBrowserLauncher/internals.js +0 -2
- package/browserLauncher/playwrightBrowserLauncher/nonChromium/nonChromiumAbstractBrowserDelegate.js +0 -15
- package/browserLauncher/playwrightBrowserLauncher/nonChromium/nonChromiumAbstractElementHandleDelegate.js +0 -73
- package/browserLauncher/playwrightBrowserLauncher/nonChromium/nonChromiumAbstractFrameDelegate.js +0 -13
- package/browserLauncher/playwrightBrowserLauncher/nonChromium/nonChromiumAbstractPageDelegate.js +0 -81
- package/browserLauncher/playwrightBrowserLauncher/pageDelegate.js +0 -2
- package/browserLauncher/playwrightBrowserLauncher/playwrightApiResponse.js +0 -18
- package/browserLauncher/playwrightBrowserLauncher/playwrightBrowser.js +0 -259
- package/browserLauncher/playwrightBrowserLauncher/playwrightBrowserLauncher.js +0 -97
- package/browserLauncher/playwrightBrowserLauncher/playwrightDom.js +0 -319
- package/browserLauncher/playwrightBrowserLauncher/playwrightFrame.js +0 -265
- package/browserLauncher/playwrightBrowserLauncher/playwrightHttpRequest.js +0 -76
- package/browserLauncher/playwrightBrowserLauncher/playwrightHttpResponse.js +0 -26
- package/browserLauncher/playwrightBrowserLauncher/playwrightPage.js +0 -377
- package/browserLauncher/playwrightBrowserLauncher/simplePlaywrightLogger.js +0 -36
- package/browserLauncher/playwrightBrowserLauncher/webkit/webkitBrowserDelegate.js +0 -50
- package/browserLauncher/playwrightBrowserLauncher/webkit/webkitElementHandleDelegate.js +0 -16
- package/browserLauncher/playwrightBrowserLauncher/webkit/webkitFrameDelegate.js +0 -19
- package/browserLauncher/playwrightBrowserLauncher/webkit/webkitPageDelegate.js +0 -15
- package/browserLauncher/playwrightBrowserLauncher/wrappers.js +0 -25
- package/browserLauncher/types.js +0 -28
- package/browserLauncher/utils.js +0 -9
|
@@ -1,319 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
-
if (k2 === undefined) k2 = k;
|
|
4
|
-
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
-
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
-
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
-
}
|
|
8
|
-
Object.defineProperty(o, k2, desc);
|
|
9
|
-
}) : (function(o, m, k, k2) {
|
|
10
|
-
if (k2 === undefined) k2 = k;
|
|
11
|
-
o[k2] = m[k];
|
|
12
|
-
}));
|
|
13
|
-
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
-
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
-
}) : function(o, v) {
|
|
16
|
-
o["default"] = v;
|
|
17
|
-
});
|
|
18
|
-
var __importStar = (this && this.__importStar) || function (mod) {
|
|
19
|
-
if (mod && mod.__esModule) return mod;
|
|
20
|
-
var result = {};
|
|
21
|
-
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
22
|
-
__setModuleDefault(result, mod);
|
|
23
|
-
return result;
|
|
24
|
-
};
|
|
25
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
26
|
-
exports.PlaywrightElementHandle = exports.PlaywrightJsHandle = exports.NAVIGATION_ERROR_MESSAGE = void 0;
|
|
27
|
-
const playwright = __importStar(require("playwright"));
|
|
28
|
-
const types_1 = require("../types");
|
|
29
|
-
const utils_1 = require("../utils");
|
|
30
|
-
const logUtils_1 = require("../../util/logUtils");
|
|
31
|
-
const pureUtil_1 = require("../../util/pureUtil");
|
|
32
|
-
exports.NAVIGATION_ERROR_MESSAGE = 'waiting for scheduled navigations to finish';
|
|
33
|
-
class PlaywrightJsHandle {
|
|
34
|
-
constructor(handle, page) {
|
|
35
|
-
this.handle = handle;
|
|
36
|
-
this.page = page;
|
|
37
|
-
}
|
|
38
|
-
getPlaywrightHandle() {
|
|
39
|
-
return this.handle;
|
|
40
|
-
}
|
|
41
|
-
asElement() {
|
|
42
|
-
return undefined;
|
|
43
|
-
}
|
|
44
|
-
evaluate(pageFunction, arg) {
|
|
45
|
-
return this.handle.evaluate(pageFunction, PlaywrightJsHandle.unwrapProperties(arg));
|
|
46
|
-
}
|
|
47
|
-
async evaluateHandle(code, arg) {
|
|
48
|
-
const handle = await this.handle.evaluateHandle(code, PlaywrightJsHandle.unwrapProperties(arg));
|
|
49
|
-
return (0, utils_1.mapIfNotNull)(handle, (handle) => handle.asElement()
|
|
50
|
-
? new PlaywrightElementHandle(handle.asElement(), this.page, this.page.delegate.createElementHandleDelegate(handle.asElement()))
|
|
51
|
-
: new PlaywrightJsHandle(handle, this.page));
|
|
52
|
-
}
|
|
53
|
-
async getProperty(propertyName) {
|
|
54
|
-
return (0, utils_1.mapIfNotNull)(await this.handle.getProperty(propertyName), (handle) => new PlaywrightJsHandle(handle, this.page));
|
|
55
|
-
}
|
|
56
|
-
jsonValue() {
|
|
57
|
-
return this.handle.jsonValue();
|
|
58
|
-
}
|
|
59
|
-
isContextDestroyed() {
|
|
60
|
-
var _a, _b;
|
|
61
|
-
const elementImpl = playwright._toImpl(this.handle);
|
|
62
|
-
return !!((_b = (_a = elementImpl._context) === null || _a === void 0 ? void 0 : _a._contextDestroyedScope) === null || _b === void 0 ? void 0 : _b.isClosed());
|
|
63
|
-
}
|
|
64
|
-
static unwrapProperties(arg, addSecondaryWorldFlag = false) {
|
|
65
|
-
if (arg === undefined) {
|
|
66
|
-
return addSecondaryWorldFlag ? { secondaryWorldValue: undefined } : null;
|
|
67
|
-
}
|
|
68
|
-
if (addSecondaryWorldFlag && arg instanceof PlaywrightJsHandle) {
|
|
69
|
-
throw new Error('Unable to setup the secondary world if the argument is a JsHandle. Pass an object instead');
|
|
70
|
-
}
|
|
71
|
-
let result = arg;
|
|
72
|
-
if (arg instanceof PlaywrightJsHandle) {
|
|
73
|
-
result = arg.getPlaywrightHandle();
|
|
74
|
-
}
|
|
75
|
-
else if ((typeof arg !== 'object' || Array.isArray(arg)) &&
|
|
76
|
-
!addSecondaryWorldFlag) {
|
|
77
|
-
result = arg;
|
|
78
|
-
}
|
|
79
|
-
else if (typeof arg === 'object' &&
|
|
80
|
-
!Object.keys(arg).some((key) => arg[key] instanceof PlaywrightJsHandle)) {
|
|
81
|
-
result = arg;
|
|
82
|
-
}
|
|
83
|
-
else if (typeof arg === 'object' && !Array.isArray(arg)) {
|
|
84
|
-
const unwrapped = { ...arg };
|
|
85
|
-
Object.keys(arg).forEach((propertyName) => {
|
|
86
|
-
const propertyValue = unwrapped[propertyName];
|
|
87
|
-
if (propertyValue instanceof PlaywrightJsHandle) {
|
|
88
|
-
unwrapped[propertyName] = propertyValue.getPlaywrightHandle();
|
|
89
|
-
}
|
|
90
|
-
});
|
|
91
|
-
result = unwrapped;
|
|
92
|
-
}
|
|
93
|
-
return addSecondaryWorldFlag ? { secondaryWorldValue: result } : result;
|
|
94
|
-
}
|
|
95
|
-
}
|
|
96
|
-
exports.PlaywrightJsHandle = PlaywrightJsHandle;
|
|
97
|
-
class PlaywrightElementHandle extends PlaywrightJsHandle {
|
|
98
|
-
constructor(element, page, delegate) {
|
|
99
|
-
super(element, page);
|
|
100
|
-
this.element = element;
|
|
101
|
-
this.page = page;
|
|
102
|
-
this.delegate = delegate;
|
|
103
|
-
try {
|
|
104
|
-
this.cdpSession = delegate.getCDPSession();
|
|
105
|
-
}
|
|
106
|
-
catch (e) {
|
|
107
|
-
(0, logUtils_1.logInternal)(`Unable to get a CDP session for the element handle. Error: ${e}`);
|
|
108
|
-
}
|
|
109
|
-
}
|
|
110
|
-
uploadFile(filePath) {
|
|
111
|
-
return this.element.setInputFiles(filePath);
|
|
112
|
-
}
|
|
113
|
-
async $x(xpathQuery) {
|
|
114
|
-
return (await this.element.$$(`xpath=${xpathQuery}`)).map((element) => new PlaywrightElementHandle(element, this.page, this.page.delegate.createElementHandleDelegate(element)));
|
|
115
|
-
}
|
|
116
|
-
asElement() {
|
|
117
|
-
return (0, utils_1.mapIfNotNull)(this.handle.asElement(), (handle) => new PlaywrightElementHandle(handle, this.page, this.page.delegate.createElementHandleDelegate(handle)));
|
|
118
|
-
}
|
|
119
|
-
async boundingBox() {
|
|
120
|
-
return (0, utils_1.mapIfNotNull)(await this.element.boundingBox(), (boundingBox) => boundingBox);
|
|
121
|
-
}
|
|
122
|
-
async maybeOverwriteScrollIntoViewDuringAction(action, options) {
|
|
123
|
-
if (options === null || options === void 0 ? void 0 : options.minimizeScrollIntoView) {
|
|
124
|
-
await this.overwriteScrollIntoViewFunction();
|
|
125
|
-
}
|
|
126
|
-
try {
|
|
127
|
-
return await action();
|
|
128
|
-
}
|
|
129
|
-
catch (e) {
|
|
130
|
-
throw e;
|
|
131
|
-
}
|
|
132
|
-
finally {
|
|
133
|
-
if (options === null || options === void 0 ? void 0 : options.minimizeScrollIntoView) {
|
|
134
|
-
await this.resetScrollIntoViewFunction();
|
|
135
|
-
}
|
|
136
|
-
}
|
|
137
|
-
}
|
|
138
|
-
click(options) {
|
|
139
|
-
return this.maybeOverwriteScrollIntoViewDuringAction(async () => {
|
|
140
|
-
var _a, _b, _c;
|
|
141
|
-
const trial = (_a = options === null || options === void 0 ? void 0 : options.trial) !== null && _a !== void 0 ? _a : false;
|
|
142
|
-
try {
|
|
143
|
-
await this.element.click({
|
|
144
|
-
button: options === null || options === void 0 ? void 0 : options.button,
|
|
145
|
-
clickCount: (_b = options === null || options === void 0 ? void 0 : options.clickCount) !== null && _b !== void 0 ? _b : 1,
|
|
146
|
-
force: (_c = options === null || options === void 0 ? void 0 : options.force) !== null && _c !== void 0 ? _c : !trial,
|
|
147
|
-
timeout: this.getActionTimeout(options),
|
|
148
|
-
trial,
|
|
149
|
-
});
|
|
150
|
-
}
|
|
151
|
-
catch (error) {
|
|
152
|
-
if (error.message.includes(exports.NAVIGATION_ERROR_MESSAGE)) {
|
|
153
|
-
(0, logUtils_1.logInternal)(`Action timed out due to navigation timeout. ${error.toString()}`);
|
|
154
|
-
return;
|
|
155
|
-
}
|
|
156
|
-
throw error;
|
|
157
|
-
}
|
|
158
|
-
}, {
|
|
159
|
-
minimizeScrollIntoView: options === null || options === void 0 ? void 0 : options.minimizeScrollIntoView,
|
|
160
|
-
});
|
|
161
|
-
}
|
|
162
|
-
async doubleClick(options) {
|
|
163
|
-
return this.maybeOverwriteScrollIntoViewDuringAction(async () => {
|
|
164
|
-
var _a, _b;
|
|
165
|
-
try {
|
|
166
|
-
const trial = (_a = options === null || options === void 0 ? void 0 : options.trial) !== null && _a !== void 0 ? _a : false;
|
|
167
|
-
return this.element.dblclick({
|
|
168
|
-
force: (_b = options === null || options === void 0 ? void 0 : options.force) !== null && _b !== void 0 ? _b : !trial,
|
|
169
|
-
timeout: this.getActionTimeout(options),
|
|
170
|
-
trial,
|
|
171
|
-
});
|
|
172
|
-
}
|
|
173
|
-
catch (error) {
|
|
174
|
-
if (error.message.includes(exports.NAVIGATION_ERROR_MESSAGE)) {
|
|
175
|
-
(0, logUtils_1.logInternal)(`Action timed out due to navigation timeout. ${error.toString()}`);
|
|
176
|
-
}
|
|
177
|
-
}
|
|
178
|
-
}, {
|
|
179
|
-
minimizeScrollIntoView: options === null || options === void 0 ? void 0 : options.minimizeScrollIntoView,
|
|
180
|
-
});
|
|
181
|
-
}
|
|
182
|
-
async clickablePoint() {
|
|
183
|
-
var _a;
|
|
184
|
-
const clickablePoint = await ((_a = this.delegate
|
|
185
|
-
.getElementImpl()) === null || _a === void 0 ? void 0 : _a._clickablePoint());
|
|
186
|
-
if (clickablePoint === 'error:notvisible' ||
|
|
187
|
-
clickablePoint === 'error:notinviewport') {
|
|
188
|
-
return undefined;
|
|
189
|
-
}
|
|
190
|
-
return clickablePoint;
|
|
191
|
-
}
|
|
192
|
-
async contentFrame() {
|
|
193
|
-
return (0, utils_1.mapIfNotNull)(await this.element.contentFrame(), (frame) => this.page.getOrCreateFrame(frame));
|
|
194
|
-
}
|
|
195
|
-
focus() {
|
|
196
|
-
return this.element.focus();
|
|
197
|
-
}
|
|
198
|
-
async frame() {
|
|
199
|
-
return (0, utils_1.mapIfNotNull)(await this.element.ownerFrame(), (frame) => this.page.getOrCreateFrame(frame));
|
|
200
|
-
}
|
|
201
|
-
hover() {
|
|
202
|
-
return this.element.hover();
|
|
203
|
-
}
|
|
204
|
-
scrollIntoViewIfNeeded() {
|
|
205
|
-
return this.element.scrollIntoViewIfNeeded();
|
|
206
|
-
}
|
|
207
|
-
async select(value, options) {
|
|
208
|
-
return this.maybeOverwriteScrollIntoViewDuringAction(async () => this.element.selectOption(value), {
|
|
209
|
-
minimizeScrollIntoView: options === null || options === void 0 ? void 0 : options.minimizeScrollIntoView,
|
|
210
|
-
});
|
|
211
|
-
}
|
|
212
|
-
async type(text, options) {
|
|
213
|
-
return this.maybeOverwriteScrollIntoViewDuringAction(async () => {
|
|
214
|
-
var _a;
|
|
215
|
-
const selectText = (_a = options === null || options === void 0 ? void 0 : options.selectText) !== null && _a !== void 0 ? _a : true;
|
|
216
|
-
if (selectText) {
|
|
217
|
-
await this.element.selectText({ force: true });
|
|
218
|
-
}
|
|
219
|
-
await this.element.type(text, {
|
|
220
|
-
delay: options === null || options === void 0 ? void 0 : options.delay,
|
|
221
|
-
timeout: 0,
|
|
222
|
-
});
|
|
223
|
-
}, {
|
|
224
|
-
minimizeScrollIntoView: options === null || options === void 0 ? void 0 : options.minimizeScrollIntoView,
|
|
225
|
-
});
|
|
226
|
-
}
|
|
227
|
-
press(key, options) {
|
|
228
|
-
return this.maybeOverwriteScrollIntoViewDuringAction(async () => this.element.press(key), {
|
|
229
|
-
minimizeScrollIntoView: options === null || options === void 0 ? void 0 : options.minimizeScrollIntoView,
|
|
230
|
-
});
|
|
231
|
-
}
|
|
232
|
-
highlight(highlightDurationMillis, highlightPhases) {
|
|
233
|
-
return this.delegate.highlight(highlightDurationMillis, highlightPhases);
|
|
234
|
-
}
|
|
235
|
-
async getValue() {
|
|
236
|
-
return this.element.inputValue();
|
|
237
|
-
}
|
|
238
|
-
async makeCDPCall(method, paramArgs) {
|
|
239
|
-
var _a;
|
|
240
|
-
return ((_a = this.cdpSession) !== null && _a !== void 0 ? _a : this.page.getCDPSession()).send(method, paramArgs);
|
|
241
|
-
}
|
|
242
|
-
getTagName() {
|
|
243
|
-
return this.element.evaluate((el) => el.tagName.toLowerCase());
|
|
244
|
-
}
|
|
245
|
-
async getAttribute(attributeName) {
|
|
246
|
-
const result = await this.element.evaluate((el, attributeName) => el.getAttribute(attributeName), attributeName);
|
|
247
|
-
return (0, pureUtil_1.isNullish)(result) ? undefined : result;
|
|
248
|
-
}
|
|
249
|
-
async getCSSProperty(propertyName) {
|
|
250
|
-
const result = await this.element.evaluate((el, propertyName) => globalThis.getComputedStyle(el).getPropertyValue(propertyName), propertyName);
|
|
251
|
-
return (0, pureUtil_1.isNullish)(result) ? undefined : result;
|
|
252
|
-
}
|
|
253
|
-
async getElementText() {
|
|
254
|
-
const innerText = await this.getInnerText();
|
|
255
|
-
return innerText ? innerText : this.getSlotText();
|
|
256
|
-
}
|
|
257
|
-
async getInnerText() {
|
|
258
|
-
const result = await this.delegate.getInnerText();
|
|
259
|
-
return (0, pureUtil_1.isNullish)(result) ? undefined : result;
|
|
260
|
-
}
|
|
261
|
-
async getSlotText() {
|
|
262
|
-
const result = await this.element.evaluate((el) => {
|
|
263
|
-
const slots = el.querySelectorAll('slot');
|
|
264
|
-
if (slots.length !== 1) {
|
|
265
|
-
return '';
|
|
266
|
-
}
|
|
267
|
-
const textNode = slots
|
|
268
|
-
.item(0)
|
|
269
|
-
.assignedNodes()
|
|
270
|
-
.find((node) => node.nodeType === Node.TEXT_NODE);
|
|
271
|
-
return textNode === null || textNode === void 0 ? void 0 : textNode.data;
|
|
272
|
-
});
|
|
273
|
-
return (0, pureUtil_1.isNullish)(result) ? undefined : result;
|
|
274
|
-
}
|
|
275
|
-
async isInShadowRoot() {
|
|
276
|
-
return this.element.evaluate((el) => el.getRootNode().nodeName === '#document-fragment');
|
|
277
|
-
}
|
|
278
|
-
focusAndSelect() {
|
|
279
|
-
return this.delegate.focusAndSelect(this);
|
|
280
|
-
}
|
|
281
|
-
async isVisible() {
|
|
282
|
-
return this.element.isVisible();
|
|
283
|
-
}
|
|
284
|
-
getActionTimeout(options) {
|
|
285
|
-
var _a;
|
|
286
|
-
const defaultTimeout = (options === null || options === void 0 ? void 0 : options.trial)
|
|
287
|
-
? types_1.DefaultTimeouts.defaultTrialTimeoutMs
|
|
288
|
-
: types_1.DefaultTimeouts.defaultActionTimeoutMs;
|
|
289
|
-
return (_a = options === null || options === void 0 ? void 0 : options.timeout) !== null && _a !== void 0 ? _a : defaultTimeout;
|
|
290
|
-
}
|
|
291
|
-
async overwriteScrollIntoViewFunction() {
|
|
292
|
-
var _a;
|
|
293
|
-
await ((_a = this.delegate
|
|
294
|
-
.getElementImpl()) === null || _a === void 0 ? void 0 : _a.evaluateInUtility(([, node]) => {
|
|
295
|
-
const element = node;
|
|
296
|
-
if (!element.__mablOriginalScrollIntoView) {
|
|
297
|
-
element.__mablOriginalScrollIntoView = element.scrollIntoView;
|
|
298
|
-
}
|
|
299
|
-
element.scrollIntoView = () => element.scrollIntoViewIfNeeded();
|
|
300
|
-
}, []));
|
|
301
|
-
}
|
|
302
|
-
async resetScrollIntoViewFunction() {
|
|
303
|
-
var _a;
|
|
304
|
-
try {
|
|
305
|
-
await ((_a = this.delegate
|
|
306
|
-
.getElementImpl()) === null || _a === void 0 ? void 0 : _a.evaluateInUtility(([, node]) => {
|
|
307
|
-
const element = node;
|
|
308
|
-
const originalFunction = element.__mablOriginalScrollIntoView;
|
|
309
|
-
if (originalFunction) {
|
|
310
|
-
element.scrollIntoView = originalFunction;
|
|
311
|
-
}
|
|
312
|
-
}, []));
|
|
313
|
-
}
|
|
314
|
-
catch (error) {
|
|
315
|
-
(0, logUtils_1.logInternal)(`Error while resetting scrollIntoView function: ${error}`);
|
|
316
|
-
}
|
|
317
|
-
}
|
|
318
|
-
}
|
|
319
|
-
exports.PlaywrightElementHandle = PlaywrightElementHandle;
|
|
@@ -1,265 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
-
if (k2 === undefined) k2 = k;
|
|
4
|
-
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
-
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
-
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
-
}
|
|
8
|
-
Object.defineProperty(o, k2, desc);
|
|
9
|
-
}) : (function(o, m, k, k2) {
|
|
10
|
-
if (k2 === undefined) k2 = k;
|
|
11
|
-
o[k2] = m[k];
|
|
12
|
-
}));
|
|
13
|
-
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
-
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
-
}) : function(o, v) {
|
|
16
|
-
o["default"] = v;
|
|
17
|
-
});
|
|
18
|
-
var __importStar = (this && this.__importStar) || function (mod) {
|
|
19
|
-
if (mod && mod.__esModule) return mod;
|
|
20
|
-
var result = {};
|
|
21
|
-
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
22
|
-
__setModuleDefault(result, mod);
|
|
23
|
-
return result;
|
|
24
|
-
};
|
|
25
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
26
|
-
exports.PlaywrightFrame = exports.UTILITY_CONTEXT_NAME = void 0;
|
|
27
|
-
const browserLauncher_1 = require("../browserLauncher");
|
|
28
|
-
const playwright = __importStar(require("playwright"));
|
|
29
|
-
const types_1 = require("../types");
|
|
30
|
-
const utils_1 = require("../utils");
|
|
31
|
-
const playwrightHttpResponse_1 = require("./playwrightHttpResponse");
|
|
32
|
-
const playwrightDom_1 = require("./playwrightDom");
|
|
33
|
-
const testsUtil_1 = require("../../commands/tests/testsUtil");
|
|
34
|
-
const logUtils_1 = require("../../util/logUtils");
|
|
35
|
-
const WAIT_FOR_CONTEXT_TIMEOUT = 1000;
|
|
36
|
-
const MAIN_CONTEXT = 'main';
|
|
37
|
-
const UTILITY_CONTEXT = 'utility';
|
|
38
|
-
exports.UTILITY_CONTEXT_NAME = '__playwright_utility_world__';
|
|
39
|
-
class PlaywrightFrame extends browserLauncher_1.Frame {
|
|
40
|
-
constructor(frame, parentPage, delegate) {
|
|
41
|
-
super();
|
|
42
|
-
this.frame = frame;
|
|
43
|
-
this.parentPage = parentPage;
|
|
44
|
-
this.delegate = delegate;
|
|
45
|
-
this.injectSecondaryWorld();
|
|
46
|
-
}
|
|
47
|
-
injectSecondaryWorld() {
|
|
48
|
-
const playwrightFrame = this;
|
|
49
|
-
const serverFrame = this.getFrameImpl();
|
|
50
|
-
if (serverFrame === undefined) {
|
|
51
|
-
return;
|
|
52
|
-
}
|
|
53
|
-
const originalSetContext = serverFrame._setContext.bind(serverFrame);
|
|
54
|
-
serverFrame._setContext = function (world, context) {
|
|
55
|
-
originalSetContext(world, context);
|
|
56
|
-
if (world === UTILITY_CONTEXT) {
|
|
57
|
-
playwrightFrame.emit(browserLauncher_1.PageEvent.SecondaryWorldCreated);
|
|
58
|
-
}
|
|
59
|
-
};
|
|
60
|
-
serverFrame.checkWorldFunction = async function (arg) {
|
|
61
|
-
let forcedWorld = MAIN_CONTEXT;
|
|
62
|
-
if (this.utilityWorldAvailable === undefined) {
|
|
63
|
-
await Promise.race([
|
|
64
|
-
this._contextData.get(UTILITY_CONTEXT).contextPromise,
|
|
65
|
-
(0, testsUtil_1.sleep)(WAIT_FOR_CONTEXT_TIMEOUT),
|
|
66
|
-
]);
|
|
67
|
-
this.utilityWorldAvailable =
|
|
68
|
-
this._contextData.get(UTILITY_CONTEXT).context !== null;
|
|
69
|
-
}
|
|
70
|
-
if (arg === null || arg === void 0 ? void 0 : arg.hasOwnProperty('secondaryWorldValue')) {
|
|
71
|
-
forcedWorld = UTILITY_CONTEXT;
|
|
72
|
-
if (!this.utilityWorldAvailable) {
|
|
73
|
-
this._contextData.set(UTILITY_CONTEXT, this._contextData.get(MAIN_CONTEXT));
|
|
74
|
-
this.utilityWorldAvailable = true;
|
|
75
|
-
}
|
|
76
|
-
arg = arg.secondaryWorldValue;
|
|
77
|
-
}
|
|
78
|
-
return { world: forcedWorld, value: arg };
|
|
79
|
-
};
|
|
80
|
-
const originalEvaluateExpressionFunction = serverFrame.evaluateExpression.bind(serverFrame);
|
|
81
|
-
const functionOverride = async function (expression, options = {}, arg) {
|
|
82
|
-
const { world, value } = await this.checkWorldFunction(arg);
|
|
83
|
-
return originalEvaluateExpressionFunction(expression, {
|
|
84
|
-
isFunction: options.isFunction,
|
|
85
|
-
exposeUtilityScript: options.exposeUtilityScript,
|
|
86
|
-
world,
|
|
87
|
-
}, value);
|
|
88
|
-
};
|
|
89
|
-
serverFrame.evaluateExpression = functionOverride.bind(serverFrame);
|
|
90
|
-
const originalEvaluateExpressionHandleFunction = serverFrame.evaluateExpressionHandle.bind(serverFrame);
|
|
91
|
-
const functionHandleOverride = async function (expression, options = {}, arg) {
|
|
92
|
-
const { world, value } = await this.checkWorldFunction(arg);
|
|
93
|
-
return originalEvaluateExpressionHandleFunction(expression, {
|
|
94
|
-
isFunction: options.isFunction,
|
|
95
|
-
exposeUtilityScript: options.exposeUtilityScript,
|
|
96
|
-
world,
|
|
97
|
-
}, value);
|
|
98
|
-
};
|
|
99
|
-
serverFrame.evaluateExpressionHandle =
|
|
100
|
-
functionHandleOverride.bind(serverFrame);
|
|
101
|
-
}
|
|
102
|
-
async $(selector) {
|
|
103
|
-
return (0, utils_1.mapIfNotNull)(await this.frame.$(selector), (handle) => new playwrightDom_1.PlaywrightElementHandle(handle, this.parentPage, this.parentPage.delegate.createElementHandleDelegate(handle)));
|
|
104
|
-
}
|
|
105
|
-
async $$(selector) {
|
|
106
|
-
const maybePlaywrightHandles = await this.frame.$$(selector);
|
|
107
|
-
if (!maybePlaywrightHandles.length) {
|
|
108
|
-
return [];
|
|
109
|
-
}
|
|
110
|
-
return maybePlaywrightHandles.map((handle) => new playwrightDom_1.PlaywrightElementHandle(handle, this.parentPage, this.parentPage.delegate.createElementHandleDelegate(handle)));
|
|
111
|
-
}
|
|
112
|
-
async $$eval(selector, pageFunction, ...args) {
|
|
113
|
-
const result = await this.frame.$$eval(selector, pageFunction, ...args === null || args === void 0 ? void 0 : args.map((argument) => argument instanceof playwrightDom_1.PlaywrightJsHandle
|
|
114
|
-
? argument.getPlaywrightHandle()
|
|
115
|
-
: argument));
|
|
116
|
-
return result;
|
|
117
|
-
}
|
|
118
|
-
async $eval(selector, pageFunction, ...args) {
|
|
119
|
-
const result = await this.frame.$eval(selector, pageFunction, ...args === null || args === void 0 ? void 0 : args.map((argument) => argument instanceof playwrightDom_1.PlaywrightJsHandle
|
|
120
|
-
? argument.getPlaywrightHandle()
|
|
121
|
-
: argument));
|
|
122
|
-
return result;
|
|
123
|
-
}
|
|
124
|
-
async $x(xpathQuery) {
|
|
125
|
-
return (await this.frame.$$(`xpath=${xpathQuery}`)).map((element) => new playwrightDom_1.PlaywrightElementHandle(element, this.parentPage, this.parentPage.delegate.createElementHandleDelegate(element)));
|
|
126
|
-
}
|
|
127
|
-
childFrames() {
|
|
128
|
-
return this.frame
|
|
129
|
-
.childFrames()
|
|
130
|
-
.map((frame) => this.parentPage.getOrCreateFrame(frame));
|
|
131
|
-
}
|
|
132
|
-
evaluate(pageFunction, arg, addSecondaryWorldFlag = false) {
|
|
133
|
-
return this.frame.evaluate(pageFunction, playwrightDom_1.PlaywrightJsHandle.unwrapProperties(arg, addSecondaryWorldFlag));
|
|
134
|
-
}
|
|
135
|
-
async evaluateCodeInSecondaryWorld(code, arg) {
|
|
136
|
-
return (await this.evaluate(code, arg, true));
|
|
137
|
-
}
|
|
138
|
-
async evaluateHandleInSecondaryWorld(code, arg) {
|
|
139
|
-
return new playwrightDom_1.PlaywrightJsHandle(await this.frame.evaluateHandle(code, playwrightDom_1.PlaywrightJsHandle.unwrapProperties(arg, true)), this.parentPage);
|
|
140
|
-
}
|
|
141
|
-
async getFrameOwnerElement() {
|
|
142
|
-
const frameElement = await this.frame.frameElement();
|
|
143
|
-
return new playwrightDom_1.PlaywrightElementHandle(frameElement, this.parentPage, this.parentPage.delegate.createElementHandleDelegate(frameElement));
|
|
144
|
-
}
|
|
145
|
-
async goto(url, options) {
|
|
146
|
-
const lifecycleEvent = this.delegate.getLifecycleEventStrategy(options === null || options === void 0 ? void 0 : options.waitUntil);
|
|
147
|
-
try {
|
|
148
|
-
return await this.tryGoto(url, lifecycleEvent, options);
|
|
149
|
-
}
|
|
150
|
-
catch (e) {
|
|
151
|
-
(0, logUtils_1.logErrorVerbose)(e);
|
|
152
|
-
if (e instanceof playwright.errors.TimeoutError) {
|
|
153
|
-
throw new browserLauncher_1.RUNNER_ERRORS.TimeoutError(e.message);
|
|
154
|
-
}
|
|
155
|
-
throw new browserLauncher_1.RunnerError(e.message);
|
|
156
|
-
}
|
|
157
|
-
}
|
|
158
|
-
async tryGoto(url, lifecycleEvent, options) {
|
|
159
|
-
var _a;
|
|
160
|
-
const timeout = (_a = options === null || options === void 0 ? void 0 : options.timeout) !== null && _a !== void 0 ? _a : types_1.DefaultTimeouts.defaultWaitTimeoutMs;
|
|
161
|
-
let response;
|
|
162
|
-
let responseHasNavigationError = false;
|
|
163
|
-
try {
|
|
164
|
-
response = await this.frame.goto(url, {
|
|
165
|
-
waitUntil: lifecycleEvent.waitUntil,
|
|
166
|
-
timeout: options === null || options === void 0 ? void 0 : options.timeout,
|
|
167
|
-
});
|
|
168
|
-
}
|
|
169
|
-
catch (e) {
|
|
170
|
-
if (browserLauncher_1.RunnerError.isPlaywrightNavigationInterruptedError(e)) {
|
|
171
|
-
(0, logUtils_1.logErrorVerbose)(e);
|
|
172
|
-
responseHasNavigationError = true;
|
|
173
|
-
}
|
|
174
|
-
else {
|
|
175
|
-
throw e;
|
|
176
|
-
}
|
|
177
|
-
}
|
|
178
|
-
if (lifecycleEvent.waitForNetworkIdle || responseHasNavigationError) {
|
|
179
|
-
await this.frame.waitForLoadState(types_1.LifecycleEvent.NetworkIdle, {
|
|
180
|
-
timeout,
|
|
181
|
-
});
|
|
182
|
-
}
|
|
183
|
-
return (0, utils_1.mapIfNotNull)(response, (response) => new playwrightHttpResponse_1.PlaywrightHttpResponse(this.parentPage, response));
|
|
184
|
-
}
|
|
185
|
-
id() {
|
|
186
|
-
return this.frame._guid;
|
|
187
|
-
}
|
|
188
|
-
name() {
|
|
189
|
-
return this.frame.name();
|
|
190
|
-
}
|
|
191
|
-
parentFrame() {
|
|
192
|
-
return (0, utils_1.mapIfNotNull)(this.frame.parentFrame(), (frame) => this.parentPage.getOrCreateFrame(frame));
|
|
193
|
-
}
|
|
194
|
-
url() {
|
|
195
|
-
return this.delegate.url();
|
|
196
|
-
}
|
|
197
|
-
async waitForSelector(selector, options) {
|
|
198
|
-
return (0, utils_1.mapIfNotNull)(await this.frame.waitForSelector(selector, options), (handle) => new playwrightDom_1.PlaywrightElementHandle(handle, this.parentPage, this.parentPage.delegate.createElementHandleDelegate(handle)));
|
|
199
|
-
}
|
|
200
|
-
page() {
|
|
201
|
-
return this.parentPage;
|
|
202
|
-
}
|
|
203
|
-
title() {
|
|
204
|
-
return this.frame.title();
|
|
205
|
-
}
|
|
206
|
-
makeCDPCall(method, paramArgs) {
|
|
207
|
-
const pageImpl = this.page().getPageImpl();
|
|
208
|
-
const frameSession = pageImpl._sessionForFrame(this.frame);
|
|
209
|
-
const client = frameSession._client;
|
|
210
|
-
return client.send(method, paramArgs);
|
|
211
|
-
}
|
|
212
|
-
getFrameImpl() {
|
|
213
|
-
if (this.frameImpl === undefined) {
|
|
214
|
-
try {
|
|
215
|
-
return playwright._toImpl(this.frame);
|
|
216
|
-
}
|
|
217
|
-
catch (e) {
|
|
218
|
-
}
|
|
219
|
-
}
|
|
220
|
-
return this.frameImpl;
|
|
221
|
-
}
|
|
222
|
-
getExposedFunctionBindingInfo(functionName) {
|
|
223
|
-
var _a;
|
|
224
|
-
try {
|
|
225
|
-
const pageImpl = this.parentPage.getPageImpl();
|
|
226
|
-
if (!pageImpl) {
|
|
227
|
-
return;
|
|
228
|
-
}
|
|
229
|
-
return ((_a = pageImpl._pageBindings.get(functionName)) !== null && _a !== void 0 ? _a : pageImpl._browserContext._pageBindings.get(functionName));
|
|
230
|
-
}
|
|
231
|
-
catch (e) {
|
|
232
|
-
return;
|
|
233
|
-
}
|
|
234
|
-
}
|
|
235
|
-
async initializeExposedFunctionInSecondaryWorld(functionName) {
|
|
236
|
-
try {
|
|
237
|
-
const binding = this.getExposedFunctionBindingInfo(functionName);
|
|
238
|
-
if (!binding) {
|
|
239
|
-
return false;
|
|
240
|
-
}
|
|
241
|
-
await this.delegate.addBindingToSecondaryWorld(binding);
|
|
242
|
-
await this.evaluateCodeInSecondaryWorld(binding.initScript.source, {});
|
|
243
|
-
}
|
|
244
|
-
catch (e) {
|
|
245
|
-
return false;
|
|
246
|
-
}
|
|
247
|
-
return true;
|
|
248
|
-
}
|
|
249
|
-
async getInjectedScriptInSecondaryWorld() {
|
|
250
|
-
const context = await this.getFrameImpl()._utilityContext();
|
|
251
|
-
return new playwrightDom_1.PlaywrightJsHandle(await context.injectedScript(), this.page());
|
|
252
|
-
}
|
|
253
|
-
async getInjectedScriptInMainWorld() {
|
|
254
|
-
const context = await this.getFrameImpl()._mainContext();
|
|
255
|
-
return new playwrightDom_1.PlaywrightJsHandle(await context.injectedScript(), this.page());
|
|
256
|
-
}
|
|
257
|
-
isDetached() {
|
|
258
|
-
return this.frame.isDetached();
|
|
259
|
-
}
|
|
260
|
-
async getOwnerElementHandle() {
|
|
261
|
-
const element = await this.frame.frameElement();
|
|
262
|
-
return new playwrightDom_1.PlaywrightElementHandle(element, this.parentPage, this.parentPage.delegate.createElementHandleDelegate(element));
|
|
263
|
-
}
|
|
264
|
-
}
|
|
265
|
-
exports.PlaywrightFrame = PlaywrightFrame;
|
|
@@ -1,76 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
-
if (k2 === undefined) k2 = k;
|
|
4
|
-
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
-
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
-
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
-
}
|
|
8
|
-
Object.defineProperty(o, k2, desc);
|
|
9
|
-
}) : (function(o, m, k, k2) {
|
|
10
|
-
if (k2 === undefined) k2 = k;
|
|
11
|
-
o[k2] = m[k];
|
|
12
|
-
}));
|
|
13
|
-
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
-
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
-
}) : function(o, v) {
|
|
16
|
-
o["default"] = v;
|
|
17
|
-
});
|
|
18
|
-
var __importStar = (this && this.__importStar) || function (mod) {
|
|
19
|
-
if (mod && mod.__esModule) return mod;
|
|
20
|
-
var result = {};
|
|
21
|
-
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
22
|
-
__setModuleDefault(result, mod);
|
|
23
|
-
return result;
|
|
24
|
-
};
|
|
25
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
26
|
-
exports.PlaywrightHttpRequest = void 0;
|
|
27
|
-
const playwright = __importStar(require("playwright"));
|
|
28
|
-
const logUtils_1 = require("../../util/logUtils");
|
|
29
|
-
class PlaywrightHttpRequest {
|
|
30
|
-
constructor(page, request, route) {
|
|
31
|
-
var _a;
|
|
32
|
-
this.page = page;
|
|
33
|
-
this.request = request;
|
|
34
|
-
this.route = route;
|
|
35
|
-
this.requestIntercepted = false;
|
|
36
|
-
try {
|
|
37
|
-
this.documentId = playwright._toImpl(this.request)._documentId;
|
|
38
|
-
}
|
|
39
|
-
catch (e) {
|
|
40
|
-
(0, logUtils_1.logInternal)(`Unable to get documentId from request: ${e.message}`);
|
|
41
|
-
}
|
|
42
|
-
(_a = this.documentId) !== null && _a !== void 0 ? _a : (this.documentId = this.request._guid);
|
|
43
|
-
}
|
|
44
|
-
abort() {
|
|
45
|
-
var _a;
|
|
46
|
-
if (this.route === undefined) {
|
|
47
|
-
throw new Error('Unable to abort an unrouted request');
|
|
48
|
-
}
|
|
49
|
-
this.requestIntercepted = true;
|
|
50
|
-
return (_a = this.route) === null || _a === void 0 ? void 0 : _a.abort();
|
|
51
|
-
}
|
|
52
|
-
frame() {
|
|
53
|
-
return this.page.getOrCreateFrame(this.request.frame());
|
|
54
|
-
}
|
|
55
|
-
requestId() {
|
|
56
|
-
return this.documentId;
|
|
57
|
-
}
|
|
58
|
-
respond(response) {
|
|
59
|
-
var _a;
|
|
60
|
-
if (this.route === undefined) {
|
|
61
|
-
throw new Error('Unable to respond an unrouted request');
|
|
62
|
-
}
|
|
63
|
-
this.requestIntercepted = true;
|
|
64
|
-
return (_a = this.route) === null || _a === void 0 ? void 0 : _a.fulfill(response);
|
|
65
|
-
}
|
|
66
|
-
url() {
|
|
67
|
-
return this.request.url();
|
|
68
|
-
}
|
|
69
|
-
headers() {
|
|
70
|
-
return this.request.allHeaders();
|
|
71
|
-
}
|
|
72
|
-
wasIntercepted() {
|
|
73
|
-
return this.requestIntercepted;
|
|
74
|
-
}
|
|
75
|
-
}
|
|
76
|
-
exports.PlaywrightHttpRequest = PlaywrightHttpRequest;
|
|
@@ -1,26 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.PlaywrightHttpResponse = void 0;
|
|
4
|
-
const playwrightHttpRequest_1 = require("./playwrightHttpRequest");
|
|
5
|
-
class PlaywrightHttpResponse {
|
|
6
|
-
constructor(page, response) {
|
|
7
|
-
this.page = page;
|
|
8
|
-
this.response = response;
|
|
9
|
-
}
|
|
10
|
-
frame() {
|
|
11
|
-
return this.page.getOrCreateFrame(this.response.frame());
|
|
12
|
-
}
|
|
13
|
-
headers() {
|
|
14
|
-
return this.response.headers();
|
|
15
|
-
}
|
|
16
|
-
request() {
|
|
17
|
-
return new playwrightHttpRequest_1.PlaywrightHttpRequest(this.page, this.response.request());
|
|
18
|
-
}
|
|
19
|
-
url() {
|
|
20
|
-
return this.response.url();
|
|
21
|
-
}
|
|
22
|
-
json() {
|
|
23
|
-
return this.response.json();
|
|
24
|
-
}
|
|
25
|
-
}
|
|
26
|
-
exports.PlaywrightHttpResponse = PlaywrightHttpResponse;
|