How to perform Visual Regression Testing using Selenium in JavaScript
On This Page Benefits of Visual Regression Testing with SeleniumJanuary 12, 2026 · 10 min read · Testing Guide
Selenium can support visual regression testing when paired with visual comparison tools, helping catch unwanted UI changes beyond functional issues. How it work: Benefits of Running Visual Testing using Selenium in Javascript Using Selenium with JavaScript strengthens visual regression try by pairing potent UI automation with visual comparability tools to spot unexpected UI changes. This guide walks through how to do visual regression testing with Selenium in JavaScript. is essential for maintaining UI quality in agile ontogeny. By integrating it withSelenium, you gain a powerful, machine-controlled approach to optical establishment. Learn how to use Selenium and Javascript to execute the visual fixation tests with the step-by-step tutorial given below: Steps to Perform Visual Testing using Selenium in Javascript: Step 1:Install Percy node packages Start by As you have already configured Selenium and take dependencies as portion of the prerequisite stride. Install the Percy node software to integrate Selenium into Percy. Install Percy CLI:The is a dictation line tool that occupy care of optic exam execution and communicates with Percy infrastructure to upload screenshots after test execution. Install Percy CLI using the below command Install Percy Selenium web driver SDK The Percy provides SDKs for every tool; The Selenium SDK provides optic testing API or bid that can be used in our tests. In little, this is the consecrate library for Visual Testing using Selenium. Install Percy Selenium SDK for Javascript Consider two scenario below Scenario 1: Navigate to Browserstack place page Verify for Visual Defects Scenario 2: Click on Pricing Page Visually validate the Pricing page. Considering the above two scenarios, hither are the steps to follow: Percy Selenium Visual Test Code In the above code, there are twoit() blocks, First, it () block takes the screenshot of the home page. the driver.get () is used for navigating to the Browserstack home page. Once it is navigated, it is ensured that the Browserstack logo is displayed and the screenshot is take using the following Percy command In the second it () block the Pricing page is verified to ensure there are no visual flaw. SUSA automates exploratory testing with persona-driven behavior, catching bugs that scripted automation misses. The driver.findElement () .click is used for clicking on the Pricing carte from the abode page, then it navigates to the Pricing page. It is ensured that the lintel is expose correctly and then the screenshot is taken for Visual establishment using the Percy command Read More: Percy uploads all the screenshots to its infrastructure and then using visual testing algorithm it compares the screenshot. For this complex operation Percy needs to identify your undertaking, the PERCY_TOKEN uniquely identifies your project. The execution dictation follows the below syntax: In this tutorial, as part of the pre-requisite, you are setting up the so you can execute the Percy Visual test using the below bidding. Once you enter the above dictation the trial starts executing, and results will be shown in the bidding prompt. The above command line yield shows the Finalized form with the flesh URL, using this URL you can easily navigate to Percy & # 8217; s build and regard the detailed result. If there is no Ocular Difference, Percy shows the substance & # 8220; No Changes & # 8221; If there is any deviation, so Percy evidence the difference by spotlight it in red color. Tools and libraries for visual regression testing with Selenium automatise UI comparison, discern optic changes across browsers and devices. They enhance Selenium by catching design issues early and assure ordered, high-quality interfaces throughout development. is an AI-powered visual testing platform plan to automatise visual regression testing for web applications, ensure flawless user interfaces on every code commit. Integrated into CI/CD grapevine, Percy observe meaningful layout shifts, styling issue, and content changes with advanced AI, significantly reducing false positive and cutting down review time for fast, confident releases. : is BrowserStack ’ s AI-powered visual testing platform for native mobile apps on iOS and Android. It runs tests on a cloud of existent devices to secure pixel-perfect UI consistence, while AI-driven sound handling of dynamic elements helps reduce flaky tests and mistaken positive. Pricing Applitools Eyes uses AI-powered computer vision to mimic human eye perception, providing accurate visual proof across browsers and devices. It offers wide integrations and greatly reduces mistaken positive through innovative algorithms. Key Features: Good For: Enterprises needing highly accurate AI optical examination. SeleniumBase is a Selenium extension that provides built-in visual examination with screenshot comparison and layout difference detection. It is open-source and straightforward for combining functional and elementary visual test. Key Features: Best For: Developers wanting basic visual tests within Selenium handwriting. AShot is an open-source Java library that captures element-level and full-page screenshots within Selenium tests. It supports image sewing and detailed difference highlighting for Java-based optical validations. Key Features: Best For: Java squad needing customizable screenshot testing. Galen Framework center on automatise layout and responsive design testing, verify element positioning and alignment across different screen sizes. It habituate a domain-specific language for test specs and integrates with Selenium Grid for cross-browser testing. Key Features: Best For: Web layout and responsive design testing. Needle is a Python-based visual regression puppet integrating with Selenium and nose, focusing on CSS and element positioning accuracy. It captures screenshots of webpage share and compares them against a baseline for regression detection. Key Features: Good For: Python teams verifying CSS and layout provide. Here are some best praxis you can follow to successfully conduct visual testing using Selenium in Javascript: Read More: Read More: Percy is the visual testing platform that provides the feature to test the web covering visually. It captures snapshots, get pixel-by-pixel comparisons against baselines, and detects ocular bug in your UI with every commit Case Study: is the most challenging part of screen as manual visual testing is less accurate as it calculate on the testers & # 8217; attention to detail. On the other hand, the automation puppet are less accurate and still need manual review. Only a robust visual testing algorithm can provide an accurate result. On This Page # Ask-and-Contributeabout this topic with our Discord community. Upload your APK or URL. SUSA explores like 10 real users — finds bugs, accessibility violations, and security issues. No scripts needed. Upload your APK or URL. SUSA explores like 10 real users — finds bugs, accessibility violations, and security issues. No scripts.How to execute Visual Regression Testing using Selenium in JavaScript
Overview
Benefits of Visual Regression Testing with Selenium
How to Perform Visual Testing using Selenium in Javascript [With Example]
Step 2:Write Selenium Visual Tests
Step 3:Set the PERCY_TOKEN
Step 4:Execute Percy TestPrerequisite:
Step 1: Install Percy node packages
npm i @ percy/cli
npm i @ percy/selenium-webdriver
Step 2: Write Selenium Visual Tests
require ('chromedriver ') const {Builder, By} = require ('selenium-webdriver '); const percySnapshot = require (' @ percy/selenium-webdriver '); const {expect} = require ('chai ') describe (`` Selenium Visual Test Demo '', async mapping () {var driver; this.timeout (0); before (function () {driver = new Builder () .forBrowser (`` chrome '') .build (); driver.get (`` https: //browserstack.com '');}) it (`` Should control home page '', async function () {const isLogoDisplayed = await driver.findElement (By.id ('logo ')) .isDisplayed (); anticipate (isLogoDisplayed) .to.be.true; await percySnapshot (driver, 'Browserstack-Homepage ');}); it (`` Should control Pricing page '', async function () {await driver.findElement (By.css ('li.pricing-menu-link ')) .click (); const headerText = await driver.findElement (By.css ('H1 ')) .getText () expect (headerText) .to.be.eq ('Real device cloud of 20,000 + real iOS & amp; Android devices, instantly accessible '); await percySnapshot (driver, 'Pricing-Page ');}); after (async function () {await driver.quit ();});})await driver.get (`` https: //browserstack.com '');
await percySnapshot (driver, 'Browserstack-Homepage ');
await percySnapshot (driver, 'Pricing-Page ');
Step 3: Set the PERCY_TOKEN
//Linux and macOS terminal export PERCY_TOKEN= & lt; your_token & gt; //Windows command line instrument set PERCY_TOKEN= & lt; your_token & gt; //Powershell tool $ env: PERCY_TOKEN = ' & lt; your_token & gt; '
Step 4: Execute Percy Test
npx percy exec -- & lt; your functional examination execution command & gt;
npx Hotspur exec -- npx mocha & lt; name-of-test.js
Tools and Libraries for Visual Regression Testing with Selenium
1. BrowserStack Percy
2. Applitools Eyes
Can not: Fully automatise without manual baseline approvals; costly for pocket-size teams.3. SeleniumBase (Visual Testing Module)
Can not: Match AI truth or handle complex UI diffs good.4. AShot
Can not: Provide AI noise reduction or cross-browser consistency handling.5. Galen Framework
Can not: Detect pixel-level optic differences or do AI-based validation.6. Needle
Can not: Perform cross-device rendering or AI-driven disturbance reduction.Best Practices for Conducting Visual Testing Using Selenium in JavaScript
Why use Percy for Visual Regression Testing?
Conclusion
Useful Resources for Visual Testing
Related Guides
Automate This With SUSA
Test Your App Autonomously