patchright-core 1.58.2 → 1.59.0
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/ThirdPartyNotices.txt +126 -650
- package/browsers.json +16 -14
- package/lib/bootstrap.js +77 -0
- package/lib/cli/browserActions.js +308 -0
- package/lib/cli/driver.js +3 -2
- package/lib/cli/installActions.js +171 -0
- package/lib/cli/program.js +47 -411
- package/lib/client/android.js +4 -4
- package/lib/client/api.js +3 -3
- package/lib/client/browser.js +8 -0
- package/lib/client/browserContext.js +22 -61
- package/lib/client/browserType.js +19 -51
- package/lib/client/cdpSession.js +6 -2
- package/lib/client/channelOwner.js +1 -1
- package/lib/client/clientHelper.js +2 -1
- package/lib/client/clock.js +0 -1
- package/lib/client/{webSocket.js → connect.js} +57 -7
- package/lib/client/connection.js +8 -4
- package/lib/client/consoleMessage.js +3 -0
- package/lib/client/debugger.js +57 -0
- package/lib/client/dialog.js +8 -1
- package/lib/client/disposable.js +76 -0
- package/lib/client/electron.js +1 -0
- package/lib/client/elementHandle.js +1 -4
- package/lib/client/events.js +3 -3
- package/lib/client/fetch.js +0 -1
- package/lib/client/frame.js +10 -23
- package/lib/client/harRouter.js +13 -1
- package/lib/client/jsHandle.js +4 -8
- package/lib/client/locator.js +13 -44
- package/lib/client/network.js +15 -16
- package/lib/client/page.js +41 -75
- package/lib/client/platform.js +0 -3
- package/lib/client/screencast.js +88 -0
- package/lib/client/selectors.js +3 -1
- package/lib/client/tracing.js +11 -5
- package/lib/client/video.js +13 -20
- package/lib/client/worker.js +6 -6
- package/lib/generated/bindingsControllerSource.js +1 -1
- package/lib/generated/clockSource.js +1 -1
- package/lib/generated/injectedScriptSource.js +1 -1
- package/lib/generated/pollingRecorderSource.js +1 -1
- package/lib/generated/storageScriptSource.js +1 -1
- package/lib/generated/utilityScriptSource.js +1 -1
- package/lib/mcpBundle.js +0 -6
- package/lib/mcpBundleImpl.js +91 -0
- package/lib/protocol/validator.js +224 -138
- package/lib/protocol/validatorPrimitives.js +1 -1
- package/lib/remote/playwrightConnection.js +10 -8
- package/lib/remote/playwrightPipeServer.js +100 -0
- package/lib/remote/playwrightServer.js +13 -8
- package/lib/remote/playwrightWebSocketServer.js +73 -0
- package/lib/remote/serverTransport.js +96 -0
- package/lib/server/android/android.js +2 -2
- package/lib/server/bidi/bidiBrowser.js +30 -8
- package/lib/server/bidi/bidiChromium.js +18 -5
- package/lib/server/bidi/bidiNetworkManager.js +39 -11
- package/lib/server/bidi/bidiPage.js +31 -15
- package/lib/server/bidi/third_party/firefoxPrefs.js +3 -1
- package/lib/server/browser.js +84 -21
- package/lib/server/browserContext.js +110 -58
- package/lib/server/browserType.js +14 -12
- package/lib/server/chromium/chromium.js +15 -12
- package/lib/server/chromium/chromiumSwitches.js +14 -2
- package/lib/server/chromium/crBrowser.js +20 -17
- package/lib/server/chromium/crCoverage.js +1 -13
- package/lib/server/chromium/crDevTools.js +1 -0
- package/lib/server/chromium/crNetworkManager.js +12 -267
- package/lib/server/chromium/crPage.js +67 -199
- package/lib/server/chromium/crServiceWorker.js +7 -14
- package/lib/server/clock.js +33 -41
- package/lib/server/console.js +5 -1
- package/lib/server/debugController.js +12 -6
- package/lib/server/debugger.js +40 -47
- package/lib/server/deviceDescriptorsSource.json +137 -137
- package/lib/server/dispatchers/browserContextDispatcher.js +29 -30
- package/lib/server/dispatchers/browserDispatcher.js +11 -5
- package/lib/server/dispatchers/browserTypeDispatcher.js +7 -0
- package/lib/server/dispatchers/cdpSessionDispatcher.js +4 -1
- package/lib/server/dispatchers/debuggerDispatcher.js +84 -0
- package/lib/server/dispatchers/dispatcher.js +1 -1
- package/lib/server/dispatchers/disposableDispatcher.js +39 -0
- package/lib/server/dispatchers/electronDispatcher.js +2 -1
- package/lib/server/dispatchers/frameDispatcher.js +6 -6
- package/lib/server/dispatchers/jsHandleDispatcher.js +2 -2
- package/lib/server/dispatchers/localUtilsDispatcher.js +37 -1
- package/lib/server/dispatchers/networkDispatchers.js +6 -5
- package/lib/server/dispatchers/pageDispatcher.js +101 -38
- package/lib/server/dispatchers/webSocketRouteDispatcher.js +4 -5
- package/lib/server/disposable.js +41 -0
- package/lib/server/dom.js +44 -26
- package/lib/server/download.js +3 -2
- package/lib/server/electron/electron.js +12 -7
- package/lib/server/firefox/ffBrowser.js +9 -19
- package/lib/server/firefox/ffInput.js +21 -5
- package/lib/server/firefox/ffNetworkManager.js +2 -2
- package/lib/server/firefox/ffPage.js +24 -27
- package/lib/server/frameSelectors.js +5 -172
- package/lib/server/frames.js +234 -687
- package/lib/server/har/harRecorder.js +2 -2
- package/lib/server/har/harTracer.js +5 -4
- package/lib/server/input.js +49 -4
- package/lib/server/instrumentation.js +5 -0
- package/lib/server/javascript.js +6 -26
- package/lib/server/launchApp.js +1 -3
- package/lib/server/localUtils.js +6 -6
- package/lib/server/network.js +9 -8
- package/lib/server/overlay.js +138 -0
- package/lib/server/page.js +157 -105
- package/lib/server/progress.js +6 -0
- package/lib/server/recorder/recorderApp.js +9 -8
- package/lib/server/recorder.js +76 -40
- package/lib/server/registry/index.js +55 -82
- package/lib/server/registry/nativeDeps.js +1 -0
- package/lib/server/screencast.js +90 -143
- package/lib/server/screenshotter.js +0 -6
- package/lib/server/trace/recorder/snapshotter.js +8 -17
- package/lib/server/trace/recorder/snapshotterInjected.js +82 -20
- package/lib/server/trace/recorder/tracing.js +87 -44
- package/lib/server/trace/viewer/traceViewer.js +3 -4
- package/lib/server/usKeyboardLayout.js +7 -0
- package/lib/server/utils/comparators.js +1 -1
- package/lib/server/utils/disposable.js +32 -0
- package/lib/server/utils/eventsHelper.js +3 -1
- package/lib/server/utils/fileUtils.js +16 -2
- package/lib/server/utils/happyEyeballs.js +15 -12
- package/lib/server/utils/hostPlatform.js +0 -15
- package/lib/server/utils/httpServer.js +5 -3
- package/lib/server/utils/network.js +2 -1
- package/lib/server/utils/nodePlatform.js +0 -6
- package/lib/server/utils/processLauncher.js +8 -6
- package/lib/server/utils/zipFile.js +2 -2
- package/lib/server/videoRecorder.js +82 -12
- package/lib/server/webkit/wkBrowser.js +1 -6
- package/lib/server/webkit/wkPage.js +27 -25
- package/lib/server/webkit/wkWorkers.js +2 -1
- package/lib/serverRegistry.js +156 -0
- package/lib/tools/backend/browserBackend.js +79 -0
- package/lib/tools/backend/common.js +63 -0
- package/lib/tools/backend/config.js +41 -0
- package/lib/tools/backend/console.js +66 -0
- package/lib/tools/backend/context.js +296 -0
- package/lib/tools/backend/cookies.js +152 -0
- package/lib/tools/backend/devtools.js +69 -0
- package/lib/tools/backend/dialogs.js +59 -0
- package/lib/tools/backend/evaluate.js +64 -0
- package/lib/tools/backend/files.js +60 -0
- package/lib/tools/backend/form.js +64 -0
- package/lib/tools/backend/keyboard.js +155 -0
- package/lib/tools/backend/logFile.js +95 -0
- package/lib/tools/backend/mouse.js +168 -0
- package/lib/tools/backend/navigate.js +106 -0
- package/lib/tools/backend/network.js +135 -0
- package/lib/tools/backend/pdf.js +48 -0
- package/lib/tools/backend/response.js +305 -0
- package/lib/tools/backend/route.js +140 -0
- package/lib/tools/backend/runCode.js +77 -0
- package/lib/tools/backend/screenshot.js +88 -0
- package/lib/tools/backend/sessionLog.js +74 -0
- package/lib/tools/backend/snapshot.js +208 -0
- package/lib/tools/backend/storage.js +68 -0
- package/lib/tools/backend/tab.js +445 -0
- package/lib/tools/backend/tabs.js +67 -0
- package/lib/tools/backend/tool.js +47 -0
- package/lib/tools/backend/tools.js +102 -0
- package/lib/tools/backend/tracing.js +78 -0
- package/lib/tools/backend/utils.js +83 -0
- package/lib/tools/backend/verify.js +151 -0
- package/lib/tools/backend/video.js +98 -0
- package/lib/tools/backend/wait.js +63 -0
- package/lib/tools/backend/webstorage.js +223 -0
- package/lib/tools/cli-client/cli.js +6 -0
- package/lib/tools/cli-client/help.json +399 -0
- package/lib/tools/cli-client/minimist.js +128 -0
- package/lib/tools/cli-client/program.js +350 -0
- package/lib/tools/cli-client/registry.js +176 -0
- package/lib/tools/cli-client/session.js +289 -0
- package/lib/tools/cli-client/skill/SKILL.md +328 -0
- package/lib/tools/cli-client/skill/references/element-attributes.md +23 -0
- package/lib/tools/cli-client/skill/references/playwright-tests.md +39 -0
- package/lib/tools/cli-client/skill/references/request-mocking.md +87 -0
- package/lib/tools/cli-client/skill/references/running-code.md +231 -0
- package/lib/tools/cli-client/skill/references/session-management.md +169 -0
- package/lib/tools/cli-client/skill/references/storage-state.md +275 -0
- package/lib/tools/cli-client/skill/references/test-generation.md +88 -0
- package/lib/tools/cli-client/skill/references/tracing.md +139 -0
- package/lib/tools/cli-client/skill/references/video-recording.md +143 -0
- package/lib/tools/cli-daemon/command.js +73 -0
- package/lib/tools/cli-daemon/commands.js +956 -0
- package/lib/tools/cli-daemon/daemon.js +157 -0
- package/lib/tools/cli-daemon/helpGenerator.js +177 -0
- package/lib/tools/cli-daemon/program.js +129 -0
- package/lib/tools/dashboard/appIcon.png +0 -0
- package/lib/tools/dashboard/dashboardApp.js +284 -0
- package/lib/tools/dashboard/dashboardController.js +296 -0
- package/lib/tools/exports.js +60 -0
- package/lib/tools/mcp/browserFactory.js +233 -0
- package/lib/tools/mcp/cdpRelay.js +352 -0
- package/lib/tools/mcp/cli-stub.js +7 -0
- package/lib/tools/mcp/config.d.js +16 -0
- package/lib/tools/mcp/config.js +446 -0
- package/lib/tools/mcp/configIni.js +189 -0
- package/lib/tools/mcp/extensionContextFactory.js +55 -0
- package/lib/tools/mcp/index.js +62 -0
- package/lib/tools/mcp/log.js +35 -0
- package/lib/tools/mcp/program.js +107 -0
- package/lib/tools/mcp/protocol.js +28 -0
- package/lib/tools/mcp/watchdog.js +44 -0
- package/lib/tools/trace/SKILL.md +171 -0
- package/lib/{server/trace/viewer/traceParser.js → tools/trace/installSkill.js} +15 -39
- package/lib/tools/trace/traceActions.js +142 -0
- package/lib/tools/trace/traceAttachments.js +69 -0
- package/lib/tools/trace/traceCli.js +87 -0
- package/lib/tools/trace/traceConsole.js +97 -0
- package/lib/tools/trace/traceErrors.js +55 -0
- package/lib/tools/trace/traceOpen.js +69 -0
- package/lib/tools/trace/traceParser.js +96 -0
- package/lib/tools/trace/traceRequests.js +182 -0
- package/lib/tools/trace/traceScreenshot.js +68 -0
- package/lib/tools/trace/traceSnapshot.js +149 -0
- package/lib/tools/trace/traceUtils.js +153 -0
- package/lib/tools/utils/connect.js +32 -0
- package/lib/tools/utils/mcp/http.js +152 -0
- package/lib/tools/utils/mcp/server.js +230 -0
- package/lib/tools/utils/mcp/tool.js +47 -0
- package/lib/tools/utils/socketConnection.js +108 -0
- package/lib/utils/isomorphic/formatUtils.js +64 -0
- package/lib/utils/isomorphic/jsonSchema.js +89 -0
- package/lib/utils/isomorphic/mimeType.js +7 -2
- package/lib/utils/isomorphic/protocolFormatter.js +2 -2
- package/lib/utils/isomorphic/protocolMetainfo.js +127 -106
- package/lib/utils/isomorphic/stringUtils.js +3 -3
- package/lib/utils/isomorphic/timeoutRunner.js +3 -3
- package/lib/utils/isomorphic/trace/snapshotRenderer.js +35 -42
- package/lib/utils/isomorphic/trace/traceLoader.js +15 -14
- package/lib/utils/isomorphic/trace/traceModel.js +3 -2
- package/lib/utils/isomorphic/trace/traceModernizer.js +1 -0
- package/lib/utils/isomorphic/urlMatch.js +54 -1
- package/lib/utils/isomorphic/utilityScriptSerializers.js +11 -0
- package/lib/utils.js +6 -2
- package/lib/utilsBundle.js +3 -21
- package/lib/utilsBundleImpl/index.js +132 -133
- package/lib/vite/dashboard/assets/index-BAOybkp8.js +50 -0
- package/lib/vite/dashboard/assets/index-CZAYOG76.css +1 -0
- package/lib/vite/dashboard/index.html +28 -0
- package/lib/vite/htmlReport/index.html +2 -70
- package/lib/vite/htmlReport/report.css +1 -0
- package/lib/vite/htmlReport/report.js +72 -0
- package/lib/vite/recorder/assets/{codeMirrorModule-CFUTFUO7.js → codeMirrorModule-C8KMvO9L.js} +20 -20
- package/lib/vite/recorder/assets/index-CqAYX1I3.js +193 -0
- package/lib/vite/recorder/index.html +1 -1
- package/lib/vite/traceViewer/assets/{codeMirrorModule-BVA4h_ZY.js → codeMirrorModule-DS0FLvoc.js} +20 -20
- package/lib/vite/traceViewer/assets/defaultSettingsView-GTWI-W_B.js +262 -0
- package/lib/vite/traceViewer/defaultSettingsView.B4dS75f0.css +1 -0
- package/lib/vite/traceViewer/{index.BVu7tZDe.css → index.CzXZzn5A.css} +1 -1
- package/lib/vite/traceViewer/{index.BtyWtaE-.js → index.Dtstcb7U.js} +1 -1
- package/lib/vite/traceViewer/index.html +4 -4
- package/lib/vite/traceViewer/sw.bundle.js +4 -4
- package/lib/vite/traceViewer/uiMode.Vipi55dB.js +6 -0
- package/lib/vite/traceViewer/uiMode.html +3 -3
- package/lib/zipBundleImpl.js +2 -2
- package/lib/zodBundle.js +39 -0
- package/lib/zodBundleImpl.js +40 -0
- package/package.json +6 -1
- package/types/protocol.d.ts +947 -51
- package/types/types.d.ts +854 -74
- package/lib/client/pageAgent.js +0 -64
- package/lib/mcpBundleImpl/index.js +0 -147
- package/lib/server/agent/actionRunner.js +0 -335
- package/lib/server/agent/actions.js +0 -128
- package/lib/server/agent/codegen.js +0 -111
- package/lib/server/agent/context.js +0 -150
- package/lib/server/agent/expectTools.js +0 -156
- package/lib/server/agent/pageAgent.js +0 -204
- package/lib/server/agent/performTools.js +0 -262
- package/lib/server/agent/tool.js +0 -109
- package/lib/server/dispatchers/pageAgentDispatcher.js +0 -96
- package/lib/server/pageBinding.js +0 -87
- package/lib/utils/isomorphic/oldUtilityScriptSerializers.js +0 -248
- package/lib/vite/recorder/assets/index-CVkBxsGf.js +0 -193
- package/lib/vite/traceViewer/assets/defaultSettingsView-CjfmcdOz.js +0 -266
- package/lib/vite/traceViewer/defaultSettingsView.7ch9cixO.css +0 -1
- package/lib/vite/traceViewer/uiMode.fyrXARf2.js +0 -5
- /package/lib/{server/utils → utils/isomorphic}/imageUtils.js +0 -0
- /package/lib/utils/isomorphic/{traceUtils.js → trace/traceUtils.js} +0 -0
package/lib/client/frame.js
CHANGED
|
@@ -101,7 +101,6 @@ class Frame extends import_channelOwner.ChannelOwner {
|
|
|
101
101
|
}
|
|
102
102
|
async goto(url, options = {}) {
|
|
103
103
|
const waitUntil = verifyLoadState("waitUntil", options.waitUntil === void 0 ? "load" : options.waitUntil);
|
|
104
|
-
this.page().context()._checkUrlAllowed(url);
|
|
105
104
|
return network.Response.fromNullable((await this._channel.goto({ url, ...options, waitUntil, timeout: this._navigationTimeout(options) })).response);
|
|
106
105
|
}
|
|
107
106
|
_setupNavigationWaiter(options) {
|
|
@@ -162,31 +161,19 @@ class Frame extends import_channelOwner.ChannelOwner {
|
|
|
162
161
|
async waitForURL(url, options = {}) {
|
|
163
162
|
if ((0, import_urlMatch.urlMatches)(this._page?.context()._options.baseURL, this.url(), url))
|
|
164
163
|
return await this.waitForLoadState(options.waitUntil, options);
|
|
165
|
-
|
|
166
|
-
await this.waitForNavigation({ url, ...options });
|
|
167
|
-
} catch (error) {
|
|
168
|
-
if ((0, import_urlMatch.urlMatches)(this._page?.context()._options.baseURL, this.url(), url)) {
|
|
169
|
-
await this.waitForLoadState(options.waitUntil, options);
|
|
170
|
-
return;
|
|
171
|
-
}
|
|
172
|
-
throw error;
|
|
173
|
-
}
|
|
164
|
+
await this.waitForNavigation({ url, ...options });
|
|
174
165
|
}
|
|
175
166
|
async frameElement() {
|
|
176
167
|
return import_elementHandle.ElementHandle.from((await this._channel.frameElement()).element);
|
|
177
168
|
}
|
|
178
|
-
async evaluateHandle(pageFunction, arg
|
|
179
|
-
(0, import_jsHandle.assertMaxArguments)(arguments.length,
|
|
180
|
-
const result = await this._channel.evaluateExpressionHandle({ expression: String(pageFunction), isFunction: typeof pageFunction === "function", arg: (0, import_jsHandle.serializeArgument)(arg)
|
|
169
|
+
async evaluateHandle(pageFunction, arg) {
|
|
170
|
+
(0, import_jsHandle.assertMaxArguments)(arguments.length, 2);
|
|
171
|
+
const result = await this._channel.evaluateExpressionHandle({ expression: String(pageFunction), isFunction: typeof pageFunction === "function", arg: (0, import_jsHandle.serializeArgument)(arg) });
|
|
181
172
|
return import_jsHandle.JSHandle.from(result.handle);
|
|
182
173
|
}
|
|
183
|
-
async evaluate(pageFunction, arg
|
|
184
|
-
(0, import_jsHandle.assertMaxArguments)(arguments.length,
|
|
185
|
-
const result = await this._channel.evaluateExpression({ expression: String(pageFunction), isFunction: typeof pageFunction === "function", arg: (0, import_jsHandle.serializeArgument)(arg)
|
|
186
|
-
return (0, import_jsHandle.parseResult)(result.value);
|
|
187
|
-
}
|
|
188
|
-
async _evaluateFunction(functionDeclaration) {
|
|
189
|
-
const result = await this._channel.evaluateExpression({ expression: functionDeclaration, isFunction: true, arg: (0, import_jsHandle.serializeArgument)(void 0) });
|
|
174
|
+
async evaluate(pageFunction, arg) {
|
|
175
|
+
(0, import_jsHandle.assertMaxArguments)(arguments.length, 2);
|
|
176
|
+
const result = await this._channel.evaluateExpression({ expression: String(pageFunction), isFunction: typeof pageFunction === "function", arg: (0, import_jsHandle.serializeArgument)(arg) });
|
|
190
177
|
return (0, import_jsHandle.parseResult)(result.value);
|
|
191
178
|
}
|
|
192
179
|
async _evaluateExposeUtilityScript(pageFunction, arg) {
|
|
@@ -214,9 +201,9 @@ class Frame extends import_channelOwner.ChannelOwner {
|
|
|
214
201
|
const result = await this._channel.evalOnSelector({ selector, expression: String(pageFunction), isFunction: typeof pageFunction === "function", arg: (0, import_jsHandle.serializeArgument)(arg) });
|
|
215
202
|
return (0, import_jsHandle.parseResult)(result.value);
|
|
216
203
|
}
|
|
217
|
-
async $$eval(selector, pageFunction, arg
|
|
218
|
-
(0, import_jsHandle.assertMaxArguments)(arguments.length,
|
|
219
|
-
const result = await this._channel.evalOnSelectorAll({ selector, expression: String(pageFunction), isFunction: typeof pageFunction === "function", arg: (0, import_jsHandle.serializeArgument)(arg)
|
|
204
|
+
async $$eval(selector, pageFunction, arg) {
|
|
205
|
+
(0, import_jsHandle.assertMaxArguments)(arguments.length, 3);
|
|
206
|
+
const result = await this._channel.evalOnSelectorAll({ selector, expression: String(pageFunction), isFunction: typeof pageFunction === "function", arg: (0, import_jsHandle.serializeArgument)(arg) });
|
|
220
207
|
return (0, import_jsHandle.parseResult)(result.value);
|
|
221
208
|
}
|
|
222
209
|
async $$(selector) {
|
package/lib/client/harRouter.js
CHANGED
|
@@ -52,9 +52,21 @@ class HarRouter {
|
|
|
52
52
|
if (response.action === "fulfill") {
|
|
53
53
|
if (response.status === -1)
|
|
54
54
|
return;
|
|
55
|
+
const transformedHeaders = response.headers.reduce((headersMap, { name, value }) => {
|
|
56
|
+
if (name.toLowerCase() !== "set-cookie") {
|
|
57
|
+
headersMap[name] = value;
|
|
58
|
+
} else {
|
|
59
|
+
if (!headersMap["set-cookie"])
|
|
60
|
+
headersMap["set-cookie"] = value;
|
|
61
|
+
else
|
|
62
|
+
headersMap["set-cookie"] += `
|
|
63
|
+
${value}`;
|
|
64
|
+
}
|
|
65
|
+
return headersMap;
|
|
66
|
+
}, {});
|
|
55
67
|
await route.fulfill({
|
|
56
68
|
status: response.status,
|
|
57
|
-
headers:
|
|
69
|
+
headers: transformedHeaders,
|
|
58
70
|
body: response.body
|
|
59
71
|
});
|
|
60
72
|
return;
|
package/lib/client/jsHandle.js
CHANGED
|
@@ -36,16 +36,12 @@ class JSHandle extends import_channelOwner.ChannelOwner {
|
|
|
36
36
|
this._preview = this._initializer.preview;
|
|
37
37
|
this._channel.on("previewUpdated", ({ preview }) => this._preview = preview);
|
|
38
38
|
}
|
|
39
|
-
async evaluate(pageFunction, arg
|
|
40
|
-
const result = await this._channel.evaluateExpression({ expression: String(pageFunction), isFunction: typeof pageFunction === "function", arg: serializeArgument(arg)
|
|
39
|
+
async evaluate(pageFunction, arg) {
|
|
40
|
+
const result = await this._channel.evaluateExpression({ expression: String(pageFunction), isFunction: typeof pageFunction === "function", arg: serializeArgument(arg) });
|
|
41
41
|
return parseResult(result.value);
|
|
42
42
|
}
|
|
43
|
-
async
|
|
44
|
-
const result = await this._channel.
|
|
45
|
-
return parseResult(result.value);
|
|
46
|
-
}
|
|
47
|
-
async evaluateHandle(pageFunction, arg, isolatedContext = true) {
|
|
48
|
-
const result = await this._channel.evaluateExpressionHandle({ expression: String(pageFunction), isFunction: typeof pageFunction === "function", arg: serializeArgument(arg), isolatedContext });
|
|
43
|
+
async evaluateHandle(pageFunction, arg) {
|
|
44
|
+
const result = await this._channel.evaluateExpressionHandle({ expression: String(pageFunction), isFunction: typeof pageFunction === "function", arg: serializeArgument(arg) });
|
|
49
45
|
return JSHandle.from(result.handle);
|
|
50
46
|
}
|
|
51
47
|
async getProperty(propertyName) {
|
package/lib/client/locator.js
CHANGED
|
@@ -24,7 +24,6 @@ __export(locator_exports, {
|
|
|
24
24
|
testIdAttributeName: () => testIdAttributeName
|
|
25
25
|
});
|
|
26
26
|
module.exports = __toCommonJS(locator_exports);
|
|
27
|
-
var import_jsHandle = require("./jsHandle");
|
|
28
27
|
var import_elementHandle = require("./elementHandle");
|
|
29
28
|
var import_locatorGenerators = require("../utils/isomorphic/locatorGenerators");
|
|
30
29
|
var import_locatorUtils = require("../utils/isomorphic/locatorUtils");
|
|
@@ -98,45 +97,14 @@ class Locator {
|
|
|
98
97
|
...options
|
|
99
98
|
});
|
|
100
99
|
}
|
|
101
|
-
async evaluate(pageFunction, arg, options
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
expression: String(pageFunction),
|
|
110
|
-
isFunction: typeof pageFunction === "function",
|
|
111
|
-
arg: (0, import_jsHandle.serializeArgument)(arg),
|
|
112
|
-
isolatedContext
|
|
113
|
-
})).value
|
|
114
|
-
),
|
|
115
|
-
{ title: "Evaluate", timeout: options?.timeout }
|
|
116
|
-
);
|
|
117
|
-
}
|
|
118
|
-
async _evaluateFunction(functionDeclaration, options) {
|
|
119
|
-
return await this._withElement((h) => h._evaluateFunction(functionDeclaration), { title: "Evaluate", timeout: options?.timeout });
|
|
120
|
-
}
|
|
121
|
-
async evaluateAll(pageFunction, arg, isolatedContext = true) {
|
|
122
|
-
return await this._frame.$$eval(this._selector, pageFunction, arg, isolatedContext);
|
|
123
|
-
}
|
|
124
|
-
async evaluateHandle(pageFunction, arg, options, isolatedContext = true) {
|
|
125
|
-
if (typeof options === "boolean") {
|
|
126
|
-
isolatedContext = options;
|
|
127
|
-
options = void 0;
|
|
128
|
-
}
|
|
129
|
-
return await this._withElement(
|
|
130
|
-
async (h) => import_jsHandle.JSHandle.from(
|
|
131
|
-
(await h._channel.evaluateExpressionHandle({
|
|
132
|
-
expression: String(pageFunction),
|
|
133
|
-
isFunction: typeof pageFunction === "function",
|
|
134
|
-
arg: (0, import_jsHandle.serializeArgument)(arg),
|
|
135
|
-
isolatedContext
|
|
136
|
-
})).handle
|
|
137
|
-
),
|
|
138
|
-
{ title: "Evaluate", timeout: options?.timeout }
|
|
139
|
-
);
|
|
100
|
+
async evaluate(pageFunction, arg, options) {
|
|
101
|
+
return await this._withElement((h) => h.evaluate(pageFunction, arg), { title: "Evaluate", timeout: options?.timeout });
|
|
102
|
+
}
|
|
103
|
+
async evaluateAll(pageFunction, arg) {
|
|
104
|
+
return await this._frame.$$eval(this._selector, pageFunction, arg);
|
|
105
|
+
}
|
|
106
|
+
async evaluateHandle(pageFunction, arg, options) {
|
|
107
|
+
return await this._withElement((h) => h.evaluateHandle(pageFunction, arg), { title: "Evaluate", timeout: options?.timeout });
|
|
140
108
|
}
|
|
141
109
|
async fill(value, options = {}) {
|
|
142
110
|
return await this._frame.fill(this._selector, value, { strict: true, ...options });
|
|
@@ -228,8 +196,9 @@ class Locator {
|
|
|
228
196
|
async count(_options) {
|
|
229
197
|
return await this._frame._queryCount(this._selector, _options);
|
|
230
198
|
}
|
|
231
|
-
async
|
|
232
|
-
|
|
199
|
+
async normalize() {
|
|
200
|
+
const { resolvedSelector } = await this._frame._channel.resolveSelector({ selector: this._selector });
|
|
201
|
+
return new Locator(this._frame, resolvedSelector);
|
|
233
202
|
}
|
|
234
203
|
async getAttribute(name, options) {
|
|
235
204
|
return await this._frame.getAttribute(this._selector, name, { strict: true, ...options });
|
|
@@ -271,8 +240,8 @@ class Locator {
|
|
|
271
240
|
const mask = options.mask;
|
|
272
241
|
return await this._withElement((h, timeout) => h.screenshot({ ...options, mask, timeout }), { title: "Screenshot", timeout: options.timeout });
|
|
273
242
|
}
|
|
274
|
-
async ariaSnapshot(options) {
|
|
275
|
-
const result = await this._frame._channel.ariaSnapshot({
|
|
243
|
+
async ariaSnapshot(options = {}) {
|
|
244
|
+
const result = await this._frame._channel.ariaSnapshot({ timeout: this._frame._timeout(options), mode: options.mode, selector: this._selector, depth: options.depth });
|
|
276
245
|
return result.snapshot;
|
|
277
246
|
}
|
|
278
247
|
async scrollIntoViewIfNeeded(options = {}) {
|
package/lib/client/network.js
CHANGED
|
@@ -50,8 +50,8 @@ class Request extends import_channelOwner.ChannelOwner {
|
|
|
50
50
|
this._redirectedFrom = null;
|
|
51
51
|
this._redirectedTo = null;
|
|
52
52
|
this._failureText = null;
|
|
53
|
+
this._response = null;
|
|
53
54
|
this._fallbackOverrides = {};
|
|
54
|
-
this._hasResponse = false;
|
|
55
55
|
this._redirectedFrom = Request.fromNullable(initializer.redirectedFrom);
|
|
56
56
|
if (this._redirectedFrom)
|
|
57
57
|
this._redirectedFrom._redirectedTo = this;
|
|
@@ -67,8 +67,6 @@ class Request extends import_channelOwner.ChannelOwner {
|
|
|
67
67
|
responseStart: -1,
|
|
68
68
|
responseEnd: -1
|
|
69
69
|
};
|
|
70
|
-
this._hasResponse = this._initializer.hasResponse;
|
|
71
|
-
this._channel.on("response", () => this._hasResponse = true);
|
|
72
70
|
}
|
|
73
71
|
static from(request) {
|
|
74
72
|
return request._object;
|
|
@@ -128,11 +126,7 @@ class Request extends import_channelOwner.ChannelOwner {
|
|
|
128
126
|
return await this._actualHeadersPromise;
|
|
129
127
|
}
|
|
130
128
|
async allHeaders() {
|
|
131
|
-
|
|
132
|
-
const page = this._safePage();
|
|
133
|
-
if (page?._closeWasCalled)
|
|
134
|
-
throw new import_errors.TargetClosedError();
|
|
135
|
-
return headers.headers();
|
|
129
|
+
return (await this._actualHeaders()).headers();
|
|
136
130
|
}
|
|
137
131
|
async headersArray() {
|
|
138
132
|
return (await this._actualHeaders()).headersArray();
|
|
@@ -146,6 +140,9 @@ class Request extends import_channelOwner.ChannelOwner {
|
|
|
146
140
|
async _internalResponse() {
|
|
147
141
|
return Response.fromNullable((await this._channel.response()).response);
|
|
148
142
|
}
|
|
143
|
+
existingResponse() {
|
|
144
|
+
return this._response;
|
|
145
|
+
}
|
|
149
146
|
frame() {
|
|
150
147
|
if (!this._initializer.frame) {
|
|
151
148
|
(0, import_assert.assert)(this.serviceWorker());
|
|
@@ -469,10 +466,9 @@ class WebSocketRouteHandler {
|
|
|
469
466
|
const patterns = [];
|
|
470
467
|
let all = false;
|
|
471
468
|
for (const handler of handlers) {
|
|
472
|
-
|
|
473
|
-
|
|
474
|
-
|
|
475
|
-
patterns.push({ regexSource: handler.url.source, regexFlags: handler.url.flags });
|
|
469
|
+
const serialized = (0, import_urlMatch.serializeURLMatch)(handler.url);
|
|
470
|
+
if (serialized)
|
|
471
|
+
patterns.push(serialized);
|
|
476
472
|
else
|
|
477
473
|
all = true;
|
|
478
474
|
}
|
|
@@ -495,6 +491,7 @@ class Response extends import_channelOwner.ChannelOwner {
|
|
|
495
491
|
this._finishedPromise = new import_manualPromise.ManualPromise();
|
|
496
492
|
this._provisionalHeaders = new RawHeaders(initializer.headers);
|
|
497
493
|
this._request = Request.from(this._initializer.request);
|
|
494
|
+
this._request._response = this;
|
|
498
495
|
Object.assign(this._request._timing, this._initializer.timing);
|
|
499
496
|
}
|
|
500
497
|
static from(response) {
|
|
@@ -570,6 +567,9 @@ class Response extends import_channelOwner.ChannelOwner {
|
|
|
570
567
|
async securityDetails() {
|
|
571
568
|
return (await this._channel.securityDetails()).value || null;
|
|
572
569
|
}
|
|
570
|
+
async httpVersion() {
|
|
571
|
+
return (await this._channel.httpVersion()).value;
|
|
572
|
+
}
|
|
573
573
|
}
|
|
574
574
|
class WebSocket extends import_channelOwner.ChannelOwner {
|
|
575
575
|
static from(webSocket) {
|
|
@@ -642,10 +642,9 @@ class RouteHandler {
|
|
|
642
642
|
const patterns = [];
|
|
643
643
|
let all = false;
|
|
644
644
|
for (const handler of handlers) {
|
|
645
|
-
|
|
646
|
-
|
|
647
|
-
|
|
648
|
-
patterns.push({ regexSource: handler.url.source, regexFlags: handler.url.flags });
|
|
645
|
+
const serialized = (0, import_urlMatch.serializeURLMatch)(handler.url);
|
|
646
|
+
if (serialized)
|
|
647
|
+
patterns.push(serialized);
|
|
649
648
|
else
|
|
650
649
|
all = true;
|
|
651
650
|
}
|
package/lib/client/page.js
CHANGED
|
@@ -26,6 +26,7 @@ var import_artifact = require("./artifact");
|
|
|
26
26
|
var import_channelOwner = require("./channelOwner");
|
|
27
27
|
var import_clientHelper = require("./clientHelper");
|
|
28
28
|
var import_coverage = require("./coverage");
|
|
29
|
+
var import_disposable = require("./disposable");
|
|
29
30
|
var import_download = require("./download");
|
|
30
31
|
var import_elementHandle = require("./elementHandle");
|
|
31
32
|
var import_errors = require("./errors");
|
|
@@ -37,6 +38,7 @@ var import_input = require("./input");
|
|
|
37
38
|
var import_jsHandle = require("./jsHandle");
|
|
38
39
|
var import_network = require("./network");
|
|
39
40
|
var import_video = require("./video");
|
|
41
|
+
var import_screencast = require("./screencast");
|
|
40
42
|
var import_waiter = require("./waiter");
|
|
41
43
|
var import_worker = require("./worker");
|
|
42
44
|
var import_timeoutSettings = require("./timeoutSettings");
|
|
@@ -48,7 +50,6 @@ var import_urlMatch = require("../utils/isomorphic/urlMatch");
|
|
|
48
50
|
var import_manualPromise = require("../utils/isomorphic/manualPromise");
|
|
49
51
|
var import_rtti = require("../utils/isomorphic/rtti");
|
|
50
52
|
var import_consoleMessage = require("./consoleMessage");
|
|
51
|
-
var import_pageAgent = require("./pageAgent");
|
|
52
53
|
class Page extends import_channelOwner.ChannelOwner {
|
|
53
54
|
constructor(parent, type, guid, initializer) {
|
|
54
55
|
super(parent, type, guid, initializer);
|
|
@@ -59,11 +60,9 @@ class Page extends import_channelOwner.ChannelOwner {
|
|
|
59
60
|
this._routes = [];
|
|
60
61
|
this._webSocketRoutes = [];
|
|
61
62
|
this._bindings = /* @__PURE__ */ new Map();
|
|
62
|
-
this._video = null;
|
|
63
63
|
this._closeWasCalled = false;
|
|
64
64
|
this._harRouters = [];
|
|
65
65
|
this._locatorHandlers = /* @__PURE__ */ new Map();
|
|
66
|
-
this.routeInjecting = false;
|
|
67
66
|
this._instrumentation.onPage(this);
|
|
68
67
|
this._browserContext = parent;
|
|
69
68
|
this._timeoutSettings = new import_timeoutSettings.TimeoutSettings(this._platform, this._browserContext._timeoutSettings);
|
|
@@ -78,6 +77,8 @@ class Page extends import_channelOwner.ChannelOwner {
|
|
|
78
77
|
this._viewportSize = initializer.viewportSize;
|
|
79
78
|
this._closed = initializer.isClosed;
|
|
80
79
|
this._opener = Page.fromNullable(initializer.opener);
|
|
80
|
+
this._video = new import_video.Video(this, this._connection, initializer.video ? import_artifact.Artifact.from(initializer.video) : void 0);
|
|
81
|
+
this.screencast = new import_screencast.Screencast(this);
|
|
81
82
|
this._channel.on("bindingCall", ({ binding }) => this._onBinding(BindingCall.from(binding)));
|
|
82
83
|
this._channel.on("close", () => this._onClose());
|
|
83
84
|
this._channel.on("crash", () => this._onCrash());
|
|
@@ -91,10 +92,6 @@ class Page extends import_channelOwner.ChannelOwner {
|
|
|
91
92
|
this._channel.on("locatorHandlerTriggered", ({ uid }) => this._onLocatorHandlerTriggered(uid));
|
|
92
93
|
this._channel.on("route", ({ route }) => this._onRoute(import_network.Route.from(route)));
|
|
93
94
|
this._channel.on("webSocketRoute", ({ webSocketRoute }) => this._onWebSocketRoute(import_network.WebSocketRoute.from(webSocketRoute)));
|
|
94
|
-
this._channel.on("video", ({ artifact }) => {
|
|
95
|
-
const artifactObject = import_artifact.Artifact.from(artifact);
|
|
96
|
-
this._forceVideo()._artifactReady(artifactObject);
|
|
97
|
-
});
|
|
98
95
|
this._channel.on("viewportSizeChanged", ({ viewportSize }) => this._viewportSize = viewportSize);
|
|
99
96
|
this._channel.on("webSocket", ({ webSocket }) => this.emit(import_events.Events.Page.WebSocket, import_network.WebSocket.from(webSocket)));
|
|
100
97
|
this._channel.on("worker", ({ worker }) => this._onWorker(import_worker.Worker.from(worker)));
|
|
@@ -135,7 +132,7 @@ class Page extends import_channelOwner.ChannelOwner {
|
|
|
135
132
|
route._context = this.context();
|
|
136
133
|
const routeHandlers = this._routes.slice();
|
|
137
134
|
for (const routeHandler of routeHandlers) {
|
|
138
|
-
if (this._closeWasCalled || this._browserContext.
|
|
135
|
+
if (this._closeWasCalled || this._browserContext.isClosed())
|
|
139
136
|
return;
|
|
140
137
|
if (!routeHandler.matches(route.request().url()))
|
|
141
138
|
continue;
|
|
@@ -212,15 +209,17 @@ class Page extends import_channelOwner.ChannelOwner {
|
|
|
212
209
|
setDefaultTimeout(timeout) {
|
|
213
210
|
this._timeoutSettings.setDefaultTimeout(timeout);
|
|
214
211
|
}
|
|
215
|
-
_forceVideo() {
|
|
216
|
-
if (!this._video)
|
|
217
|
-
this._video = new import_video.Video(this, this._connection);
|
|
218
|
-
return this._video;
|
|
219
|
-
}
|
|
220
212
|
video() {
|
|
221
213
|
if (!this._browserContext._options.recordVideo)
|
|
222
214
|
return null;
|
|
223
|
-
return this.
|
|
215
|
+
return this._video;
|
|
216
|
+
}
|
|
217
|
+
async pickLocator() {
|
|
218
|
+
const { selector } = await this._channel.pickLocator({});
|
|
219
|
+
return this.locator(selector);
|
|
220
|
+
}
|
|
221
|
+
async cancelPickLocator() {
|
|
222
|
+
await this._channel.cancelPickLocator({});
|
|
224
223
|
}
|
|
225
224
|
async $(selector, options) {
|
|
226
225
|
return await this._mainFrame.$(selector, options);
|
|
@@ -231,9 +230,9 @@ class Page extends import_channelOwner.ChannelOwner {
|
|
|
231
230
|
async dispatchEvent(selector, type, eventInit, options) {
|
|
232
231
|
return await this._mainFrame.dispatchEvent(selector, type, eventInit, options);
|
|
233
232
|
}
|
|
234
|
-
async evaluateHandle(pageFunction, arg
|
|
235
|
-
(0, import_jsHandle.assertMaxArguments)(arguments.length,
|
|
236
|
-
return await this._mainFrame.evaluateHandle(pageFunction, arg
|
|
233
|
+
async evaluateHandle(pageFunction, arg) {
|
|
234
|
+
(0, import_jsHandle.assertMaxArguments)(arguments.length, 2);
|
|
235
|
+
return await this._mainFrame.evaluateHandle(pageFunction, arg);
|
|
237
236
|
}
|
|
238
237
|
async $eval(selector, pageFunction, arg) {
|
|
239
238
|
(0, import_jsHandle.assertMaxArguments)(arguments.length, 3);
|
|
@@ -253,15 +252,15 @@ class Page extends import_channelOwner.ChannelOwner {
|
|
|
253
252
|
return await this._mainFrame.addStyleTag(options);
|
|
254
253
|
}
|
|
255
254
|
async exposeFunction(name, callback) {
|
|
256
|
-
await this.
|
|
257
|
-
await this._channel.exposeBinding({ name });
|
|
255
|
+
const result = await this._channel.exposeBinding({ name });
|
|
258
256
|
const binding = (source, ...args) => callback(...args);
|
|
259
257
|
this._bindings.set(name, binding);
|
|
258
|
+
return import_disposable.DisposableObject.from(result.disposable);
|
|
260
259
|
}
|
|
261
260
|
async exposeBinding(name, callback, options = {}) {
|
|
262
|
-
await this.
|
|
263
|
-
await this._channel.exposeBinding({ name, needsHandle: options.handle });
|
|
261
|
+
const result = await this._channel.exposeBinding({ name, needsHandle: options.handle });
|
|
264
262
|
this._bindings.set(name, callback);
|
|
263
|
+
return import_disposable.DisposableObject.from(result.disposable);
|
|
265
264
|
}
|
|
266
265
|
async setExtraHTTPHeaders(headers) {
|
|
267
266
|
(0, import_network.validateHeaders)(headers);
|
|
@@ -396,21 +395,18 @@ class Page extends import_channelOwner.ChannelOwner {
|
|
|
396
395
|
viewportSize() {
|
|
397
396
|
return this._viewportSize || null;
|
|
398
397
|
}
|
|
399
|
-
async evaluate(pageFunction, arg
|
|
400
|
-
(0, import_jsHandle.assertMaxArguments)(arguments.length,
|
|
401
|
-
return await this._mainFrame.evaluate(pageFunction, arg
|
|
402
|
-
}
|
|
403
|
-
async _evaluateFunction(functionDeclaration) {
|
|
404
|
-
return this._mainFrame._evaluateFunction(functionDeclaration);
|
|
398
|
+
async evaluate(pageFunction, arg) {
|
|
399
|
+
(0, import_jsHandle.assertMaxArguments)(arguments.length, 2);
|
|
400
|
+
return await this._mainFrame.evaluate(pageFunction, arg);
|
|
405
401
|
}
|
|
406
402
|
async addInitScript(script, arg) {
|
|
407
|
-
await this.installInjectRoute();
|
|
408
403
|
const source = await (0, import_clientHelper.evaluationScript)(this._platform, script, arg);
|
|
409
|
-
await this._channel.addInitScript({ source });
|
|
404
|
+
return import_disposable.DisposableObject.from((await this._channel.addInitScript({ source })).disposable);
|
|
410
405
|
}
|
|
411
406
|
async route(url, handler, options = {}) {
|
|
412
407
|
this._routes.unshift(new import_network.RouteHandler(this._platform, this._browserContext._options.baseURL, url, handler, options.times));
|
|
413
408
|
await this._updateInterceptionPatterns({ title: "Route requests" });
|
|
409
|
+
return new import_disposable.DisposableStub(() => this.unroute(url, handler));
|
|
414
410
|
}
|
|
415
411
|
async routeFromHAR(har, options = {}) {
|
|
416
412
|
const localUtils = this._connection.localUtils();
|
|
@@ -539,12 +535,18 @@ class Page extends import_channelOwner.ChannelOwner {
|
|
|
539
535
|
async fill(selector, value, options) {
|
|
540
536
|
return await this._mainFrame.fill(selector, value, options);
|
|
541
537
|
}
|
|
542
|
-
async
|
|
543
|
-
|
|
538
|
+
async clearConsoleMessages() {
|
|
539
|
+
await this._channel.clearConsoleMessages();
|
|
540
|
+
}
|
|
541
|
+
async consoleMessages(options) {
|
|
542
|
+
const { messages } = await this._channel.consoleMessages({ filter: options?.filter });
|
|
544
543
|
return messages.map((message) => new import_consoleMessage.ConsoleMessage(this._platform, message, this, null));
|
|
545
544
|
}
|
|
546
|
-
async
|
|
547
|
-
|
|
545
|
+
async clearPageErrors() {
|
|
546
|
+
await this._channel.clearPageErrors();
|
|
547
|
+
}
|
|
548
|
+
async pageErrors(options) {
|
|
549
|
+
const { errors } = await this._channel.pageErrors({ filter: options?.filter });
|
|
548
550
|
return errors.map((error) => (0, import_errors.parseError)(error));
|
|
549
551
|
}
|
|
550
552
|
locator(selector, options) {
|
|
@@ -680,48 +682,12 @@ class Page extends import_channelOwner.ChannelOwner {
|
|
|
680
682
|
}
|
|
681
683
|
return result.pdf;
|
|
682
684
|
}
|
|
683
|
-
|
|
684
|
-
|
|
685
|
-
|
|
686
|
-
|
|
687
|
-
|
|
688
|
-
|
|
689
|
-
apiTimeout: options.provider?.apiTimeout,
|
|
690
|
-
apiCacheFile: options.provider?._apiCacheFile,
|
|
691
|
-
doNotRenderActive: options._doNotRenderActive,
|
|
692
|
-
model: options.provider?.model,
|
|
693
|
-
cacheFile: options.cache?.cacheFile,
|
|
694
|
-
cacheOutFile: options.cache?.cacheOutFile,
|
|
695
|
-
maxTokens: options.limits?.maxTokens,
|
|
696
|
-
maxActions: options.limits?.maxActions,
|
|
697
|
-
maxActionRetries: options.limits?.maxActionRetries,
|
|
698
|
-
// @ts-expect-error runAgents is hidden
|
|
699
|
-
secrets: options.secrets ? Object.entries(options.secrets).map(([name, value]) => ({ name, value })) : void 0,
|
|
700
|
-
systemPrompt: options.systemPrompt
|
|
701
|
-
};
|
|
702
|
-
const { agent } = await this._channel.agent(params);
|
|
703
|
-
const pageAgent = import_pageAgent.PageAgent.from(agent);
|
|
704
|
-
pageAgent._expectTimeout = options?.expect?.timeout;
|
|
705
|
-
return pageAgent;
|
|
706
|
-
}
|
|
707
|
-
async _snapshotForAI(options = {}) {
|
|
708
|
-
return await this._channel.snapshotForAI({ timeout: this._timeoutSettings.timeout(options), track: options.track });
|
|
709
|
-
}
|
|
710
|
-
async installInjectRoute() {
|
|
711
|
-
if (this.routeInjecting || this.context().routeInjecting) return;
|
|
712
|
-
await this.route("**/*", async (route) => {
|
|
713
|
-
try {
|
|
714
|
-
if (route.request().resourceType() === "document" && route.request().url().startsWith("http")) {
|
|
715
|
-
const protocol = route.request().url().split(":")[0];
|
|
716
|
-
await route.fallback({ url: protocol + "://patchright-init-script-inject.internal/" });
|
|
717
|
-
} else {
|
|
718
|
-
await route.fallback();
|
|
719
|
-
}
|
|
720
|
-
} catch (error) {
|
|
721
|
-
await route.fallback();
|
|
722
|
-
}
|
|
723
|
-
});
|
|
724
|
-
this.routeInjecting = true;
|
|
685
|
+
async ariaSnapshot(options = {}) {
|
|
686
|
+
const result = await this.mainFrame()._channel.ariaSnapshot({ timeout: this._timeoutSettings.timeout(options), track: options._track, mode: options.mode, depth: options.depth });
|
|
687
|
+
return result.snapshot;
|
|
688
|
+
}
|
|
689
|
+
async _setDockTile(image) {
|
|
690
|
+
await this._channel.setDockTile({ image });
|
|
725
691
|
}
|
|
726
692
|
}
|
|
727
693
|
class BindingCall extends import_channelOwner.ChannelOwner {
|
package/lib/client/platform.js
CHANGED
|
@@ -66,9 +66,6 @@ const emptyPlatform = {
|
|
|
66
66
|
streamWritable: (channel) => {
|
|
67
67
|
throw new Error("Streams are not available");
|
|
68
68
|
},
|
|
69
|
-
zodToJsonSchema: (schema) => {
|
|
70
|
-
throw new Error("Zod is not available");
|
|
71
|
-
},
|
|
72
69
|
zones: { empty: noopZone, current: () => noopZone }
|
|
73
70
|
};
|
|
74
71
|
// Annotate the CommonJS export names for ESM import in node:
|
|
@@ -0,0 +1,88 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __export = (target, all) => {
|
|
7
|
+
for (var name in all)
|
|
8
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
+
};
|
|
10
|
+
var __copyProps = (to, from, except, desc) => {
|
|
11
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
+
for (let key of __getOwnPropNames(from))
|
|
13
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
+
}
|
|
16
|
+
return to;
|
|
17
|
+
};
|
|
18
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
+
var screencast_exports = {};
|
|
20
|
+
__export(screencast_exports, {
|
|
21
|
+
Screencast: () => Screencast
|
|
22
|
+
});
|
|
23
|
+
module.exports = __toCommonJS(screencast_exports);
|
|
24
|
+
var import_artifact = require("./artifact");
|
|
25
|
+
var import_disposable = require("./disposable");
|
|
26
|
+
class Screencast {
|
|
27
|
+
constructor(page) {
|
|
28
|
+
this._started = false;
|
|
29
|
+
this._onFrame = null;
|
|
30
|
+
this._page = page;
|
|
31
|
+
this._page._channel.on("screencastFrame", ({ data }) => {
|
|
32
|
+
void this._onFrame?.({ data });
|
|
33
|
+
});
|
|
34
|
+
}
|
|
35
|
+
async start(options = {}) {
|
|
36
|
+
if (this._started)
|
|
37
|
+
throw new Error("Screencast is already started");
|
|
38
|
+
this._started = true;
|
|
39
|
+
if (options.onFrame)
|
|
40
|
+
this._onFrame = options.onFrame;
|
|
41
|
+
const result = await this._page._channel.screencastStart({
|
|
42
|
+
size: options.size,
|
|
43
|
+
quality: options.quality,
|
|
44
|
+
sendFrames: !!options.onFrame,
|
|
45
|
+
record: !!options.path
|
|
46
|
+
});
|
|
47
|
+
if (result.artifact) {
|
|
48
|
+
this._artifact = import_artifact.Artifact.from(result.artifact);
|
|
49
|
+
this._savePath = options.path;
|
|
50
|
+
}
|
|
51
|
+
return new import_disposable.DisposableStub(() => this.stop());
|
|
52
|
+
}
|
|
53
|
+
async stop() {
|
|
54
|
+
await this._page._wrapApiCall(async () => {
|
|
55
|
+
this._started = false;
|
|
56
|
+
this._onFrame = null;
|
|
57
|
+
await this._page._channel.screencastStop();
|
|
58
|
+
if (this._savePath)
|
|
59
|
+
await this._artifact?.saveAs(this._savePath);
|
|
60
|
+
this._artifact = void 0;
|
|
61
|
+
this._savePath = void 0;
|
|
62
|
+
});
|
|
63
|
+
}
|
|
64
|
+
async showActions(options) {
|
|
65
|
+
await this._page._channel.screencastShowActions({ duration: options?.duration, position: options?.position, fontSize: options?.fontSize });
|
|
66
|
+
return new import_disposable.DisposableStub(() => this._page._channel.screencastHideActions());
|
|
67
|
+
}
|
|
68
|
+
async hideActions() {
|
|
69
|
+
await this._page._channel.screencastHideActions();
|
|
70
|
+
}
|
|
71
|
+
async showOverlay(html, options) {
|
|
72
|
+
const { id } = await this._page._channel.screencastShowOverlay({ html, duration: options?.duration });
|
|
73
|
+
return new import_disposable.DisposableStub(() => this._page._channel.screencastRemoveOverlay({ id }));
|
|
74
|
+
}
|
|
75
|
+
async showChapter(title, options) {
|
|
76
|
+
await this._page._channel.screencastChapter({ title, ...options });
|
|
77
|
+
}
|
|
78
|
+
async showOverlays() {
|
|
79
|
+
await this._page._channel.screencastSetOverlayVisible({ visible: true });
|
|
80
|
+
}
|
|
81
|
+
async hideOverlays() {
|
|
82
|
+
await this._page._channel.screencastSetOverlayVisible({ visible: false });
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
86
|
+
0 && (module.exports = {
|
|
87
|
+
Screencast
|
|
88
|
+
});
|
package/lib/client/selectors.js
CHANGED
|
@@ -41,9 +41,11 @@ class Selectors {
|
|
|
41
41
|
setTestIdAttribute(attributeName) {
|
|
42
42
|
this._testIdAttributeName = attributeName;
|
|
43
43
|
(0, import_locator.setTestIdAttribute)(attributeName);
|
|
44
|
-
for (const context of this._contextsForSelectors)
|
|
44
|
+
for (const context of this._contextsForSelectors) {
|
|
45
|
+
context._options.testIdAttributeName = attributeName;
|
|
45
46
|
context._channel.setTestIdAttributeName({ testIdAttributeName: attributeName }).catch(() => {
|
|
46
47
|
});
|
|
48
|
+
}
|
|
47
49
|
}
|
|
48
50
|
_withSelectorOptions(options) {
|
|
49
51
|
return { ...options, selectorEngines: this._selectorEngines, testIdAttributeName: this._testIdAttributeName };
|