ScreenshotNeo

BlogHow-to

Applitools Eyes Selenium Java Tutorial in Hindi

Add Applitools Eyes visual checkpoints to Selenium Java, run the official sample, understand baselines and match levels, and troubleshoot common setup errors.

By the ScreenshotNeo team4 October 20267 min read

Direct answer: Applitools Eyes adds visual checkpoints to a Selenium Java test. Selenium opens the page and performs actions; eyes.check() captures a checkpoint for comparison with a baseline. Start from Applitools’ maintained Selenium Java quickstart and its official example repository. This English-language walkthrough keeps Java identifiers and commands unchanged.

1. What Applitools Eyes adds to Selenium

A regular Selenium assertion checks a value, such as whether a button exists. A visual checkpoint checks the rendered appearance of a page or region. Selenium remains responsible for browser control and actions; Eyes records visual steps and reports differences against the saved baseline.

A batch groups test executions, while each eyes.check() call creates a visual step. On a first run without an existing baseline, a test can appear as New and its images become the baseline. Later runs compare new checkpoints against that baseline. Differences may appear as Unresolved for review in the dashboard. See the official quickstart for the current flow.

2. Prerequisites and API key setup

The official quickstart lists an Applitools account and API key, JDK 8 or higher, Maven, an up-to-date Chrome browser, and a corresponding ChromeDriver. Verify current Java, Chrome, Selenium, and driver compatibility before debugging an environment failure. Chrome and ChromeDriver must have the same major version, and the driver executable must be discoverable through PATH.

Configure the key

Set APPLITOOLS_API_KEY in the shell or IDE run configuration. Use a placeholder in documentation and keep the real key out of source control.

# macOS or Linux
export APPLITOOLS_API_KEY=YOUR_API_KEY

# Windows Command Prompt
set APPLITOOLS_API_KEY=YOUR_API_KEY

Check Maven with mvn -v and ChromeDriver with chromedriver -v. In an IDE, set the environment variable in the test’s run configuration so the Java process can read it. Some IDEs bundle Maven.

3. Get the maintained Java example running

  1. Clone the example and enter its directory:
git clone https://github.com/applitools/example-selenium-java-basic.git
cd example-selenium-java-basic
  1. Install the project dependencies:
mvn install
  1. Set APPLITOOLS_API_KEY for the same shell or IDE session, then run the sample:
mvn exec:exec@run-the-tests -Dexec.classpathScope=test

The sample test is src/test/java/com/applitools/example/AcmeBankTests.java. Run the project’s maintained sample as written first. Its SDK setup uses the current Eyes Java APIs; avoid copying old tutorials that use legacy methods such as checkWindow. Check the repository and quickstart if their implementation changes.

4. Understand the visual test flow

The official sample demonstrates the important lifecycle: initialize the runner and configuration, create Chrome options and a Selenium WebDriver, open an Eyes test with eyes.open(), navigate with Selenium, capture named checkpoints using eyes.check(), and close the Eyes test and runner. Follow the complete current implementation in AcmeBankTests.java.

// Core flow in the maintained example; use the repository for imports and setup.
// 1. Create the Eyes runner and Configuration.
// 2. Create ChromeOptions and a ChromeDriver.
// 3. Open the Eyes test with eyes.open(...).
// 4. Navigate and interact using Selenium WebDriver.
// 5. Add named visual steps, for example:
eyes.check(Target.window().fully().withName("Login page"));
// 6. Close Eyes and the runner in cleanup code.

In the quickstart example, Chrome is launched with ChromeOptions, Eyes opens a named test, Selenium loads a sample banking application and performs login actions, and checkpoints capture the login and main pages. Keeping checkpoint names meaningful makes the corresponding images easier to locate in results.

Run locally or use Ultrafast Grid targets

The example configures an Applitools VisualGridRunner and browser/device targets through a Configuration object. The quickstart illustrates desktop Chrome, Firefox, Safari, and Chrome emulation for selected devices. Treat those targets as examples, not a guarantee that every account has identical access or that the catalog stays fixed. Confirm the active target list in the vendor’s current documentation. The repository notes that Ultrafast Grid is enabled in its default example configuration, while Execution Cloud is not.

5. Read baselines and review results

  • Batch: A group of tests from an execution or suite.
  • Test status: New indicates no prior baseline for the test; a subsequent run compares with the saved baseline. Unresolved indicates a difference that needs review.
  • Test steps: Each eyes.check() call appears as a visual step. Open a step to inspect the checkpoint and comparison.
  • Review: Determine whether a difference is an intended UI update or a regression before updating or accepting a baseline.

A changed screenshot is not automatically a product bug: it may reflect expected content or a real layout regression. Review the affected region and the code or data change that caused it. A baseline should represent the intended design for the test environment.

6. Choose a match level for dynamic pages

Applitools’ quickstart describes three primary match levels. Start with the default Strict comparison and relax only the known dynamic areas when variable content makes the comparison noisy.

