Skip to main content

Python client for visual testing with Percy

Project description

percy-selenium-python

Test

Percy visual testing for Python Selenium.

Installation

npm install @percy/cli:

$ npm install --save-dev @percy/cli

pip install Percy selenium package:

$ pip install percy-selenium

Usage

This is an example test using the percy_snapshot function.

from percy import percy_snapshot

browser = webdriver.Firefox()
browser.get('http://example.com')

# take a snapshot
percy_snapshot(browser, 'Python example')

Running the test above normally will result in the following log:

[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.

$ export PERCY_TOKEN=[your-project-token]
$ percy exec -- [python test command]
[percy] Percy has started!
[percy] Created build #1: https://percy.io/[your-project]
[percy] Snapshot taken "Python example"
[percy] Stopping percy...
[percy] Finalized build #1: https://percy.io/[your-project]
[percy] Done!

Configuration

percy_snapshot(driver, name[, **kwargs])

  • driver (required) - A selenium-webdriver driver instance
  • name (required) - The snapshot name; must be unique to each snapshot
  • Additional snapshot options (overrides any project options) (**kwargs**):
    • widths - An array of widths to take screenshots at
    • min_height - The minimum viewport height to take screenshots at
    • percy_css - Percy specific CSS only applied in Percy's rendering environment
    • request_headers - Headers that should be used during asset discovery
    • enable_javascript - Enable JavaScript in Percy's rendering environment

Migrating Config

If you have a previous Percy configuration file, migrate it to the newest version with the config:migrate command:

$ percy config:migrate

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

percy-python-selenium-1.0.0.tar.gz (2.7 kB view hashes)

Uploaded source

Built Distribution

Supported by

AWS AWS Cloud computing Datadog Datadog Monitoring Facebook / Instagram Facebook / Instagram PSF Sponsor Fastly Fastly CDN Google Google Object Storage and Download Analytics Huawei Huawei PSF Sponsor Microsoft Microsoft PSF Sponsor NVIDIA NVIDIA PSF Sponsor Pingdom Pingdom Monitoring Salesforce Salesforce PSF Sponsor Sentry Sentry Error logging StatusPage StatusPage Status page