David Jones
Percy Blog
Published in
2 min readDec 20, 2018

--

We’re thrilled to announce our Java Selenium SDK! Percy now has support for Java applications–just add Percy snapshots to your Selenium tests.

Visual testing for Java apps with Selenium

For developers building and maintaining Java apps, Selenium is a powerful and flexible tool for automating user actions within browsers for test purposes.

Our Selenium Java SDK builds on top of Selenium’s flexible and powerful foundation, helping teams add visual coverage to their Java applications. It’s now easier than ever to ensure your applications not only function as intended but also look exactly as designed.

Integrating Percy with Java Selenium

In this post, you’ll get a quick overview of installing and setting up Percy with your Java Selenium setup. Check out our documentation to go through each of those steps in detail.

1. Add percy-java-selenium to your project dependencies.

For example, if you’re using Maven for your dependencies:

<dependency>
<groupId>io.percy</groupId>
<artifactId>percy-java-selenium</artifactId>
</dependency>

2. Install the @percy/agent npm package:

$ npm install --save-dev @percy/agent

3. Import the Percy selenium library into each file from which you want to take snapshots: import io.percy.selenium.Percy

4. Create a new Percy object with a WebDriver instance as a parameter: Percy percy = new Percy(webDriver);

5. Call percy.snapshot(SNAPSHOT_NAME) wherever you want to generate a snapshot.

6. Wrap your run command in ./node_modules/.bin/percy exec --. This will start a Percy agent to receive snapshots from your tests and upload them to your Percy project.

For example, if you’re using Maven you would do something like this:

./node_modules/.bin/percy exec —- mvn test

With this integration, you can also globally configure snapshot widths for each build. Check out our documentation.

Walk through our Java Selenium tutorial where we clone an example Java application tested with Selenium, make some changes, and see the visual diffs in Percy.

Being able to easily add visual testing to your existing Selenium setup is the fastest way to get visual coverage across your Java application. We’re excited to extend our support to Java applications and are excited to broaden the use of Percy.

We recently launched SDKs for several test frameworks:

Stay tuned for upcoming announcements by hitting Follow below or on Twitter.

Percy is an all-in-one visual testing solution that gives your team confidence in every visual change before it’s shipped. Learn more at https://percy.io. ☕️

--

--