Visual Regression Testing with Apify and AI Vision Model n8n Workflow Template

n8n workflow template · 24 nodes · Google Drive

Visual Regression Testing with Apify and AI Vision Model is a free n8n workflow template that runs on a schedule and works with Google Drive, Google Gemini, Google Sheets and Linear. It has 24 nodes, 3 of them AI nodes (Google Gemini Chat Model, Structured Output Parser and Basic LLM Chain). The notes inside the workflow say: “This workflow uses a Google Sheet to track a list of webpages to test and is split into 2 parts; Part A generates the base screenshots of the list and Part B runs the visual regression testing.” To run it, you add your own credentials for Google Drive OAuth2, Google Gemini (PaLM) API, Google Sheets OAuth2, HTTP Query Auth and Linear API.

At a glance

Trigger
Schedule Trigger (Schedule Trigger)
Nodes
24
Apps
Google Drive, Google Gemini, Google Sheets and Linear
AI nodes
3
Credentials
5 types
Category
IT, security and DevOps

Apps and integrations

  • Google Drive
  • Google Gemini
  • Google Sheets
  • Linear

Node types used

  • Google Drive
  • Google Gemini Chat Model
  • Structured Output Parser
  • Loop Over Items
  • Wait
  • HTTP Request
  • Google Sheets
  • Merge
  • Schedule Trigger
  • Filter
  • Edit Fields (Set)
  • Aggregate
  • Linear
  • Manual Trigger
  • Basic LLM Chain

How it works

The text below comes from the sticky notes inside the workflow. We removed links, code samples and anything that looks like a key or token.

Try It Out!

This workflow implements an approach to Visual Regression Testing - a means to test websites for defects - using AI Vision Models.

This workflow uses a Google Sheet to track a list of webpages to test and is split into 2 parts; Part A generates the base screenshots of the list and Part B runs the visual regression testing.

The example spreadsheet can be found here

Apify.com is the screenshot generator of choice and a free account with $5 in credit is available via this link.

Need Help?

Join the Discord or ask in the Forum!

Part A. Generate Base Images

Before we can run our visual regression tests, we must generate a series of base screenshots to compare against. This part of the workflow uses an external website screenshotting service, Apify.com, to achieve this. This part of the workflow should only be run when we want to update our base screenshots.

1. Get List of Webpages to Generate Base Images

Learn more about using Google Sheets

This workflow is split into 2 parts: Part A will generate the "base" screenshots to compare new screenshots against. To capture these base screenshots, we'll use Google Sheets to hold our list of webpages and their screenshot references (we'll come on to that later).

3. Upload Screenshot to Google Drive

Read more about using the Google Drive node

Once we have our screenshots, we'll download them from Apify and upload them to our Google Drive for safe keeping. After uploading, we'll capture the new Google Drive IDs for the images into our Google Sheet, this will allow us to reference them again when we perform the visual regression testing.

Part B. Run Visual Regression Test

In this part of the workflow, we'll retrieve our list of webpages to test with our AI vision model. This part can be run as many times as required.

4. Trigger Visual Regression Test Run

Read more about the Schedule Trigger

Once we've generated our base images to compare with in Part A, we can now run our Visual Regression Tests. These tests are intended to check for unexpected changes to a webpage by using some form of image detection. To trigger Part B, we'll start with a schedule trigger and pull a list of webpages to test from Google Sheets.

5. Download Base and Generate new Webpage Screenshot

Learn more about Apify.com

Looping for each webpage, we'll do 2 tasks (1) download the base screenshot for the url and (2) and use our Apify.com webpage screenshot actor again to generate a fresh screenshot.

6. Compare Screenshots using Vision Model

Read more about the basic LLM chain

To carry out our visual regression test, we need to send both screenshots simultaneously to our Vision model. This is easily achieved using n8n's built-in basic LLM chain where we can define two user messages of the binary type. For our vision model, we'll use Google's Gemini but any capable vision model will also do the job. A Structured Output Parser is used here to return the AI's response in JSON format, this is for easier formatting purposes which we'll get to in the next step.

Setup notes

The text below comes from the sticky notes inside the workflow. We removed links, code samples and anything that looks like a key or token.

2. Generate Webpage Screenshot via Apify

Learn more about Apify.com

To generate a screenshot of the webpage, we'll need a third party service since this functionality is outside the scope of n8n. Feel free to pick whichever internal or external service works for you but I've had great experience using Apify.com - a popular webscraping SaaS who offer a generous free plan and require very little configuration to get started.

The Apify "actor" (ie. a type of scraper) we'll be using is specifically designed to take webpage screenshots.

7. Create Report In Linear

Learn more about integrating with Linear.app

For the final step, we'll generate a simple report which will capture any changes detected in our webpages list. Let's do this by first combining our webpages with their test results and filter out any in the page where no changes were detected. Next, we'll aggregate all changes into the Linear.app node which will be formatted into a markdown snippet and used to create a new issue in Linear. If you don't use Linear, feel free to swap this out for JIRA or even Slack.

Nodes in this workflow

The 24 nodes in file order (sticky notes excluded). Branches and connections determine execution order in n8n:

  1. Base Image (Google Drive)
  2. Google Gemini Chat Model (Google Gemini Chat Model)
  3. Structured Output Parser (Structured Output Parser)
  4. Loop Over Items (Loop Over Items)
  5. Wait (Wait)
  6. Download Screenshot (HTTP Request)
  7. Upload to Drive (Google Drive)
  8. Update Base Image (Google Sheets)
  9. Merge (Merge)
  10. Schedule Trigger (Schedule Trigger)
  11. Get URLs with Missing Base Images (Google Sheets)
  12. Run Webpage Screenshot (HTTP Request)
  13. Run Webpage Screenshot1 (HTTP Request)
  14. Has Changes (Filter)
  15. Combine Row and Result (Edit Fields (Set))
  16. Wait1 (Wait)
  17. Aggregate (Aggregate)
  18. Create Report (Linear)
  19. When clicking ‘Test workflow’ (Manual Trigger)
  20. Get Webpages List (Google Sheets)
  21. For Each Webpage... (Loop Over Items)
  22. Download New Screenshot (HTTP Request)
  23. Combine Screenshots (Merge)
  24. Visual Regression Agent (Basic LLM Chain)

Credentials you need

  • Google Drive OAuth2 – used by Base Image and Upload to Drive
  • Google Gemini (PaLM) API – used by Google Gemini Chat Model
  • Google Sheets OAuth2 – used by Get URLs with Missing Base Images, Get Webpages List and Update Base Image
  • HTTP Query Auth – used by Run Webpage Screenshot and Run Webpage Screenshot1
  • Linear API – used by Create Report

Configure your own credentials after importing. Create each credential in n8n, then select it in the node.

How to import into n8n

  1. Download the JSON file with the button above.
  2. In n8n, open a new workflow, select the ... menu and choose Import from File. You can also paste the JSON straight into the editor canvas.
  3. Open each node that shows a warning and select or create its credential.
  4. Read the notes on the canvas, test the workflow with sample data, then activate it.

Do you need somewhere to run it? Read our guide to self-hosted n8n.

Need this customised?

We can adapt this workflow to your apps, data and process, then deploy and support it.

Contact Us