Target 类
🌐 Target class
Target 表示一个 CDP 目标。在 CDP 中,目标是可以调试的东西,例如一个框架、一个页面或一个 worker。
🌐 Target represents a CDP target. In CDP a target is something that can be debugged, such as a frame, a page or a worker.
语法
🌐 Signature
export declare abstract class Target
附注
🌐 Remarks
这个类的构造函数被标记为内部。第三方代码不应直接调用构造函数或创建继承 Target 类的子类。
🌐 The constructor for this class is marked as internal. Third-party code should not call the constructor directly or create subclasses that extend the Target class.
方法
🌐 Methods
方法 🌐 Method | 修饰符 🌐 Modifiers | 描述 🌐 Description |
|---|---|---|
| asPage() | 强制为任何类型的目标创建页面。如果你想将类型为 🌐 Forcefully creates a page for a target of any type. It is useful if you want to handle a CDP target of type | |
| browser() | 获取目标所属的浏览器。 🌐 Get the browser the target belongs to. | |
| browserContext() | 获取目标所属的浏览器上下文。 🌐 Get the browser context the target belongs to. | |
| createCDPSession() | 创建附加到目标的 Chrome Devtools 协议会话。 🌐 Creates a Chrome Devtools Protocol session attached to the target. | |
| opener() | 获取打开此目标的目标。顶层目标返回 🌐 Get the target that opened this target. Top-level targets return | |
| page() | 如果目标类型不是 🌐 If the target is not of type | |
| type() | 确定这是什么类型的目标。 🌐 Identifies what kind of target this is. 附注 有关后台页面的更多信息,请参阅 文档。 🌐 See docs for more info about background pages. | |
| url() | ||
| worker() | 如果目标不是 🌐 If the target is not of type |