### [python-percy-client on Github](🔗)
[![Package Status](https://img.shields.io/pypi/v/percy.svg)](🔗) [![Build Status](https://travis-ci.org/percy/python-percy-client.svg?branch=master)](🔗)
Python client library for visual regression testing with [Percy](🔗) and Selenium tests.
This library is in beta---we welcome contributions to improve it.
Make sure you have completed [Setup](🔗) of your CI service first. You can also test Percy in your [local development](🔗) environment.
Requires Python >= 2.7.
The following assumes that `
webdriver` is a Selenium webdriver object of some sort (like `
webdriver.Chrome()`). Proper setup and teardown of Selenium tests is not included here.
First, create a `
ResourceLoader` object. This is the configuration for how Percy will discover your app's assets.
Now, create a `
percy.Runner` object and initialize a build. This must be done at the beginning of your entire test suite.
Then, at the end of your entire test suite, finalize the build (this needs to be run even if tests fail):
During Selenium tests, use `
percy_runner.snapshot()` in any test to capture the DOM state and send it to Percy for rendering and visual regression testing.
snapshot` also accepts a `
name` to uniquely identify it across builds:
Done! Now commit and push your branch to run your tests in your CI service, or create a GitHub PR.
## Responsive testing
Setup default responsive breakpoints for all snapshots:
These are the default responsive widths to be used on every snapshot. They can be overridden on a per-snapshot basis by passing the `
widths` arg to `
To temporarily disable Percy in CI, set the `
PERCY_ENABLE=0` environment variable.
See [Percy usage in the Sentry repository](🔗) for a complete example of Percy integrated in a large Django application and with `
Fork it ( <https://github.com/percy/python-percy-client/fork> )
Create your feature branch (`
git checkout -b my-new-feature`)
Commit your changes (`
git commit -am 'Add some feature'`)
Push to the branch (`
git push origin my-new-feature`)
Create a new Pull Request
[Throw a ★ on it!](🔗)