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.
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.
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.
Join the Discord or ask in the Forum!
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.
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).
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.
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.
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.
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.
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.
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.
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.
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.
The 24 nodes in file order (sticky notes excluded). Branches and connections determine execution order in n8n:
Configure your own credentials after importing. Create each credential in n8n, then select it in the node.
Do you need somewhere to run it? Read our guide to self-hosted n8n.
We can adapt this workflow to your apps, data and process, then deploy and support it.
Contact Us