# percy-selenium-python
![Test](https://github.com/percy/percy-python-selenium/workflows/Test/badge.svg)
[Percy](https://percy.io) visual testing for Python Selenium.
## Installation
npm install `@percy/cli`:
```sh-session
$ npm install --save-dev @percy/cli
```
pip install Percy selenium package:
```ssh-session
$ pip install percy-selenium
```
## Usage
This is an example test using the `percy_snapshot` function.
``` python
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:
```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 -- [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`](https://github.com/percy/cli/tree/master/packages/cli-config#percy-configmigrate-filepath-output) command:
```sh-session
$ percy config:migrate
```
Raw data
{
"_id": null,
"home_page": "https://github.com/percy/percy-selenium-python",
"name": "percy-python-selenium",
"maintainer": "",
"docs_url": null,
"requires_python": ">=3.6",
"maintainer_email": "",
"keywords": "selenium percy visual testing",
"author": "Perceptual Inc.",
"author_email": "team@percy.io",
"download_url": "https://files.pythonhosted.org/packages/0f/6f/96745634ec04a48801bf49cba166696b39f239a03caab1743c501ccc6131/percy-python-selenium-1.0.0.tar.gz",
"platform": "",
"description": "# percy-selenium-python\n![Test](https://github.com/percy/percy-python-selenium/workflows/Test/badge.svg)\n\n[Percy](https://percy.io) visual testing for Python Selenium.\n\n## Installation\n\nnpm install `@percy/cli`:\n\n```sh-session\n$ npm install --save-dev @percy/cli\n```\n\npip install Percy selenium package:\n\n```ssh-session\n$ pip install percy-selenium\n```\n\n## Usage\n\nThis is an example test using the `percy_snapshot` function.\n\n``` python\nfrom percy import percy_snapshot\n\nbrowser = webdriver.Firefox()\nbrowser.get('http://example.com')\n\u200b\n# take a snapshot\npercy_snapshot(browser, 'Python example')\n```\n\nRunning the test above normally will result in the following log:\n\n```sh-session\n[percy] Percy is not running, disabling snapshots\n```\n\nWhen running with [`percy\nexec`](https://github.com/percy/cli/tree/master/packages/cli-exec#percy-exec), and your project's\n`PERCY_TOKEN`, a new Percy build will be created and snapshots will be uploaded to your project.\n\n```sh-session\n$ export PERCY_TOKEN=[your-project-token]\n$ percy exec -- [python test command]\n[percy] Percy has started!\n[percy] Created build #1: https://percy.io/[your-project]\n[percy] Snapshot taken \"Python example\"\n[percy] Stopping percy...\n[percy] Finalized build #1: https://percy.io/[your-project]\n[percy] Done!\n```\n\n## Configuration\n\n`percy_snapshot(driver, name[, **kwargs])`\n\n- `driver` (**required**) - A selenium-webdriver driver instance\n- `name` (**required**) - The snapshot name; must be unique to each snapshot\n- Additional snapshot options (overrides any project options) (`**kwargs**`):\n - `widths` - An array of widths to take screenshots at\n - `min_height` - The minimum viewport height to take screenshots at\n - `percy_css` - Percy specific CSS only applied in Percy's rendering environment\n - `request_headers` - Headers that should be used during asset discovery\n - `enable_javascript` - Enable JavaScript in Percy's rendering environment\n\n### Migrating Config\n\nIf you have a previous Percy configuration file, migrate it to the newest version with the\n[`config:migrate`](https://github.com/percy/cli/tree/master/packages/cli-config#percy-configmigrate-filepath-output) command:\n\n```sh-session\n$ percy config:migrate\n```\n\n\n",
"bugtrack_url": null,
"license": "MIT",
"summary": "Python client for visual testing with Percy",
"version": "1.0.0",
"project_urls": {
"Homepage": "https://github.com/percy/percy-selenium-python"
},
"split_keywords": [
"selenium",
"percy",
"visual",
"testing"
],
"urls": [
{
"comment_text": "",
"digests": {
"blake2b_256": "3381ea79b5b3c64fcfcea0be2416ce8b5b8c619a53dbd9a3ced587ce2bafb920",
"md5": "c8036a800ea99471435256f9ab560473",
"sha256": "4879c6145266aaecce6c5fa14de50bb578bfdff02beb85187e4180d110c6fa4c"
},
"downloads": -1,
"filename": "percy_python_selenium-1.0.0-py3-none-any.whl",
"has_sig": false,
"md5_digest": "c8036a800ea99471435256f9ab560473",
"packagetype": "bdist_wheel",
"python_version": "py3",
"requires_python": ">=3.6",
"size": 3175,
"upload_time": "2021-02-08T18:35:31",
"upload_time_iso_8601": "2021-02-08T18:35:31.314404Z",
"url": "https://files.pythonhosted.org/packages/33/81/ea79b5b3c64fcfcea0be2416ce8b5b8c619a53dbd9a3ced587ce2bafb920/percy_python_selenium-1.0.0-py3-none-any.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": "",
"digests": {
"blake2b_256": "0f6f96745634ec04a48801bf49cba166696b39f239a03caab1743c501ccc6131",
"md5": "f93a83eb4403185b25cd16cd9b305715",
"sha256": "d50975cc7d923b7ce470f7f56f8d3ebcb33cb4a2d53f865ccd9c65d207a77252"
},
"downloads": -1,
"filename": "percy-python-selenium-1.0.0.tar.gz",
"has_sig": false,
"md5_digest": "f93a83eb4403185b25cd16cd9b305715",
"packagetype": "sdist",
"python_version": "source",
"requires_python": ">=3.6",
"size": 2673,
"upload_time": "2021-02-08T18:35:32",
"upload_time_iso_8601": "2021-02-08T18:35:32.517824Z",
"url": "https://files.pythonhosted.org/packages/0f/6f/96745634ec04a48801bf49cba166696b39f239a03caab1743c501ccc6131/percy-python-selenium-1.0.0.tar.gz",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2021-02-08 18:35:32",
"github": true,
"gitlab": false,
"bitbucket": false,
"codeberg": false,
"github_user": "percy",
"github_project": "percy-selenium-python",
"travis_ci": false,
"coveralls": false,
"github_actions": true,
"requirements": [
{
"name": "selenium",
"specs": [
[
">=",
"3"
]
]
},
{
"name": "requests",
"specs": [
[
"==",
"2.*"
]
]
}
],
"lcname": "percy-python-selenium"
}