Generating Multiple Lighthouse Reports Using Lambda Hooks
LambdaTest lets you perform Selenium automation while allowing you to generate multiple Lighthouse reports through Lambda Hooks. It includes the hook structure, expected behavior, and conditions under which the reports are generated or errors are thrown.
Hook Structure
To generate a Lighthouse report, the following JavaScriptExecutor hook is used:
JavascriptExecutor jse = (JavascriptExecutor)driver;
jse.executeScript("lambdatest_executor: {\"action\": \"generateLighthouseReport\", \"arguments\": {\"url\": \"<any url>\"}}");
Generating Lighthouse Report Using Lambda Hooks
- You can execute the hook multiple times with a configurable URL.
- In case of an error from Lighthouse report execution, a 200 status response with the message Failed to generate Lighthouse report. Please try again. will be sent. However, the test execution will continue.
- For browsers other than Chrome, a 4XX error will be thrown stating Lighthouse report is supported only for Chrome browser.
- If you generate Lighthouse reports using Lambda hook, ensure to turn off the
performance:true
capability. - Successful generation of the report will return a 200 status and a response body containing:
{
"message": "Lighthouse report generated successfully",
"data": "<STRINGIFIED LIGHTHOUSE JSON REPORT>"
}
- Lighthouse reports for all hooks executed will be visible on the LambdaTest Web Automation Dashboard under Performance tab.