chrome remote interface client.Network is undefined

538 views Asked by At

I have the following code example from the CDP page

https://github.com/cyrus-and/chrome-remote-interface/wiki/Async-await-example

const CDP = require('chrome-remote-interface');

async function example() {
    let client;
    try {
        // connect to endpoint
        client = await CDP();
        // extract domains
     
        const {Network, Page} = client;
        // setup handlers
        Network.requestWillBeSent((params) => {
            console.log(params.request.url);
        });
        // enable events then start!
        await Network.enable();
        await Page.enable();
        await Page.navigate({url: 'https://github.com'});
        await Page.loadEventFired();
    } catch (err) {
        console.error(err);
    } finally {
        if (client) {
            await client.close();
        }
    }
}

example();

but when i run it with: node --inspect=9222 getLogs.js

it throws an error: TypeError: Cannot read property 'requestWillBeSent' of undefined

I am completely new to this, so I don't know what else should I do, Network and Page they both are undefined.

1

There are 1 answers

0
Anush B M On

Try running node getLogs.jsinstead...

Found a similar issue on https://github.com/cyrus-and/chrome-remote-interface/issues/407