Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Chrome Dev Tools API & Selenium WebDriver

I am experimenting with Selenium Web Driver for automating my browser integration tests. I see that Chrome Dev Tools comes with a console API for invoking certain dev tool functions from inside JavaScript.

Ideally, from inside my Java/JUnit integration test, I could start the Chrome Dev Tool memory profiler (and perhaps some other tools), run my WebDriver tests (instantiating a Chrome browser instance, manipulating DOM elements, etc.), and then stop the profiler, then inspect the profiler's results to see if there are any memory leaks.

Is this concept even feasible or am I way out to lunch? Why/why not?

It seems like the API already has a console.profile() to start a profiling session, and a console.profileEnd(). So in theory I could have WebDriver invoke these two methods and run tests in between them.

I think the missing link is then programmatically interacting with the results of the profiling session...

like image 625
IAmYourFaja Avatar asked Jan 04 '14 02:01

IAmYourFaja


People also ask

Does Chrome have an API?

Chrome provides extensions with many special-purpose APIs like chrome. runtime and chrome.

What are Chrome dev tools?

Chrome DevTools is a set of web developer tools built directly into the Google Chrome browser. These tools let you inspect the rendered HTML (DOM) and network activity of your pages. You can use DevTools to troubleshoot ad serving issues.


2 Answers

You can actually use the debugger protocol as mentioned by @loislo above – you might find more useful the link https://developer.chrome.com/devtools/docs/debugger-protocol

Just add the flag when opening Chrome and remote-debug it! :)

like image 121
Tom Roggero Avatar answered Sep 30 '22 08:09

Tom Roggero


Chrome DevTools has two parts, front-end with UI and back-end in the native code of the renderer. These parts work with each other via protocol. The protocol is described in the protocol.js file

Chrome can work in remote debugging mode when it exposes tcp socket that can be used for interacting with the backend part of DevTools. This feature is actively used in Chrome browser Telemetry toolset

This toolset was written in python and we keep it in sync with the current version of the protocol. The toolset has the code for working with heap profiler part and other parts of the DevTools.

like image 23
loislo Avatar answered Sep 30 '22 08:09

loislo