Sheetal Satish Babu
Sheetal Satish Babu

Reputation: 51

Clear Network Logs in Chrome

I am trying to read logs from network tab in chrome browser for each action in the web page. Since there are no unique values to identify the network logs, I need to clear the network logs after every event. I have tried console.clear to clear the logs, but its not working. Please let me know how it can be done

JavascriptExecutor js = (JavascriptExecutor) driver;
String script = "console.clear();";
js.executeScript(script);

Upvotes: 1

Views: 2646

Answers (1)

Adrian
Adrian

Reputation: 8597

You can't do this by executing JavaScript in the console. You'd need intercept the Chrome window and execute Ctrl + E twice (Windows) or Command + E twice (Mac).

The above is not achievable using Client-side JavaScript.

Ctrl/Command + E shortcut stops the network tab recording and doing it the second time cleans the log and starts recording again, there's no shortcut to clean the log or do it from the console.

Upvotes: 1

Related Questions