https://github.com/percy/percy-selenium-ruby
Visual testing with Selenium Ruby and Percy
https://github.com/percy/percy-selenium-ruby
percy percy-sdk ruby-selenium screenshots testing visual-testing
Last synced: 4 months ago
JSON representation
Visual testing with Selenium Ruby and Percy
- Host: GitHub
- URL: https://github.com/percy/percy-selenium-ruby
- Owner: percy
- License: mit
- Created: 2021-04-06T21:54:31.000Z (almost 5 years ago)
- Default Branch: main
- Last Pushed: 2024-10-08T05:54:00.000Z (over 1 year ago)
- Last Synced: 2024-11-11T10:55:18.619Z (over 1 year ago)
- Topics: percy, percy-sdk, ruby-selenium, screenshots, testing, visual-testing
- Language: Ruby
- Homepage: https://docs.percy.io/docs/selenium-for-ruby
- Size: 32.2 KB
- Stars: 3
- Watchers: 9
- Forks: 0
- Open Issues: 2
-
Metadata Files:
- Readme: README.md
- License: LICENSE
- Codeowners: CODEOWNERS
Awesome Lists containing this project
README
# percy-selenium-ruby
[](https://badge.fury.io/rb/percy-selenium)

[Percy](https://percy.io) visual testing for Ruby Selenium.
## Installation
npm install `@percy/cli`:
```sh-session
$ npm install --save-dev @percy/cli
```
gem install Percy selenium package:
```ssh-session
$ gem install percy-selenium
```
## Usage
This is an example test using the `Percy.snapshot` method.
``` ruby
require 'percy'
driver = Selenium::WebDriver.for :firefox
driver.navigate.to "https://example.com"
# Take a snapshot
Percy.snapshot(driver, 'homepage')
driver.quit
```
Running the test above normally will result in the following log:
```sh-session
[percy] Percy is not running, disabling snapshots
```
When running with [`percy
exec`](https://github.com/percy/cli/tree/master/packages/cli-exec#percy-exec), and your project's
`PERCY_TOKEN`, a new Percy build will be created and snapshots will be uploaded to your project.
```sh-session
$ export PERCY_TOKEN=[your-project-token]
$ percy exec -- [ruby test command]
[percy] Percy has started!
[percy] Created build #1: https://percy.io/[your-project]
[percy] Snapshot taken "Ruby example"
[percy] Stopping percy...
[percy] Finalized build #1: https://percy.io/[your-project]
[percy] Done!
```
## Configuration
`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](https://www.browserstack.com/docs/percy/take-percy-snapshots/overview#per-snapshot-configuration)