Audit a web page (performance, accessibility, etc.) with Lighthouse

Sample project used in this topic: GitHub - katalon-studio-samples/katalon-studio-chrome-devtools-protocol-plugin-samples

This topic covers how to collect performance metrics of Google web page using Lighthouse, then generate a report on its performance, accessibility and more. From there, the audits can be used as indicators for improving the web page.

Prerequisites

  • Latest version of Katalon Studio with Chrome DevTools Protocol Integration installed.
  • Lighthouse as a NodeJS module (see Overview - Chrome Developers for installation instructions).
    Note: Please assure that lighthouse command can be executed on command-line interface before restarting Katalon Studio (try the command lighthouse --help).
  • Lighthouse metrics test case which is available in the sample project

Instructions

  1. Open browser and navigate to Google web page.
WebUI.openBrowser('https://www.google.com')
  1. Get the current tab url as well as host and port of the current browser instance.
String url = WebUI.getUrl()
def (host, port) = CdpUtils.getServiceEndpoint()
  1. Audit the web page in a new tab with Lighthouse.
OsUtils.runCommand("lighthouse ${url} --hostname ${host} --port ${port} --no-enable-error-reporting", null, null)
  1. Finally, clean up and close the browser.
WebUI.closeBrowser()
  1. An HTML file will be generated in the root of the project.
12 Likes

Hi! I tried this approach but TC Lighthouse metrics fails with error:


I couldn’t get to the command line from the Katalon either way (I tried to run a batch file, execute some random application from the test - no luck)
@sonpham could you please help me fix it?

Hi @Ayame,

Have you tried the sample project?

FYI, you can find the OsUtils class here.

Hope it helps!

Hi! Yes, I did. But I think I could do something wrong while copying it to my own. Should I copy all th files from it (configuration,settings)? I copied scripts and test cases

Hi @Ayame,

You also need to copy everything under Include/scripts/groovy .

1 Like

thank you very much, it helped

1 Like