Using Lighthouse for quick performance results of any website.

Hey Guys, Lighthouse is an open-source, automated tool for improving the quality of web pages. You can run it against any web page, public or requiring authentication. It has audits for performance, accessibility, progressive web apps, SEO and more. This tool has can make everyone’s life easy – Developers / SDETs / Product Managers.

You can run Lighthouse in Chrome DevTools, from the command line, as a Node module or you can also use https://web.dev/measure/ to measure the performance. You give Lighthouse a URL to audit, it runs a series of audits against the page, and then it generates a report on how well the page did. From there, use the failing audits as indicators on how to improve the page. Each audit has a reference doc explaining why the audit is important, as well as how to fix it.

———————————–___——————

Here is a quality report I ran for a website using https://web.dev/measure/ :

https://lighthouse-dot-webdotdevsite.appspot.com//lh/html?url=https%3A%2F%2Fsoftwaretestingtimes.com

———————————–___——————

As far as the webpage Performance Test is concerned, Lighthouse measures the following metrics:

First Contentful Paint: FCP measures how long it takes the browser to render the first piece of DOM content after a user navigates to your page. Images, non-white <canvas> elements, and SVGs on your page are considered DOM content; anything inside an iframe isn’t included.


Speed Index: Speed Index measures how quickly content is visually displayed during page load. Lighthouse first captures a video of the page loading in the browser and computes the visual progression between frames. Lighthouse then uses the Speedline Node.js module to generate the Speed Index score.


Largest Contentful Paint: Largest Contentful Paint (LCP) is an important, user-centric metric for measuring perceived load speed because it marks the point in the page load timeline when the page’s main content has likely loaded—a fast LCP helps reassure the user that the page is useful.
The Largest Contentful Paint (LCP) metric reports the render time of the largest image or text block visible within the viewport, relative to when the page first started loading.

Time to Interactive: TTI measures how long it takes a page to become fully interactive. A page is considered fully interactive when:

  • The page displays useful content, which is measured by the First Contentful Paint,
  • Event handlers are registered for most visible page elements, and
  • The page responds to user interactions within 50 milliseconds.


Total Blocking Time: TBT measures the total amount of time that a page is blocked from responding to user input, such as mouse clicks, screen taps, or keyboard presses. The sum is calculated by adding the blocking portion of all long tasks between First Contentful Paint and Time to Interactive. Any task that executes for more than 50 ms is a long task. The amount of time after 50 ms is the blocking portion. For example, if Lighthouse detects a 70 ms long task, the blocking portion would be 20 ms.

Cumulative Layout Shift: Cumulative Layout Shift (CLS) is an important, user-centric metric for measuring visual stability because it helps quantify how often users experience unexpected layout shifts—a low CLS helps ensure that the page is delightful.

CLS measures the sum total of all individual layout shift scores for every unexpected layout shift that occurs during the entire lifespan of the page.

A layout shift occurs any time a visible element changes its position from one rendered frame to the next.

Read More about lighthouse here: https://developers.google.com/web/tools/lighthouse

Download Lighthouse for chrome here and it will display in devtools (see below image): https://chrome.google.com/webstore/detail/lighthouse/blipmdconlkpinefehnmjammfjpmpbjk?utm_source=chrome-ntp-icon

In Chrome Devtools:

Below are the screenshots of Results (Detailed report can be found here: https://lighthouse-dot-webdotdevsite.appspot.com//lh/html?url=https%3A%2F%2Fsoftwaretestingtimes.com)

Uploading Files with Selenium Java – Test Automation Cookbook – via Applitools

Angie Jones and Applitools has recently launched a new initiative – Automation Cookbook. It has free bite-size recipes related to JS (#Cypress) & Java (#Selenium).

Here is a tip from cookbook: Uploading files with Selenium Java:

Code:

package file_upload;

import base.BaseTests;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
import org.openqa.selenium.By;

public class FileUploadTests extends BaseTests {

    @BeforeEach
    public void launchApp(){
        driver.get("https://kitchen.applitools.com/ingredients/file-picker");
    }

    @Test
    public void testFileUpload() {
        String filePath = "/Users/angie/workspace/recipes/resources/images/mac-n-cheese.jpg";
        driver.findElement(By.id("photo-upload")).sendKeys(filePath);
    }
}

You can practice above code in this file picker: https://kitchen.applitools.com/ingredients/file-picker

Find more Selenium and Cypress recipes over at the Automation Cookbook: https://applitools.com/cookbook/

Thanks to Angie and Applitools for making our life easy.