percy-appium-app


Namepercy-appium-app JSON
Version 2.0.5 PyPI version JSON
download
home_pagehttps://github.com/percy/percy-appium-python
SummaryPython client for visual testing with Percy for mobile apps
upload_time2024-03-29 03:42:53
maintainerNone
docs_urlNone
authorPerceptual Inc.
requires_python>=3.6
licenseMIT
keywords appium percy visual testing
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            # percy-appium-python
[![PyPI version](https://badge.fury.io/py/percy-appium-app.svg)](https://pypi.org/project/percy-appium-app/)
![Test](https://github.com/percy/percy-appium-python/workflows/Test/badge.svg)

[Percy](https://percy.io) visual testing for Python Appium.

## Installation

npm install `@percy/cli`:

```sh-session
$ npm install --save-dev @percy/cli
```

pip install Percy appium package:

```ssh-session
$ 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.

``` python
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:

```sh-session
[percy] Percy is not running, disabling screenshots
```

When running with [`percy
app:exec`](https://github.com/percy/cli/tree/master/packages/cli-exec#app-exec), and your project's
`PERCY_TOKEN`, a new Percy build will be created and screenshots will be uploaded to your project.

```sh-session
$ 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 instance
- `name` (**required**) - The screenshot name; must be unique to each screenshot
- `device_name` (**optional**) - The device name used for capturing screenshot
- `orientation` (**optional**) - Orientation of device while capturing screeenshot; Allowed values [`portrait` | `landscape`]
- `status_bar_height` (**optional**) - Height of status bar; int
- `nav_bar_height` (**optional**) - Height of navigation bar; int
- `sync` - Boolean value by default it falls back to `false`, Gives the processed result around screenshot [From CLI v1.28.0-beta.0+]
- `fullpage` (**optional**) - [Alpha] Only supported on App Automate driver sessions [ needs @percy/cli 1.20.2+ ]; boolean
  - `screen_lengths` (**optional**) - [Alpha] Max screen lengths for fullPage; int
  - In case scrollview is overlapping with other app elements. Offsets can be provided to reduce the area which needs to be considered for scrolling:
    - `top_scrollview_offset`: (**optional**) - [Alpha] Offset from top of scrollview; int
    - `bottom_scrollview_offset` (**optional**) - [Alpha] Offset from bottom of scrollview; int
- `full_screen` (**optional**) - Indicate whether app is full screen; boolean [ needs @percy/cli 1.20.2+ ];
- `scrollable_xpath` (**optional**) - [Alpha] Scrollable element xpath for fullpage [ needs @percy/cli 1.20.2+ ]; string
- `scrollable_id` (**optional**) - [Alpha] Scrollable element accessibility id for fullpage [ needs @percy/cli 1.20.2+ ]; string
- `ignore_regions_xpaths` (**optional**) - Elements xpaths that user want to ignore in visual diff [ needs @percy/cli 1.23.0+ ]; list of string
- `ignore_region_accessibility_ids` (**optional**) - Elements accessibility_ids that user want to ignore in visual diff [ needs @percy/cli 1.23.0+ ]; list of string
- `ignore_region_appium_elements` (**optional**) - Appium elements that user want to ignore in visual diff [ needs @percy/cli 1.23.0+ ]; list of appium element object
- `custom_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.

## Running with Hybrid Apps

For a hybrid app, we need to switch to native context before taking screenshot.

- Add a helper method similar to following for say flutter based hybrid app:
```python
def percy_screenshot_flutter(driver, name: str, **kwargs):
  driver.switch_to.context('NATIVE_APP')
  percy_screenshot(driver, name, **kwargs)
  driver.switch_to.context('FLUTTER')
```

- Call PercyScreenshotFlutter helper function when you want to take screenshot.
```python
percy_screenshot_flutter(driver, name, **kwargs)
```

> Note: 
>
> For other hybrid apps the `driver.switch_to.context('FLUTTER')` would change to context that it uses like say WEBVIEW etc.
>

## Running Percy on Automate
`percy_screenshot(driver, name, options)` [ needs @percy/cli 1.27.0-beta.0+ ];
- `driver` (**required**) - A appium driver instance
- `name` (**required**) - The screenshot name; must be unique to each screenshot
- `options` (**optional**) - There are various options supported by percy_screenshot to server further functionality.
    - `freeze_animated_image` - Boolean value by default it falls back to `false`, you can pass `true` and percy will freeze image based animations.
    - `freeze_image_by_selectors` -List of selectors. Images will be freezed which are passed using selectors. For this to work `freeze_animated_image` must be set to true.
    - `freeze_image_by_xpaths` - List of xpaths. Images will be freezed which are passed using xpaths. For this to work `freeze_animated_image` must be set to true.
    - `percy_css` - Custom CSS to be added to DOM before the screenshot being taken. Note: This gets removed once the screenshot is taken.
    - `ignore_region_xpaths` - List of xpaths. elements in the DOM can be ignored using xpath
    - `ignore_region_selectors` - List of selectors. elements in the DOM can be ignored using selectors.
    - `ignore_region_appium_elements` - List of appium web-element. elements can be ignored using appium_elements.
    - `custom_ignore_regions` -  List of custom objects. elements can be ignored using custom boundaries. Just passing a simple object for it like below.
      - example: ```{"top": 10, "right": 10, "bottom": 120, "left": 10}```
      - In above example it will draw rectangle of ignore region as per given coordinates.
          - `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.
    - `consider_region_xpaths` - List of xpaths. elements in the DOM can be considered for diffing and will be ignored by Intelli Ignore using xpaths.
    - `consider_region_selectors` - List of selectors. elements in the DOM can be considered for diffing and will be ignored by Intelli Ignore using selectors.
    - `consider_region_appium_elements` - List of appium web-element. elements can be considered for diffing and will be ignored by Intelli Ignore using appium_elements.
    - `custom_consider_regions` - List of custom objects. elements can be considered for diffing and will be ignored by Intelli Ignore using custom boundaries
      - example:```{"top": 10, "right": 10, "bottom": 120, "left": 10}```
      - In above example it will draw rectangle of consider region will be drawn.
      - Parameters:
        - `top` (int): Top coordinate of the consider region.
        - `bottom` (int): Bottom coordinate of the consider region.
        - `left` (int): Left coordinate of the consider region.
        - `right` (int): Right coordinate of the consider region.

### Creating Percy on automate build
Note: Automate Percy Token starts with `auto` keyword. The command can be triggered using `exec` keyword.

```sh-session
$ export PERCY_TOKEN=[your-project-token]
$ percy exec -- [python test command]
[percy] Percy has started!
[percy] [Python example] : Starting automate screenshot ...
[percy] Screenshot taken "Python example"
[percy] Stopping percy...
[percy] Finalized build #1: https://percy.io/[your-project]
[percy] Done!
```

Refer to docs here: [Percy on Automate](https://docs.percy.io/docs/integrate-functional-testing-with-visual-testing)

### 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-appium-python",
    "name": "percy-appium-app",
    "maintainer": null,
    "docs_url": null,
    "requires_python": ">=3.6",
    "maintainer_email": null,
    "keywords": "appium percy visual testing",
    "author": "Perceptual Inc.",
    "author_email": "team@percy.io",
    "download_url": "https://files.pythonhosted.org/packages/e2/86/ebd5f9017e6b302ec74ea8454903ebfb8528029b625f57b0109038147428/percy-appium-app-2.0.5.tar.gz",
    "platform": null,
    "description": "# percy-appium-python\n[![PyPI version](https://badge.fury.io/py/percy-appium-app.svg)](https://pypi.org/project/percy-appium-app/)\n![Test](https://github.com/percy/percy-appium-python/workflows/Test/badge.svg)\n\n[Percy](https://percy.io) visual testing for Python Appium.\n\n## Installation\n\nnpm install `@percy/cli`:\n\n```sh-session\n$ npm install --save-dev @percy/cli\n```\n\npip install Percy appium package:\n\n```ssh-session\n$ pip install percy-appium-app\n```\n> 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\n\n[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.\n\n## Usage\n\nThis is an example test using the `percy_screenshot` function.\n\n``` python\nfrom appium import webdriver\nfrom percy import percy_screenshot\n\ndriver = webdriver.Remote(\"https://\" + userName + \":\" + accessKey + \"@hub-cloud.browserstack.com/wd/hub\", desired_caps)\n\n# take a screenshot\npercy_screenshot(driver, 'here is some name')\n```\n\nRunning the test above normally will result in the following log:\n\n```sh-session\n[percy] Percy is not running, disabling screenshots\n```\n\nWhen running with [`percy\napp:exec`](https://github.com/percy/cli/tree/master/packages/cli-exec#app-exec), and your project's\n`PERCY_TOKEN`, a new Percy build will be created and screenshots will be uploaded to your project.\n\n```sh-session\n$ export PERCY_TOKEN=[your-project-token]\n$ percy app:exec -- [python test command]\n[percy] Percy has started!\n[percy] Created build #1: https://percy.io/[your-project]\n[percy] Screenshot 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_screenshot(driver, name[, **kwargs])`\n\n- `driver` (**required**) - A appium driver instance\n- `name` (**required**) - The screenshot name; must be unique to each screenshot\n- `device_name` (**optional**) - The device name used for capturing screenshot\n- `orientation` (**optional**) - Orientation of device while capturing screeenshot; Allowed values [`portrait` | `landscape`]\n- `status_bar_height` (**optional**) - Height of status bar; int\n- `nav_bar_height` (**optional**) - Height of navigation bar; int\n- `sync` - Boolean value by default it falls back to `false`, Gives the processed result around screenshot [From CLI v1.28.0-beta.0+]\n- `fullpage` (**optional**) - [Alpha] Only supported on App Automate driver sessions [ needs @percy/cli 1.20.2+ ]; boolean\n  - `screen_lengths` (**optional**) - [Alpha] Max screen lengths for fullPage; int\n  - In case scrollview is overlapping with other app elements. Offsets can be provided to reduce the area which needs to be considered for scrolling:\n    - `top_scrollview_offset`: (**optional**) - [Alpha] Offset from top of scrollview; int\n    - `bottom_scrollview_offset` (**optional**) - [Alpha] Offset from bottom of scrollview; int\n- `full_screen` (**optional**) - Indicate whether app is full screen; boolean [ needs @percy/cli 1.20.2+ ];\n- `scrollable_xpath` (**optional**) - [Alpha] Scrollable element xpath for fullpage [ needs @percy/cli 1.20.2+ ]; string\n- `scrollable_id` (**optional**) - [Alpha] Scrollable element accessibility id for fullpage [ needs @percy/cli 1.20.2+ ]; string\n- `ignore_regions_xpaths` (**optional**) - Elements xpaths that user want to ignore in visual diff [ needs @percy/cli 1.23.0+ ]; list of string\n- `ignore_region_accessibility_ids` (**optional**) - Elements accessibility_ids that user want to ignore in visual diff [ needs @percy/cli 1.23.0+ ]; list of string\n- `ignore_region_appium_elements` (**optional**) - Appium elements that user want to ignore in visual diff [ needs @percy/cli 1.23.0+ ]; list of appium element object\n- `custom_ignore_regions` (**optional**) - Custom locations that user want to ignore in visual diff [ needs @percy/cli 1.23.0+ ]; list of ignore_region object\n  - IgnoreRegion:-\n    - Description: This class represents a rectangular area on a screen that needs to be ignored for visual diff.\n    - Constructor:\n      ```\n      init(self, top, bottom, left, right)\n      ```\n    - Parameters:\n      - `top` (int): Top coordinate of the ignore region.\n      - `bottom` (int): Bottom coordinate of the ignore region.\n      - `left` (int): Left coordinate of the ignore region.\n      - `right` (int): Right coordinate of the ignore region.\n\n## Running with Hybrid Apps\n\nFor a hybrid app, we need to switch to native context before taking screenshot.\n\n- Add a helper method similar to following for say flutter based hybrid app:\n```python\ndef percy_screenshot_flutter(driver, name: str, **kwargs):\n  driver.switch_to.context('NATIVE_APP')\n  percy_screenshot(driver, name, **kwargs)\n  driver.switch_to.context('FLUTTER')\n```\n\n- Call PercyScreenshotFlutter helper function when you want to take screenshot.\n```python\npercy_screenshot_flutter(driver, name, **kwargs)\n```\n\n> Note: \n>\n> For other hybrid apps the `driver.switch_to.context('FLUTTER')` would change to context that it uses like say WEBVIEW etc.\n>\n\n## Running Percy on Automate\n`percy_screenshot(driver, name, options)` [ needs @percy/cli 1.27.0-beta.0+ ];\n- `driver` (**required**) - A appium driver instance\n- `name` (**required**) - The screenshot name; must be unique to each screenshot\n- `options` (**optional**) - There are various options supported by percy_screenshot to server further functionality.\n    - `freeze_animated_image` - Boolean value by default it falls back to `false`, you can pass `true` and percy will freeze image based animations.\n    - `freeze_image_by_selectors` -List of selectors. Images will be freezed which are passed using selectors. For this to work `freeze_animated_image` must be set to true.\n    - `freeze_image_by_xpaths` - List of xpaths. Images will be freezed which are passed using xpaths. For this to work `freeze_animated_image` must be set to true.\n    - `percy_css` - Custom CSS to be added to DOM before the screenshot being taken. Note: This gets removed once the screenshot is taken.\n    - `ignore_region_xpaths` - List of xpaths. elements in the DOM can be ignored using xpath\n    - `ignore_region_selectors` - List of selectors. elements in the DOM can be ignored using selectors.\n    - `ignore_region_appium_elements` - List of appium web-element. elements can be ignored using appium_elements.\n    - `custom_ignore_regions` -  List of custom objects. elements can be ignored using custom boundaries. Just passing a simple object for it like below.\n      - example: ```{\"top\": 10, \"right\": 10, \"bottom\": 120, \"left\": 10}```\n      - In above example it will draw rectangle of ignore region as per given coordinates.\n          - `top` (int): Top coordinate of the ignore region.\n          - `bottom` (int): Bottom coordinate of the ignore region.\n          - `left` (int): Left coordinate of the ignore region.\n          - `right` (int): Right coordinate of the ignore region.\n    - `consider_region_xpaths` - List of xpaths. elements in the DOM can be considered for diffing and will be ignored by Intelli Ignore using xpaths.\n    - `consider_region_selectors` - List of selectors. elements in the DOM can be considered for diffing and will be ignored by Intelli Ignore using selectors.\n    - `consider_region_appium_elements` - List of appium web-element. elements can be considered for diffing and will be ignored by Intelli Ignore using appium_elements.\n    - `custom_consider_regions` - List of custom objects. elements can be considered for diffing and will be ignored by Intelli Ignore using custom boundaries\n      - example:```{\"top\": 10, \"right\": 10, \"bottom\": 120, \"left\": 10}```\n      - In above example it will draw rectangle of consider region will be drawn.\n      - Parameters:\n        - `top` (int): Top coordinate of the consider region.\n        - `bottom` (int): Bottom coordinate of the consider region.\n        - `left` (int): Left coordinate of the consider region.\n        - `right` (int): Right coordinate of the consider region.\n\n### Creating Percy on automate build\nNote: Automate Percy Token starts with `auto` keyword. The command can be triggered using `exec` keyword.\n\n```sh-session\n$ export PERCY_TOKEN=[your-project-token]\n$ percy exec -- [python test command]\n[percy] Percy has started!\n[percy] [Python example] : Starting automate screenshot ...\n[percy] Screenshot taken \"Python example\"\n[percy] Stopping percy...\n[percy] Finalized build #1: https://percy.io/[your-project]\n[percy] Done!\n```\n\nRefer to docs here: [Percy on Automate](https://docs.percy.io/docs/integrate-functional-testing-with-visual-testing)\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",
    "bugtrack_url": null,
    "license": "MIT",
    "summary": "Python client for visual testing with Percy for mobile apps",
    "version": "2.0.5",
    "project_urls": {
        "Homepage": "https://github.com/percy/percy-appium-python"
    },
    "split_keywords": [
        "appium",
        "percy",
        "visual",
        "testing"
    ],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "51d85239c6b70bdda87d3e302e85dfb075f8b10f6f03cc71bd8243163a2da28f",
                "md5": "e320a4c65133dd9297e95d427335b041",
                "sha256": "63bde8351c8ea2d4e3057d5fcc2134a7228725ca761d8b9610ea5a857b021973"
            },
            "downloads": -1,
            "filename": "percy_appium_app-2.0.5-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "e320a4c65133dd9297e95d427335b041",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": ">=3.6",
            "size": 21803,
            "upload_time": "2024-03-29T03:42:51",
            "upload_time_iso_8601": "2024-03-29T03:42:51.693198Z",
            "url": "https://files.pythonhosted.org/packages/51/d8/5239c6b70bdda87d3e302e85dfb075f8b10f6f03cc71bd8243163a2da28f/percy_appium_app-2.0.5-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "e286ebd5f9017e6b302ec74ea8454903ebfb8528029b625f57b0109038147428",
                "md5": "0b7a22d643641ae0cb97b15241b53733",
                "sha256": "c7cf728b2500e1e69000248ab5505a96a4c1a768724d6dcbe08a8eaf6936471b"
            },
            "downloads": -1,
            "filename": "percy-appium-app-2.0.5.tar.gz",
            "has_sig": false,
            "md5_digest": "0b7a22d643641ae0cb97b15241b53733",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": ">=3.6",
            "size": 30035,
            "upload_time": "2024-03-29T03:42:53",
            "upload_time_iso_8601": "2024-03-29T03:42:53.040028Z",
            "url": "https://files.pythonhosted.org/packages/e2/86/ebd5f9017e6b302ec74ea8454903ebfb8528029b625f57b0109038147428/percy-appium-app-2.0.5.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2024-03-29 03:42:53",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "percy",
    "github_project": "percy-appium-python",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": true,
    "requirements": [],
    "lcname": "percy-appium-app"
}
        
Elapsed time: 0.22076s