Match level What it is for Use it when
Strict Default comparison that flags human-visible changes. The page or region is expected to render consistently and visual detail matters.
Ignore Colors Compares without treating color changes as differences. Color varies intentionally but text, shapes, and layout still matter.
Layout Checks overall structure and relative positioning while tolerating dynamic content in the documented example. A known region contains changing values but its structure should remain.

Apply Layout matching selectively to the dashboard selectors containing changing balances or table data, as shown in the official tutorial:

eyes.check(
    Target.window().fully().withName("Main page")
        .layout(
            By.cssSelector(".dashboardOverview_accountBalances__3TUPB"),
            By.cssSelector(".dashboardTable_dbTable___R5Du")
        )
);

Selectors above belong to the tutorial’s sample app; replace them with selectors from your own page. A looser match changes which differences count. Do not use it to suppress an unexplained failure. The tutorial notes that Layout can still identify structural problems such as an element disappearing or failing to load.

7. Troubleshooting

Symptom Likely cause Fix
Eyes cannot find an API key or the test fails to authenticate APPLITOOLS_API_KEY is unset or unavailable to the Java process. Set the variable in the shell or IDE run configuration that launches Maven or the test. Check for a typo; do not paste a real key into committed code.
ChromeDriver fails during WebDriver initialization Chrome and ChromeDriver major versions differ, or the executable is missing from PATH. Align the major versions and ensure the driver is installed and executable where Selenium can discover it. Recheck with chromedriver -v.
mvn is not recognized or dependencies are unresolved Maven is unavailable in the shell, or dependencies have not been installed. Install Maven or use the IDE’s bundled Maven, verify with mvn -v, then run mvn install from the repository root.
Test shows New on its first run No baseline exists yet for that test. Inspect the captured page to confirm it is the intended starting point; subsequent runs can compare against that baseline.
Later run shows Unresolved with changing values highlighted The page includes dynamic data or other real visual changes. Review the diff. Stabilize test data when possible; otherwise apply a suitable match level to the specific dynamic selectors.
Some configured browser or device targets do not run The target example may not match the currently available catalog or account access. Check the current Ultrafast Grid documentation and adjust the Configuration target list.
Test starts but a checkpoint captures an incomplete page The page may not have finished rendering before the checkpoint. Wait for the relevant application state using Selenium before calling eyes.check(); prefer a specific readiness condition over an arbitrary long delay.

8. Performance, reliability, and cost considerations

  • Performance: Each checkpoint adds capture and comparison work. Capture meaningful page states rather than every intermediate action. Grid target count and suite size affect the amount of visual work; keep the target matrix focused on supported environments you need.
  • Reliability: Make navigation and test data repeatable, wait for the page state that matters, and use stable selectors for dynamic regions. Review baseline changes intentionally so environment noise does not become accepted design.
  • Credentials: Provide the API key through environment configuration and protect it as a secret in local and CI environments. Never commit a real key.
  • Cost: The reviewed official quickstart and sample do not establish current pricing or plan limits. Check Applitools’ current account and plan information before budgeting; do not infer cost from the number of local Selenium steps alone.

9. Or skip the browser setup

If your goal is to capture a clean website screenshot from code rather than run a Selenium visual regression test, ScreenshotNeo is a website screenshot API and MCP server from Yorker Media. A single request captures a URL as PNG, JPEG, WebP, or PDF. See the ScreenshotNeo API documentation.

curl -G "https://api.screenshotneo.com/v1/shot" -d access_key=YOUR_API_KEY --data-urlencode url=https://stripe.com -o shot.webp
import requests
r = requests.get("https://api.screenshotneo.com/v1/shot", params={"access_key": "YOUR_API_KEY", "url": "https://stripe.com"}, timeout=90)
open("shot.webp", "wb").write(r.content)
const q = new URLSearchParams({ access_key: 'YOUR_API_KEY', url: 'https://stripe.com' });
const res = await fetch(`https://api.screenshotneo.com/v1/shot?${q}`);

ScreenshotNeo removes cookie banners, popups, and chat widgets before the shot. Bot checks, blank pages, and failed loads are never billed. Its MCP server lets AI agents take screenshots. The free plan includes 1,000 screenshots a month with no card; paid plans start at $5 for 3,000. It provides screenshot capture rather than Applitools baseline comparison. Sign up for ScreenshotNeo and get 1,000 free screenshots a month, with no card required.

10. FAQ

Does Eyes replace Selenium?

No. Selenium still drives the browser and performs interactions; Eyes adds visual checkpoints and comparison.

Should every page use Layout matching?

No. Use the strict default for stable content and a more tolerant match only for regions with understood, expected variation.

Can I use this tutorial’s Ultrafast Grid device list unchanged?

Use it as an illustration. Check the current target catalog and account access before depending on particular browsers or devices.

Is ScreenshotNeo an Applitools replacement?

No. ScreenshotNeo captures website screenshots through an API or MCP server; this guide uses Applitools Eyes to compare visual test checkpoints against baselines.

Primary references