Skip to content

Latest commit

 

History

History
40 lines (25 loc) · 1.99 KB

File metadata and controls

40 lines (25 loc) · 1.99 KB

Selenium-GoogleLightHouse-Integration

This project will integrate Google Lighthouse tool with Selenium for application audit and other health check-up stuffs.

Google Lighthouse is an open-source, automated tool for improving the quality of web pages. It can be run on any web page, public or requiring authentication. It has audits for performance, accessibility, progressive web apps, SEO and more. Lighthouse runs a series of tests on the page, and then generates a report on how well the page did. The report includes opportunities for improvement and suggestions on how to fix them.

Selenium will help to navigate to different pages of application where we have to run the lighthouse audit as sometimes its not required to run on every page.

We will use Lighthouse Node CLI as its the most powerful and advanced way to run performance and accessibility audits. This is also recommended by the Lighthouse Team in their GitHub Page.

  1. Use below command to install lighthouse CLI in your laptop.

npm install -g lighthouse

  1. Launch the chrome browser programmatically using process builder on any available port.

ProcessBuilder builder = new ProcessBuilder("cmd.exe", "/c", "chrome-debug --port=9222"); builder.redirectErrorStream(true); Process p = builder.start();

  1. Now using selenium, point this above existing chrome instance by pointing to the mentioned port i.e. 9200.

ChromeOptions options = new ChromeOptions(); options.setExperimentalOption("debuggerAddress", "127.0.0.1:9222"); ChromeDriver driver = new ChromeDriver(options);

  1. After introduction of websocket in latest versions of Selenium, its creating problem while connecting with existing chrome instances. Therefore, use below dependency to handle this.
org.seleniumhq.selenium selenium-http-jdk-client 4.5.0

image