调试器
用于控制 Playwright 调试器的 API。调试器允许暂停脚本执行并检查页面。通过 browser_context.debugger 获取调试器实例。
🌐 API for controlling the Playwright debugger. The debugger allows pausing script execution and inspecting the page. Obtain the debugger instance via browser_context.debugger.
方法
🌐 Methods
next
Added in: v1.59恢复脚本执行,并在下一个操作前再次暂停。如果调试器未暂停,则抛出异常。
🌐 Resumes script execution and pauses again before the next action. Throws if the debugger is not paused.
用法
debugger.next()
返回
request_pause
Added in: v1.59配置调试器以在执行下一操作之前暂停。
🌐 Configures the debugger to pause before the next action is executed.
如果调试器已经暂停,则会抛出异常。暂停时使用 debugger.next() 或 debugger.run_to() 来执行单步操作。
🌐 Throws if the debugger is already paused. Use debugger.next() or debugger.run_to() to step while paused.
请注意,page.pause() 等同于一个 "debugger" 语句——它会立即在调用位置暂停执行。相反,debugger.request_pause() 等同于 "在下一语句暂停"——它会配置调试器在下一个操作执行前暂停。
🌐 Note that page.pause() is equivalent to a "debugger" statement — it pauses execution at the call site immediately. On the contrary, debugger.request_pause() is equivalent to "pause on next statement" — it configures the debugger to pause before the next action is executed.
用法
debugger.request_pause()
返回
resume
Added in: v1.59恢复脚本执行。如果调试器未暂停,则抛出异常。
🌐 Resumes script execution. Throws if the debugger is not paused.
用法
debugger.resume()
返回
run_to
Added in: v1.59恢复脚本执行,并在操作来自给定源位置时暂停。如果调试器未暂停,则抛出异常。
🌐 Resumes script execution and pauses when an action originates from the given source location. Throws if the debugger is not paused.
用法
debugger.run_to(location)
参数
返回
属性
🌐 Properties
paused_details
Added in: v1.59返回有关当前已暂停通话的详细信息。如果调试器未暂停,则返回 null。
🌐 Returns details about the currently paused call. Returns null if the debugger is not paused.
用法
debugger.paused_details
返回
事件
🌐 Events
on("pausedstatechanged")
Added in: v1.59当调试器暂停或恢复时发出。
🌐 Emitted when the debugger pauses or resumes.
用法
debugger.on("pausedstatechanged", handler)