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 commandlighthouse --help
). -
Lighthouse metrics
test case which is available in the sample project
Instructions
- Open browser and navigate to Google web page.
WebUI.openBrowser('https://www.google.com')
- 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()
- Audit the web page in a new tab with Lighthouse.
OsUtils.runCommand("lighthouse ${url} --hostname ${host} --port ${port} --no-enable-error-reporting", null, null)
- Finally, clean up and close the browser.
WebUI.closeBrowser()
- An HTML file will be generated in the root of the project.