1

Is there a way to run the "Generate Report" in Chrome Dev-Tools via Javascript from the JavaScript console in chrome?

Means instead of manually clicking on the "Generate Report" button, I want to execute the function/test behind the button from javascript.

I could run the lighthouse from node.js/NPM, but it still requiring to install all node.js/NPM dependencies, there Chrome has already everything integrated and no other dependencies are required.

=> So searching a node.js free version by using the provided Chrome Dev-Tools to run the lighthouse reporting

this question is similar to this network panel data query https://stackoverflow.com/a/48763513/3880225

cilap
  • 1,783
  • 1
  • 13
  • 46
  • 1
    I dont understand exactly what you are after. If you have devtools open you just press "run audit" under the "lighthouse" tab. What are you actually trying to achieve? If you want to automate testing then use the lighthouse API to get the JSON and parse the result. You need to lay out your requirements a bit better so we can help (number of pages tested, frequency, do you want to store the results etc.). – Graham Ritchie Oct 21 '20 at 16:31
  • thx for your reply. I have added this Means instead of manually clicking on the "Generate Report" button, I want to execute the function/test behind the button from javascript. Hope it is now clearer, that I want to be able to run the test from the javascript call in the browser (or to be specific from selenium) – cilap Oct 22 '20 at 09:27
  • As far as I am aware this is not possible. As you don't want to install the lighthouse CLI (it is really easy on your local machine) then the best option is the Lighthouse API. You would then have to parse the result from the JSON response but that is the easiest way. If you do install the CLI you can save the actual reports if that is what you want as generated HTML files. You would have to write a little API bridge if you wanted to call via JavaScript as obviously you can't call command line from JS. – Graham Ritchie Oct 22 '20 at 09:41
  • 1
    maybe I am blind, but could not find a lighthouse API? Is it a REST api provided by google? – cilap Oct 24 '20 at 16:52
  • Apologies it is called [Page Speed Insights API](https://developers.google.com/speed/docs/insights/v5/get-started). Lighthouse and PSI are basically the same thing so that was why I used the wrong name. – Graham Ritchie Oct 24 '20 at 17:55
  • I could not find that PSI is using lightspeed. Even if, the issue with PSI is that the measuring is done from a google bot typically resided in the US and so return false data regarding latency. Therefore was looking for a more realistic measuring via lightspeed from a defined environment / browser – cilap Oct 27 '20 at 16:36
  • [PSI definitely uses Lighthouse](https://developers.google.com/web/tools/lighthouse#psi) not sure where you looked but it is right on the main Lighthouse page! "To run Lighthouse on PageSpeed Insights:". You are left with [using the Lighthouse CLI](https://stackoverflow.com/a/64511869/2702894), which you said you did not want to do but it is really not difficult to install Node and the CLI. You do not have any other options if you want to control the environment and run it automatically. – Graham Ritchie Oct 27 '20 at 17:42

0 Answers0