Chrome Dev Tools API & Selenium WebDriver

拥有回忆 提交于 2019-12-18 02:09:12

问题


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...


回答1:


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! :)




回答2:


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.



来源:https://stackoverflow.com/questions/20916035/chrome-dev-tools-api-selenium-webdriver

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!