Installations
npm install @percy/selenium-webdriver
Developer Guide
Typescript
Yes
Module System
CommonJS
Min. Node Version
>=14
Node Version
14.21.3
NPM Version
6.14.18
Score
93.4
Supply Chain
97.8
Quality
92.5
Maintenance
100
Vulnerability
100
License
Releases
Contributors
Languages
JavaScript (98.05%)
TypeScript (1.95%)
Developer
percy
Download Statistics
Total Downloads
5,360,409
Last Day
15,205
Last Week
135,224
Last Month
631,844
Last Year
5,123,276
GitHub Statistics
2 Stars
327 Commits
2 Forks
9 Watching
30 Branches
39 Contributors
Package Meta Information
Latest Version
2.1.0
Package Id
@percy/selenium-webdriver@2.1.0
Unpacked Size
23.14 kB
Size
7.32 kB
File Count
8
NPM Version
6.14.18
Node Version
14.21.3
Publised On
07 Oct 2024
Total Downloads
Cumulative downloads
Total Downloads
5,360,409
Last day
-43.9%
15,205
Compared to previous day
Last week
-11.4%
135,224
Compared to previous week
Last month
8.1%
631,844
Compared to previous month
Last year
3,085.4%
5,123,276
Compared to previous year
Daily Downloads
Weekly Downloads
Monthly Downloads
Yearly Downloads
Dependencies
2
@percy/selenium-webdriver
Percy visual testing for Selenium.js.
Installation
1$ npm install --save-dev @percy/cli @percy/selenium-webdriver
Usage
This is an example using the percySnapshot
function. For other examples of selenium-webdriver
usage, see the Selenium JS docs.
1const { Builder } = require('selenium-webdriver'); 2const percySnapshot = require('@percy/selenium-webdriver'); 3 4(async function example() { 5 let driver = await new Builder().forBrowser('firefox').build(); 6 7 try { 8 await driver.get('http://google.com/'); 9 await percySnapshot(driver, 'Google Homepage'); 10 11 await driver.get('http://example.com/'); 12 await percySnapshot(driver, 'Example Site'); 13 } finally { 14 await driver.quit(); 15 } 16})();
Running the code above directly will result in the following logs:
1$ node script.js 2[percy] Percy is not running, disabling snapshots
When running with percy exec
, and your project's
PERCY_TOKEN
, a new Percy build will be created and snapshots will be uploaded to your project.
1$ export PERCY_TOKEN=[your-project-token] 2$ percy exec -- node script.js 3[percy] Percy has started! 4[percy] Created build #1: https://percy.io/[your-project] 5[percy] Running "node script.js" 6[percy] Snapshot taken "Google Homepage" 7[percy] Snapshot taken "Example Site" 8[percy] Stopping percy... 9[percy] Finalized build #1: https://percy.io/[your-project] 10[percy] Done!
Configuration
percySnapshot(driver, name[, options])
driver
(required) - Aselenium-webdriver
driver instancename
(required) - The snapshot name; must be unique to each snapshotoptions
- See per-snapshot configuration options
Upgrading
Automatically with @percy/migrate
We built a tool to help automate migrating to the new CLI toolchain! Migrating can be done by running the following commands and following the prompts:
1$ npx @percy/migrate 2? Are you currently using @percy/selenium-webdriver (@percy/seleniumjs)? Yes 3? Install @percy/cli (required to run percy)? Yes 4? Migrate Percy config file? Yes 5? Upgrade SDK to @percy/selenium-webdriver@1.0.0? Yes
This will automatically run the changes described below for you.
Manually
Uninstalling @percy/seleniumjs
If you're coming from the @percy/seleniumjs
package, make sure to uninstall that package first
before installing this one.
1$ npm uninstall @percy/seleniumjs
Now you can safely install @percy/selenium-webdriver
and @percy/cli
.
Installing @percy/cli
If you're coming from a pre-1.0 version of this package, make sure to install @percy/cli
after
upgrading to retain any existing scripts that reference the Percy CLI command.
1$ npm install --save-dev @percy/cli
Migrating Config
If you have a previous Percy configuration file, migrate it to the newest version with the
config:migrate
command:
1$ percy config:migrate
Running Percy on Automate
percyScreenshot(driver, name, options)
[ needs @percy/cli 1.27.0-beta.0+ ];
This is an example test using the percyScreenshot
method.
1const { Builder } = require('selenium-webdriver'); 2const { percyScreenshot } = require('@percy/selenium-webdriver'); // both for selenium-webdriver/wdio 3 4(async function example() { 5const driver = new webdriver.Builder().usingServer('https://hub-cloud.browserstack.com/wd/hub').withCapabilities(capabilities).build(); // pass automate capabilities 6 7 try { 8 await driver.get('http://google.com/'); 9 await percyScreenshot(driver, 'Screenshot 1'); 10 11 await driver.get('http://example.com/'); 12 await percyScreenshot(driver, 'Screenshot 2'); 13 } finally { 14 await driver.quit(); 15 } 16})();
driver
(required) - A Selenium driver instancename
(required) - The screenshot name; must be unique to each screenshotoptions
(optional) - There are various options supported by percyScreenshot to server further functionality.sync
- Boolean value by default it falls back tofalse
, Gives the processed result around screenshot [From CLI v1.28.0-beta.0+]fullPage
- Boolean value by default it falls back tofalse
, Takes full page screenshot [From CLI v1.27.6+]freezeAnimatedImage
- Boolean value by default it falls back tofalse
, you can passtrue
and percy will freeze image based animations.freezeImageBySelectors
- List of selectors. Images will be freezed which are passed using selectors. For this to workfreezeAnimatedImage
must be set to true.freezeImageByXpaths
- List of xpaths. Images will be freezed which are passed using xpaths. For this to workfreezeAnimatedImage
must be set to true.percyCSS
- Custom CSS to be added to DOM before the screenshot being taken. Note: This gets removed once the screenshot is taken.ignoreRegionXpaths
- List of xpaths. elements in the DOM can be ignored using xpathignoreRegionSelectors
- List of selectors. elements in the DOM can be ignored using selectors.ignoreRegionSeleniumElements
- List of selenium web-element. elements can be ignored using selenium_elements.customIgnoreRegions
- List of custom objects. elements can be ignored using custom boundaries. Just passing a simple object for it like below.- example:
{top: 10, right: 10, bottom: 120, left: 10}
- In above example it will draw rectangle of ignore region as per given coordinates.
top
(int): Top coordinate of the ignore region.bottom
(int): Bottom coordinate of the ignore region.left
(int): Left coordinate of the ignore region.right
(int): Right coordinate of the ignore region.
- example:
considerRegionXpaths
- List of xpaths. elements in the DOM can be considered for diffing and will be ignored by Intelli Ignore using xpaths.considerRegionSelectors
- List of selectors. elements in the DOM can be considered for diffing and will be ignored by Intelli Ignore using selectors.considerRegionSeleniumElements
- List of selenium web-element. elements can be considered for diffing and will be ignored by Intelli Ignore using selenium_elements.customConsiderRegions
- List of custom objects. elements can be considered for diffing and will be ignored by Intelli Ignore using custom boundaries- example:
{top: 10, right: 10, bottom: 120, left: 10}
- In above example it will draw rectangle of consider region will be drawn.
- Parameters:
top
(int): Top coordinate of the consider region.bottom
(int): Bottom coordinate of the consider region.left
(int): Left coordinate of the consider region.right
(int): Right coordinate of the consider region.
- example:
Creating Percy on automate build
Note: Automate Percy Token starts with auto
keyword. The command can be triggered using exec
keyword.
1$ export PERCY_TOKEN=[your-project-token] 2$ percy exec -- [js test command] 3[percy] Percy has started! 4[percy] [Javascript example] : Starting automate screenshot ... 5[percy] Screenshot taken "Javascript example" 6[percy] Stopping percy... 7[percy] Finalized build #1: https://percy.io/[your-project] 8[percy] Done!
Refer to docs here: Percy on Automate
No vulnerabilities found.
Reason
14 commit(s) and 0 issue activity found in the last 90 days -- score normalized to 10
Reason
no dangerous workflow patterns detected
Reason
no binaries found in the repo
Reason
license file detected
Details
- Info: project has a license file: LICENSE:0
- Info: FSF or OSI recognized license: MIT License: LICENSE:0
Reason
packaging workflow detected
Details
- Info: Project packages its releases by way of GitHub Actions.: .github/workflows/release.yml:6
Reason
Found 24/25 approved changesets -- score normalized to 9
Reason
SAST tool is not run on all commits -- score normalized to 8
Details
- Warn: 25 commits out of 30 are checked with a SAST tool
Reason
8 existing vulnerabilities detected
Details
- Warn: Project is vulnerable to: GHSA-67hx-6x53-jw92
- Warn: Project is vulnerable to: GHSA-grv7-fg5c-xmjg
- Warn: Project is vulnerable to: GHSA-rc47-6667-2j5j
- Warn: Project is vulnerable to: GHSA-9c47-m6qq-7p4h
- Warn: Project is vulnerable to: GHSA-952p-6rrq-rcjv
- Warn: Project is vulnerable to: GHSA-f5x3-32g6-xq36
- Warn: Project is vulnerable to: GHSA-3h5v-q93c-6h6q
- Warn: Project is vulnerable to: GHSA-f9xv-q969-pqx4
Reason
dependency not pinned by hash detected -- score normalized to 0
Details
- Warn: third-party GitHubAction not pinned by hash: .github/workflows/changelog.yml:9: update your workflow using https://app.stepsecurity.io/secureworkflow/percy/percy-selenium-js/changelog.yml/master?enable=pin
- Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/lint.yml:8: update your workflow using https://app.stepsecurity.io/secureworkflow/percy/percy-selenium-js/lint.yml/master?enable=pin
- Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/lint.yml:9: update your workflow using https://app.stepsecurity.io/secureworkflow/percy/percy-selenium-js/lint.yml/master?enable=pin
- Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/lint.yml:15: update your workflow using https://app.stepsecurity.io/secureworkflow/percy/percy-selenium-js/lint.yml/master?enable=pin
- Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/release.yml:9: update your workflow using https://app.stepsecurity.io/secureworkflow/percy/percy-selenium-js/release.yml/master?enable=pin
- Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/release.yml:10: update your workflow using https://app.stepsecurity.io/secureworkflow/percy/percy-selenium-js/release.yml/master?enable=pin
- Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/stale.yml:10: update your workflow using https://app.stepsecurity.io/secureworkflow/percy/percy-selenium-js/stale.yml/master?enable=pin
- Warn: third-party GitHubAction not pinned by hash: .github/workflows/test.yml:19: update your workflow using https://app.stepsecurity.io/secureworkflow/percy/percy-selenium-js/test.yml/master?enable=pin
- Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/test.yml:28: update your workflow using https://app.stepsecurity.io/secureworkflow/percy/percy-selenium-js/test.yml/master?enable=pin
- Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/test.yml:29: update your workflow using https://app.stepsecurity.io/secureworkflow/percy/percy-selenium-js/test.yml/master?enable=pin
- Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/test.yml:35: update your workflow using https://app.stepsecurity.io/secureworkflow/percy/percy-selenium-js/test.yml/master?enable=pin
- Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/typecheck.yml:8: update your workflow using https://app.stepsecurity.io/secureworkflow/percy/percy-selenium-js/typecheck.yml/master?enable=pin
- Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/typecheck.yml:9: update your workflow using https://app.stepsecurity.io/secureworkflow/percy/percy-selenium-js/typecheck.yml/master?enable=pin
- Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/typecheck.yml:15: update your workflow using https://app.stepsecurity.io/secureworkflow/percy/percy-selenium-js/typecheck.yml/master?enable=pin
- Info: 2 out of 14 GitHub-owned GitHubAction dependencies pinned
- Info: 0 out of 2 third-party GitHubAction dependencies pinned
Reason
detected GitHub workflow tokens with excessive permissions
Details
- Info: jobLevel 'contents' permission set to 'read': .github/workflows/Semgrep.yml:22
- Info: topLevel 'contents' permission set to 'read': .github/workflows/Semgrep.yml:16
- Warn: no topLevel permission defined: .github/workflows/changelog.yml:1
- Warn: no topLevel permission defined: .github/workflows/lint.yml:1
- Warn: no topLevel permission defined: .github/workflows/release.yml:1
- Warn: no topLevel permission defined: .github/workflows/stale.yml:1
- Warn: no topLevel permission defined: .github/workflows/test.yml:1
- Warn: no topLevel permission defined: .github/workflows/typecheck.yml:1
- Info: no jobLevel write permissions found
Reason
no effort to earn an OpenSSF best practices badge detected
Reason
security policy file not detected
Details
- Warn: no security policy file detected
- Warn: no security file to analyze
- Warn: no security file to analyze
- Warn: no security file to analyze
Reason
project is not fuzzed
Details
- Warn: no fuzzer integrations found
Score
5.8
/10
Last Scanned on 2024-12-16
The Open Source Security Foundation is a cross-industry collaboration to improve the security of open source software (OSS). The Scorecard provides security health metrics for open source projects.
Learn More