{"id":14978883,"url":"https://github.com/percy/percy-selenium-java","last_synced_at":"2026-04-02T18:34:12.081Z","repository":{"id":36965499,"uuid":"156753832","full_name":"percy/percy-selenium-java","owner":"percy","description":"Visual testing with Java Selenium and Percy","archived":false,"fork":false,"pushed_at":"2025-01-10T05:34:47.000Z","size":484,"stargazers_count":12,"open_issues_count":22,"forks_count":17,"subscribers_count":10,"default_branch":"master","last_synced_at":"2025-02-10T03:39:54.739Z","etag":null,"topics":["java","percy","percy-agent","percy-sdk","selenium","visual-regression-testing","visual-testing","visual-tests"],"latest_commit_sha":null,"homepage":"https://docs.percy.io/docs/java-selenium","language":"Java","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/percy.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":"CODEOWNERS","security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2018-11-08T18:51:45.000Z","updated_at":"2024-10-07T10:43:25.000Z","dependencies_parsed_at":"2023-09-25T17:47:28.438Z","dependency_job_id":"cca6d297-bf35-40b5-9749-2ef540a14192","html_url":"https://github.com/percy/percy-selenium-java","commit_stats":{"total_commits":233,"total_committers":18,"mean_commits":"12.944444444444445","dds":0.5836909871244635,"last_synced_commit":"e246873623e645325dc6d8edae328a5926a69068"},"previous_names":["percy/percy-java-selenium"],"tags_count":35,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/percy%2Fpercy-selenium-java","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/percy%2Fpercy-selenium-java/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/percy%2Fpercy-selenium-java/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/percy%2Fpercy-selenium-java/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/percy","download_url":"https://codeload.github.com/percy/percy-selenium-java/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":238662637,"owners_count":19509640,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["java","percy","percy-agent","percy-sdk","selenium","visual-regression-testing","visual-testing","visual-tests"],"created_at":"2024-09-24T13:58:34.746Z","updated_at":"2025-10-28T14:30:38.953Z","avatar_url":"https://github.com/percy.png","language":"Java","readme":"# percy-java-selenium\n\n[![Maven Central](https://maven-badges.herokuapp.com/maven-central/io.percy/percy-java-selenium/badge.svg)](https://maven-badges.herokuapp.com/maven-central/io.percy/percy-java-selenium)\n![Test](https://github.com/percy/percy-java-selenium/workflows/Test/badge.svg)\n\n[Percy](https://percy.io) visual testing for Java Selenium.\n\n## Development\n\nInstall/update `@percy/cli` dev dependency (requires Node 14+):\n\n```sh-session\n$ npm install --save-dev @percy/cli\n```\n\nInstall maven:\n\n```sh-session\n$ brew install mvn\n```\n\nRun tests:\n\n```\nnpm test\n```\n\n## Installation\n\nnpm install `@percy/cli`:\n\n```sh-session\n$ npm install --save-dev @percy/cli\n```\n\nAdd percy-java-selenium to your project dependencies. If you're using Maven:\n\n``` xml\n\u003cdependency\u003e\n  \u003cgroupId\u003eio.percy\u003c/groupId\u003e\n  \u003cartifactId\u003epercy-java-selenium\u003c/artifactId\u003e\n  \u003cversion\u003e1.2.0\u003c/version\u003e\n\u003c/dependency\u003e\n```\n\nIf you're using a different build system, see https://search.maven.org/artifact/io.percy/percy-java-selenium for details for your specific system.\n\n## Usage\n\nThis is an example test using the `percy.snapshot` function.\n\n``` java\n// import ...\nimport io.percy.selenium.Percy;\n\npublic class Example {\n  private static WebDriver driver;\n  private static Percy percy;\n\n  public static void main(String[] args) {\n    FirefoxOptions options = new FirefoxOptions();\n    options.setHeadless(true);\n    driver = new FirefoxDriver(options);\n    percy = new Percy(driver);\n\n    driver.get(\"https://example.com\");\n    percy.snapshot(\"Java example\");\n  }\n}\n```\n\nRunning the test above normally will result in the following log:\n\n```sh-session\n[percy] Percy is not running, disabling snapshots\n```\n\nWhen running with [`percy\nexec`](https://github.com/percy/cli/tree/master/packages/cli-exec#percy-exec), and your project's\n`PERCY_TOKEN`, a new Percy build will be created and snapshots will be uploaded to your project.\n\n```sh-session\n$ export PERCY_TOKEN=[your-project-token]\n$ percy exec -- [java test command]\n[percy] Percy has started!\n[percy] Created build #1: https://percy.io/[your-project]\n[percy] Snapshot taken \"Java example\"\n[percy] Stopping percy...\n[percy] Finalized build #1: https://percy.io/[your-project]\n[percy] Done!\n```\n\n## Configuration\n\nThe snapshot method arguments:\n\n`percy.snapshot(name, widths[], minHeight, enableJavaScript, percyCSS, scope, sync, responsiveSnapshotCapture)`\n\n- `name` (**required**) - The snapshot name; must be unique to each snapshot\n- Additional snapshot options (overrides any project options):\n  - `widths` - An array of widths to take screenshots at\n  - `minHeight` - The minimum viewport height to take screenshots at\n  - `enableJavaScript` - Enable JavaScript in Percy's rendering environment\n  - `percyCSS` - Percy specific CSS only applied in Percy's rendering\n    environment\n  - `scope` - A CSS selector to scope the screenshot to\n  - `sync` - For getting syncronous results https://www.browserstack.com/docs/percy/advanced/sync-comparison-results\n  - `responsiveSnapshotCapture` - For capturing snapshot of responsive websites\n\n\n## Upgrading\n\n### Automatically with `@percy/migrate`\n\nWe built a tool to help automate migrating to the new CLI toolchain! Migrating\ncan be done by running the following commands and following the prompts:\n\n``` shell\n$ npx @percy/migrate\n? Are you currently using percy-java-selenium? Yes\n? Install @percy/cli (required to run percy)? Yes\n? Migrate Percy config file? Yes\n```\n\nThis will automatically run the changes described below for you.\n\n### Manually\n\n#### Installing `@percy/cli` \u0026 removing `@percy/agent`\n\nIf you're coming from a pre-3.0 version of this package, make sure to install `@percy/cli` after\nupgrading to retain any existing scripts that reference the Percy CLI\ncommand. You will also want to uninstall `@percy/agent`, as it's been replaced\nby `@percy/cli`.\n\n```sh-session\n$ npm uninstall @percy/agent\n$ npm install --save-dev @percy/cli\n```\n\n### Migrating Config\n\nIf you have a previous Percy configuration file, migrate it to the newest version with the\n[`config:migrate`](https://github.com/percy/cli/tree/master/packages/cli-config#percy-configmigrate-filepath-output) command:\n\n```sh-session\n$ percy config:migrate\n```\n\n## Running Percy on Automate\n`percy.screenshot(driver, name, options)` [ needs @percy/cli 1.27.0-beta.0+ ];\n\nThis is an example test using the `percy.screenshot` method.\n\n``` java\n// import ...\nimport io.percy.selenium.Percy;\n\npublic class Example {\n\n  public static void main(String[] args) throws MalformedURLException, InterruptedException {\n    DesiredCapabilities caps = new DesiredCapabilities();\n    // Add caps here\n\n    WebDriver driver = new RemoteWebDriver(new URL(URL), caps);\n\n    Percy percy = new Percy(driver);\n    percy.screenshot(\"Screenshot 1\");\n    driver.quit();\n  }\n}\n```\n\n- `driver` (**required**) - A selenium driver instance\n- `name` (**required**) - The screenshot name; must be unique to each screenshot\n- `options` (**optional**) - There are various options supported by percy.screenshot to server further functionality.\n  - `sync` - Boolean value by default it falls back to false, Gives the processed result around screenshot [From CLI v1.28.0-beta.0+]\n  - `fullPage` - Boolean value by default it falls back to `false`, Takes full page screenshot [From CLI v1.27.6+]\n  - `freezeAnimatedImage` - Boolean value by default it falls back to `false`, you can pass `true` and percy will freeze image based animations.\n  - `freezeImageBySelectors` - List of selectors. Images will be freezed which are passed using selectors. For this to work `freezeAnimatedImage` must be set to true.\n  - `freezeImageByXpaths` - List of xpaths. Images will be freezed which are passed using xpaths. For this to work `freezeAnimatedImage` must be set to true.\n  - `percyCSS` - Custom CSS to be added to DOM before the screenshot being taken. Note: This gets removed once the screenshot is taken.\n  - `ignoreRegionXpaths` - List of xpaths. elements in the DOM can be ignored using xpath\n  - `ignoreRegionSelectors` - List of selectors. elements in the DOM can be ignored using selectors.\n  - `ignoreRegionSeleniumElements` - List of selenium web-element. elements can be ignored using selenium_elements.\n  - `customIgnoreRegions` - List of custom objects. elements can be ignored using custom boundaries\n    - Refer to example -\n      - ```\n          List\u003cHashMap\u003e customRegion = new ArrayList\u003c\u003e();\n          HashMap\u003cString, Integer\u003e region1 = new HashMap\u003c\u003e();\n          region1.put(\"top\", 10);\n          region1.put(\"bottom\", 110);\n          region1.put(\"right\", 10);\n          region1.put(\"left\", 120);\n          customRegion.add(region1);\n          options.put(\"custom_ignore_regions\", customRegion);\n        ```\n    - Parameters:\n      - `top` (int): Top coordinate of the ignore region.\n      - `bottom` (int): Bottom coordinate of the ignore region.\n      - `left` (int): Left coordinate of the ignore region.\n      - `right` (int): Right coordinate of the ignore region.\n  - `considerRegionXpaths` - List of xpaths. elements in the DOM can be considered for diffing and will be ignored by Intelli Ignore using xpaths.\n  - `considerRegionSelectors` - List of selectors. elements in the DOM can be considered for diffing and will be ignored by Intelli Ignore using selectors.\n  - `considerRegionSeleniumElements` - List of selenium web-element. elements can be considered for diffing and will be ignored by Intelli Ignore using selenium_elements.\n  - `customConsiderRegions` - List of custom objects. elements can be considered for diffing and will be ignored by Intelli Ignore using custom boundaries\n    - Refer to example -\n      - ```\n          List\u003cHashMap\u003e customRegion = new ArrayList\u003c\u003e();\n          HashMap\u003cString, Integer\u003e region2 = new HashMap\u003c\u003e();\n          region2.put(\"top\", 10);\n          region2.put(\"bottom\", 110);\n          region2.put(\"right\", 10);\n          region2.put(\"left\", 120);\n          customRegion.add(region2);\n          options.put(\"custom_consider_regions\", customRegion);\n        ```\n      - Parameters:\n        - `top` (int): Top coordinate of the consider region.\n        - `bottom` (int): Bottom coordinate of the consider region.\n        - `left` (int): Left coordinate of the consider region.\n        - `right` (int): Right coordinate of the consider region.\n    - `regions` parameter that allows users to apply snapshot options to specific areas of the page. This parameter is an array where each object defines a custom region with configurations.\n      - Parameters:\n       - `elementSelector` (optional, only one of the following must be provided, if this is not provided then full page will be considered as region)\n            - `boundingBox` (object): Defines the coordinates and size of the region.\n              - `x` (number): X-coordinate of the region.\n              - `y` (number): Y-coordinate of the region.\n              - `width` (number): Width of the region.\n              - `height` (number): Height of the region.\n            - `elementXpath` (string): The XPath selector for the element.\n            - `elementCSS` (string): The CSS selector for the element.\n        - `algorithm` (mandatory)\n            - Specifies the snapshot comparison algorithm.\n            - Allowed values: `standard`, `layout`, `ignore`, `intelliignore`.\n        - `configuration` (required for `standard` and `intelliignore` algorithms, ignored otherwise)\n            - `diffSensitivity` (number): Sensitivity level for detecting differences.\n            - `imageIgnoreThreshold` (number): Threshold for ignoring minor image differences.\n            - `carouselsEnabled` (boolean): Whether to enable carousel detection.\n            - `bannersEnabled` (boolean): Whether to enable banner detection.\n            - `adsEnabled` (boolean): Whether to enable ad detection.\n         - `assertion` (optional)\n            - Defines assertions to apply to the region.\n            - `diffIgnoreThreshold` (number): The threshold for ignoring minor differences.\n### Example Usage for regions\n```\n        Map\u003cString, Object\u003e params = new HashMap\u003c\u003e();\n        params.put(\"elementXpath\", \"//div[@id='test']\");\n        params.put(\"algorithm\", \"standard\");\n        params.put(\"diffSensitivity\", 3);\n        params.put(\"imageIgnoreThreshold\", 0.2);\n        params.put(\"carouselsEnabled\", true);\n        params.put(\"bannersEnabled\", false);\n        params.put(\"adsEnabled\", true);\n        params.put(\"diffIgnoreThreshold\", 0.1);\n\n        // Call the method to create the region\n        Map\u003cString, Object\u003e regions2 = percy.createRegion(params);\n        List\u003cMap\u003cString, Object\u003e\u003e regions = Collections.singletonList(obj1);\n        Map\u003cString, Object\u003e options = new HashMap\u003c\u003e();\n        options.put(\"regions\", regions);\n\n        percy.snapshot(\"Homepage\", options); \n\n```\n\n### Creating Percy on automate build\nNote: Automate Percy Token starts with `auto` keyword. The command can be triggered using `exec` keyword.\n```sh-session\n$ export PERCY_TOKEN=[your-project-token]\n$ percy exec -- [java test command]\n[percy] Percy has started!\n[percy] [Java example] : Starting automate screenshot ...\n[percy] Screenshot taken \"Java example\"\n[percy] Stopping percy...\n[percy] Finalized build #1: https://percy.io/[your-project]\n[percy] Done!\n```\n\nRefer to docs here: [Percy on Automate](https://www.browserstack.com/docs/percy/integrate/functional-and-visual)\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fpercy%2Fpercy-selenium-java","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fpercy%2Fpercy-selenium-java","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fpercy%2Fpercy-selenium-java/lists"}