CDPSession クラス
CDPSession
インスタンスは、生の Chrome Devtools Protocol の処理に使用されます。
シグネチャ:
export declare abstract class CDPSession extends EventEmitter<CDPSessionEvents>
拡張: EventEmitter<CDPSessionEvents>
注釈
Protocol メソッドは CDPSession.send() メソッドで呼び出すことができ、Protocol イベントは CDPSession.on
メソッドでサブスクライブできます。
便利なリンク: DevTools Protocol ビューア と DevTools Protocol 入門。
このクラスのコンストラクターは内部としてマークされています。サードパーティのコードはコンストラクターを直接呼び出したり、CDPSession
クラスを拡張するサブクラスを作成しないでください。
例
const client = await page.target().createCDPSession();
await client.send('Animation.enable');
client.on('Animation.animationCreated', () =>
console.log('Animation created!')
);
const response = await client.send('Animation.getPlaybackRate');
console.log('playback rate is ' + response.playbackRate);
await client.send('Animation.setPlaybackRate', {
playbackRate: response.playbackRate / 2,
});
メソッド
メソッド | 修飾子 | 説明 |
---|---|---|
connection() | ||
detach() | CDPセッションをターゲットからデタッチします。デタッチすると、cdpSessionオブジェクトはイベントを発生させなくなり、メッセージを送信するために使用できなくなります。 | |
id() | セッションのIDを返します。 | |
send(method, params, options) |