Selenium
This guide shows how to add Buddy Visual Tests to an existing Selenium test suite. Plugins are available for Java, C#, and JavaScript. Snapshots taken in your tests are uploaded on every run and compared against the approved baseline.
Prerequisites
bdyCLI installed (requires Node.js v20+)- Suite token exported as
BUDDY_VT_TOKEN- copy it from the suite settings (in Buddy pipelines the token is set automatically)
Java
Add the dependency to pom.xml:
xml<dependency> <groupId>works.buddy.visual-tests</groupId> <artifactId>plugin</artifactId> <version>1.0.2</version> <!-- check for the latest version --> </dependency>
Initialize the driver and plugin in your test class:
javaprivate static WebDriver driver; private static VisualTestsPlugin visualTestPlugin; @BeforeAll static void setupAll() { WebDriverManager.chromedriver().setup(); driver = new ChromeDriver(); visualTestPlugin = new VisualTestsPlugin(driver, false); }
Take snapshots in your tests:
javavisualTestPlugin.takeSnapshot("Snapshot name");
Run the tests through the CLI:
bashbdy tests visual session create "mvn test"$
C#
Add the package to your project:
bashdotnet add package BuddyWorks.VisualTests.Selenium$
Initialize the driver and plugin in your test class:
csharpstatic IWebDriver driver = null; static VisualTestsPlugin visualTestsPlugin = null; [AssemblyInitialize] public static void AssemblyInit(TestContext context) { driver = new ChromeDriver(); visualTestsPlugin = new VisualTestsPlugin(driver, suppressErrors: false); }
Take snapshots in your tests:
csharpawait visualTestsPlugin.TakeSnapshotAsync("Snapshot name");
Run the tests through the CLI:
bashbdy tests visual session create "dotnet test TestProject.csproj"$
JavaScript
Install the plugin:
bashnpm i @buddy-works/visual-tests-selenium$
Initialize the driver and plugin in your test file:
javascriptimport { Builder } from "selenium-webdriver"; import VisualTestsPlugin from "@buddy-works/visual-tests-selenium"; const driver = await new Builder().forBrowser("chrome").build(); const visualTestsPlugin = new VisualTestsPlugin(driver);
Take snapshots in your tests:
javascriptawait visualTestsPlugin.takeSnap('Snapshot name');
Run the tests through the CLI:
bashbdy tests visual session create "node test.js"$
Whichever language you use, when the run finishes the session appears in the suite with all captured snapshots rendered across the browsers and devices configured in the suite settings. See Reviewing & Approvals for the next step.
Let AI do it
If you use an AI coding agent, paste this prompt to have it wire up visual tests in your existing tests:
Add Buddy Visual Tests to my Selenium test suite:
1. Install the Buddy visual tests plugin for my language:
- Java: Maven dependency works.buddy.visual-tests:plugin
- C#: NuGet package BuddyWorks.VisualTests.Selenium
- JavaScript: npm package @buddy-works/visual-tests-selenium
2. Initialize a VisualTestsPlugin instance next to the WebDriver setup
(one shared instance for the test class/file).
3. After each meaningful, stable UI state in the tests, take a snapshot:
- Java: visualTestPlugin.takeSnapshot("<descriptive-snapshot-name>");
- C#: await visualTestsPlugin.TakeSnapshotAsync("<descriptive-snapshot-name>");
- JavaScript: await visualTestsPlugin.takeSnap('<descriptive-snapshot-name>');
4. Use kebab-case snapshot names; group related views with "/" (e.g. "checkout/step-1").
5. Do not change any test logic or assertions.
The tests will be executed through the Buddy CLI, e.g.:
bdy tests visual session create "mvn test"
Last modified on Jul 13, 2026