Page
与所检查页面相关的操作和事件属于页面域。
EN
Actions and events related to the inspected page belong to the page domain.
✅️️ Methods
🔨Page.addScriptToEvaluateOnNewDocument
在创建每个帧时(在加载帧的脚本之前)评估给定的脚本。
EN
Evaluates given script in every frame upon creation (before loading frame's scripts).
| 参数 | 必填 | 标记 | 类型 | 描述 | 原文 |
|---|---|---|---|---|---|
| source | ✔️ | string | |||
| worldName | 🧪 | string | 如果指定,将创建一个具有给定名称的独立世界,并在其中执行给定的脚本。当相应事件被触发时,此世界名称将用作ExecutionContextDescription::name。 | ENIf specified, creates an isolated world with the given name and evaluates given script in it. This world name will be used as the ExecutionContextDescription::name when the corresponding event is emitted. | |
| includeCommandLineAPI | 🧪 | boolean | 指定命令行API是否应对脚本可用,默认为false。 | ENSpecifies whether command line API should be available to the script, defaults to false. | |
| runImmediately | 🧪 | boolean | 如果为真,则立即在现有的执行上下文或世界中运行脚本。默认值:false。 | ENIf true, runs the script immediately on existing execution contexts or worlds. Default: false. |
| 返回对象 | 类型 | 描述 | 原文 |
|---|---|---|---|
| identifier | ScriptIdentifier | 已添加脚本的标识符。 | ENIdentifier of the added script. |
🔨Page.bringToFront
将页面置于前台(激活标签页)。
EN
Brings page to front (activates tab).
🔨Page.captureScreenshot
捕获页面截图。
EN
Capture page screenshot.
| 参数 | 必填 | 标记 | 类型 | 描述 | 原文 |
|---|---|---|---|---|---|
| format | string | 图像压缩格式(默认为 png)。 允许的值: jpeg、png、webp | ENImage compression format (defaults to png).Allowed Values: jpeg, png, webp | ||
| quality | integer | 压缩质量范围从[0..100](仅限jpeg格式)。 | ENCompression quality from range [0..100] (jpeg only). | ||
| clip | Viewport | 仅捕获给定区域的屏幕截图。 | ENCapture the screenshot of a given region only. | ||
| fromSurface | 🧪 | boolean | 从表面而非视图捕获屏幕截图。默认为 true。 | ENCapture the screenshot from the surface, rather than the view. Defaults to true. | |
| captureBeyondViewport | 🧪 | boolean | 捕获超出视口的屏幕截图。默认为 false。 | ENCapture the screenshot beyond the viewport. Defaults to false. | |
| optimizeForSpeed | 🧪 | boolean | 优化图像编码以提升速度,而非压缩文件大小(默认值为 false) | ENOptimize image encoding for speed, not for resulting size (defaults to false) |
| 返回对象 | 类型 | 描述 | 原文 |
|---|---|---|---|
| data | string | Base64编码的图像数据。(在通过JSON传递时编码为base64字符串) | ENBase64-encoded image data. (Encoded as a base64 string when passed over JSON) |
🔨Page.close
尝试关闭页面,运行其beforeunload钩子(如果有的话)。
EN
Tries to close page, running its beforeunload hooks, if any.
🔨Page.createIsolatedWorld
为给定的框架创建一个隔离的世界。
EN
Creates an isolated world for the given frame.
| 参数 | 必填 | 标记 | 类型 | 描述 | 原文 |
|---|---|---|---|---|---|
| frameId | ✔️ | FrameId | 在其中创建隔离世界的框架的Id。 | ENId of the frame in which the isolated world should be created. | |
| worldName | string | 一个可选名称,在''执行上下文''中报告。 | ENAn optional name which is reported in the Execution Context. | ||
| grantUniveralAccess | boolean | 是否应向隔离世界授予通用访问权限。这是一个强大的选项,请谨慎使用。 | ENWhether or not universal access should be granted to the isolated world. This is a powerful option, use with caution. |
| 返回对象 | 类型 | 描述 | 原文 |
|---|---|---|---|
| executionContextId | Runtime.ExecutionContextId | 隔离世界的执行上下文。 | ENExecution context of the isolated world. |
🔨Page.disable
禁用页面域通知。
EN
Disables page domain notifications.
🔨Page.enable
启用页面域通知。
EN
Enables page domain notifications.
| 参数 | 必填 | 标记 | 类型 | 描述 | 原文 |
|---|---|---|---|---|---|
| enableFileChooserOpenedEvent | 🧪 | boolean | 如果为真,无论Page.setInterceptFileChooserDialog命令设置的状态如何,都会触发Page.fileChooserOpened事件(默认值:false)。 | ENIf true, thePage.fileChooserOpened event will be emitted regardless of the state set by Page.setInterceptFileChooserDialog command (default: false). |