Covered in this doc
- Integrating Percy with your Selenium Ruby tests
- Installing and importing the
- Calling and configuring
@percy/cli (currently only available from NPM). This package does the heavy lifting & communication to our API:
npm install --save-dev @percy/cli
yarn add -D @percy/agent
Now install the
percy-selenium Ruby package:
$ gem install percy-selenium
Step 1: In order to start creating snapshots from your Selenium tests, you'll need to import the
Percy.snapshot function from the
percy package into your test.
# At the top of your test file(s) OR the top of your test helper file require 'percy'
Step 2: You can now incorporate visual tests in your existing suite:
require 'percy' driver = Selenium::WebDriver.for :firefox driver.navigate.to "https://example.com" # Take a snapshot Percy.snapshot(driver, 'homepage') driver.quit
Step 3: Finally, wrap your test runner command in the
percy exec command. This will start a local Percy server to receive snapshots from your Ruby Selenium tests. From there the snapshots are processed and uploaded to your Percy dashboard. An example might be:
percy exec -- bundle exec rspec.
Before you can successfully run Percy, the
PERCY_TOKEN environment variable must be set:
set PERCY_TOKEN=[your-projects-token] # Powershell $Env:PERCY_TOKEN="[your-projects-token]"
Now you can run
percy exec. For example:
percy exec -- bundle exec rspec
Note the double dash,
percy exec and your test run command.
That's it! Now, whenever you run your tests with Percy, a snapshot of the app in that state will be uploaded to Percy for visual regression testing!
Percy.snapshot(driver, name[, options])
driver(required) - A selenium-webdriver driver instance
name(required) - The snapshot name; must be unique to each snapshot
options- See per-snapshot configuration options
You can also configure Percy to use the same options over all snapshots. To see supported configuration read our configuration docs
Updated over 1 year ago