Tracing is already started – chrome debugging protocol and

I’m trying to collect complete timelines using the chrome remote interface and tracing. The code that
I have navigates to a page using webdriver IO and the chromedriver. Once the webdriver session has started, I can obtain the port for the chrome debugger protocol from the file DevToolsActivePort and connect to establish a connection to chrome debugging protocol (CDP) and start tracing.

The code that I’m using is capable of connecting, but once I try to start tracing i get an error that states: “Tracing is already started”. (Even though is the first time i start tracing) Debugging further, this seems to be coming from chrome, the code fails in these lines:

I’ve tried stopping the tracing before starting it, but it fails because i have not started tracing =|

I have not started tracing anywhere else, only in the code shown below. I have another method on where I’ll end Tracing and write the events to a file. I make CDP client part of the webdriver io client.

const options = {
port: webdriverIOClient.remoteDebuggingPort,
webSocketDebuggerUrl: ws://localhost:${webdriverIOClient.remoteDebuggingPort}${webdriverIOClient.webSocketDebuggerUrl}

    const getCDP = async () => { 
      if (webdriverIOClient.cdpClient) {
        return webdriverIOClient.cdpClient;
      let cdpClient = null; 

      await CDP(options, async (browser) => {
        try { 
          const events = []; 
          const { Page, Tracing } = browser;
          Tracing.dataCollected(({ value }) => {
          cdpClient = browser; 
 = events;
          await Tracing.start({
             bufferUsageReportingInterval: 500,
             options: "sampling-frequency=10000",
             transferMode: "ReportEvents"
           webdriverIOClient.cdpClient = browser;   
        } catch (error) {
          console.log(`we hit an error trying to get the CDP `, error)
      return cdpClient; 

Chrome DevTools – how do you close an alert box?

I am using Chrome DevToools through the Chrome remote interface.

One thing I don’t see a way to do here is to close an alert box. Is this possible?

Chrome remote debugging Basic Authentication

How can I do a basic authentication via chrome remote debugging?

That is I have a chrome running in remote debug like this

chrome.exe –remote-debugging-port=9222

then I use WebSocket4Net to comunicate with chrome. I would like to automate the basic authentication, by passing user and password in the json. I know that I could do simply

https://username:[email protected]/

but I would like also to try to pass them in the json.

I also have another question related to this.. Is it possible to pass in the json a javascript expression to evaluate? I have a javascript function to evaluate in order to get an id in a webpage

var children = document.body.getElementsByTagName('*');
var id='userScreenName';
var elements = [], child;
for (var i = 0, length = children.length; i < length; i++) {
   child = children[i];
   if (>-1)
return elements[0].id;

Extracting nodeId from Selenium WebDriver for Chrome Remote Interface

I was able to invoke Chrome Remote Interface functions inside Selenium WebDriver session (Page.captureScreenshot, Emulation.clearDeviceMetricsOverride etc). But I have problem with invoking methods which work on DOM element. The problem is with nodeId parameter. For example this function accepts as one of parameters nodeId. I can’t figure out how to extract nodeId based on IWebElement (or RemoteWebElement) from SeleniumWebdriver.

How can I find nodeId using Selenium or Javascript?

More info about Chrome Remote Interface could be found here