Python client for visual testing with Percy for mobile apps
Project description
percy-appium-python
Percy visual testing for Python Appium.
Installation
npm install @percy/cli
:
$ npm install --save-dev @percy/cli
pip install Percy appium package:
$ pip install percy-appium-app
Note: This package is tested on Python versions 3.6, 3.8, 3.9 as part of unit tests. It should ideally work on all Python 3.6+ versions
[NOTE] Appium-Python-Client(>= v2.9.0) is having compatibility issues with urllib3 latest versions. To solve the issue it is recommended to add urllib3>=1.26.15,<2
in your requirements.txt file.
Usage
This is an example test using the percy_screenshot
function.
from appium import webdriver
from percy import percy_screenshot
driver = webdriver.Remote("https://" + userName + ":" + accessKey + "@hub-cloud.browserstack.com/wd/hub", desired_caps)
# take a screenshot
percy_screenshot(driver, 'here is some name')
Running the test above normally will result in the following log:
[percy] Percy is not running, disabling screenshots
When running with percy app:exec
, and your project's
PERCY_TOKEN
, a new Percy build will be created and screenshots will be uploaded to your project.
$ export PERCY_TOKEN=[your-project-token]
$ percy app:exec -- [python test command]
[percy] Percy has started!
[percy] Created build #1: https://percy.io/[your-project]
[percy] Screenshot taken "Python example"
[percy] Stopping percy...
[percy] Finalized build #1: https://percy.io/[your-project]
[percy] Done!
Configuration
percy_screenshot(driver, name[, **kwargs])
driver
(required) - A appium driver instancename
(required) - The screenshot name; must be unique to each screenshotdevice_name
(optional) - The device name used for capturing screenshotorientation
(optional) - Orientation of device while capturing screeenshot; Allowed values [portrait
|landscape
]status_bar_height
(optional) - Height of status bar; intnav_bar_height
(optional) - Height of navigation bar; intfull_screen
(optional) - Indicate whether app is full screen; booleanfullpage
(optional) - [Experimental] only supported on App Automate driver sessions [ needs @percy/cli 1.20.2+ ]; booleanscreen_lengths
(optional) - [Experimental] max screen lengths for fullPage [ needs @percy/cli 1.20.2+ ]; booleanscrollable_xpath
(optional) - [Experimental] scrollable element xpath for fullpage [ needs @percy/cli 1.20.2+ ]; stringscrollable_id
(optional) - [Experimental] scrollable element accessibility id for fullpage [ needs @percy/cli 1.20.2+ ]; stringignore_regions_xpaths
(optional) - elements xpaths that user want to ignore in visual diff [ needs @percy/cli 1.23.0+ ]; list of stringignore_region_accessibility_ids
(optional) - elements accessibility_ids that user want to ignore in visual diff [ needs @percy/cli 1.23.0+ ]; list of stringignore_region_appium_elements
(optional) - appium elements that user want to ignore in visual diff [ needs @percy/cli 1.23.0+ ]; list of appium element objectcustom_ignore_regions
(optional) - custom locations that user want to ignore in visual diff [ needs @percy/cli 1.23.0+ ]; list of ignore_region object- IgnoreRegion:-
-
Description: This class represents a rectangular area on a screen that needs to be ignored for visual diff.
-
Constructor:
init(self, top, bottom, left, right)
-
Parameters:
top
(int): Top coordinate of the ignore region.bottom
(int): Bottom coordinate of the ignore region.left
(int): Left coordinate of the ignore region.right
(int): Right coordinate of the ignore region. -
Raises:ValueError: If top, bottom, left, or right is less than 0 or top is greater than or equal to bottom or left is greater than or equal to right.
-
valid: Ignore region should be within the boundaries of the screen.
-
- IgnoreRegion:-
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
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Hashes for percy_appium_app-1.2.2-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 727ca7cac7ceca29a1fd284306d172da9b053597f2ca1ccbcc0d1d1d594aaec3 |
|
MD5 | b3cbe2c1bce09b247d093f9fc4ee46ac |
|
BLAKE2b-256 | 9cd9b9662614c48976adf0fb3a4b366c57fc77df0e7d1d2910d1882f74905fd3 |