stf-appium-client


Namestf-appium-client JSON
Version 0.12.0 PyPI version JSON
download
home_pagehttps://github.com/OpenTMI/stf-appium-python-client
SummarySTF client with appium
upload_time2024-09-24 08:15:18
maintainerNone
docs_urlNone
authorJussi Vatjus-Anttila
requires_python>=3.7
licenseMIT
keywords devicefarmer stf appium pytest robot-framework lockable resource android
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage
            ## OpenSTF+Appium Client for test automation

[![Unit tests](https://github.com/OpenTMI/stf-appium-python-client/actions/workflows/test.yml/badge.svg)](https://github.com/OpenTMI/stf-appium-python-client/actions/workflows/test.yml)
[![Coverage Status](https://coveralls.io/repos/github/OpenTMI/stf-appium-python-client/badge.svg?branch=main&t=CQV17G)](https://coveralls.io/github/OpenTMI/stf-appium-python-client?branch=main)
[![PyPI version](https://badge.fury.io/py/stf-appium-client.svg)](https://badge.fury.io/py/stf-appium-client)

Library provides basic functionality for test automation which allows allocating
phone from [STF](https://github.com/DeviceFarmer/stf) server using [python stf-client](https://pypi.org/project/stf-client/), initialise adb connection to it and 
start [appium][https://github.com/appium/python-client] server for it.

Basic idea is to run tests against remote openstf device farm with minimum
requirements.


### Flow
```mermaid
sequenceDiagram
    participant C as User
    participant A as stf-appium-client
    participant B as STF(device)
    C->>A: allocation_context(requirements, wait_timeout, timeout, shuffle)
    A->>B: Find suitable device
    A->>B: allocate device
    A->>B: remoteConnect
    A->>B: ADB Connection
    A->>A: Start AppiumServer(ADB)
    A->>A: Start AppiumClient(AppiumServer)
    A->>C: AppiumClient(AppiumServer(ADB))
    C->>A: Run Appium Tests
```


### Getting Started

These instructions will get you a copy of the project up and running on your local machine for development and testing purposes. See deployment for notes on how to deploy the project on a live system.

### Prerequisites
* openstf server and access token 
* python >=3.8
* adb
* appium (`npm install appium`)
  Library expects that appium is located to PATH
  * appium 2 (`npm install appium@next`)
    * remember to install appium drivers, e.g. `appium driver install uiautomator2`
  * appium 1
  * note that appium server and client need to be compatible with each other!
    * see compatibility matrix from [python-client readme](https://github.com/appium/python-client?tab=readme-ov-file#compatibility-matrix)
  
### Installing

* `pip install stf-appium-client`
  
or for development purpose:

* `pip install -e .`

### Running the tests

`make test`

CI runs tests against following environments:

|      | ubuntu-latest | macos-latest | windows-latest |
|------| ------------- | ------------- | ------------- |
| 3.7  | ✓  | ✓  | ✓  |
| 3.8  | ✓  | ✓  | ✓  |
| 3.9  | ✓  | ✓  | ✓  |
| 3.10 | ✓  | ✓  | ✓  |
| 3.11 | ✓  | ✓  | ✓  |

### Deployment

This pip package could be installed together with test framework
and utilise using CLI interface or via python interface. 
See more usage examples below.

### usage

#### Python Library

```
client = StfClient(host=environ.get('STF_HOST'))
client.connect(token=environ.get('STF_TOKEN'))

with client.allocation_context(
        requirements=dict(version='10')) as device:
    print('phone is now allocated and remote connected')
    with AdbServer(device['remote_adb_url']) as adb_port:
        print('adb server started with port: {adb_port}')
            with AppiumServer() as appium:
                print("Phone is ready for test automation..")
                # appium is running and ready for usage
                with AppiumClient() as driver:
                   print(driver)
```

See examples from [examples](examples) -folder.

##### Logging

Library utilise python native logging module. Logger name is `StfAppiumClient`. 
By default it configure default console handler for logger with `INFO` level.
`STF_APPIUM_LOGGING` env variable can be used to use `DEBUG` logging level.
If any handlers for this logger is configured before `StfClient` instance 
creation no default handlers are added.

#### CLI

```shell script
stf --token 123456 --requirements "{\"version\": \"9\"}" "echo $DEV1_SERIAL"
```

Call robot framework
```shell script
stf --token 123456 --requirements "{\"version\": \"9\"}" "robot phone/suite" 
```


```shell script
$ stf --help
usage: stf [-h] --token TOKEN [--host HOST] [--requirements R] [--list]
           [command [command ...]]

STF client with appium.

Tool allocate phone, create adb and appium server and 
call user given command with generated env variables:
DEV1_ADB_PORT      ADB PORT that appium utilize.
DEV1_APPIUM_HOST   appium host where user given command can connect, e.g. robot framework
DEV1_SERIAL        device details..
DEV1_VERSION
DEV1_REQUIREMENTS  user given requirements
DEV1_INFO          phone details

Example: stf --token 123 -- echo \$DEV1_SERIAL


positional arguments:
  command           Command to be execute during device allocation

optional arguments:
  -h, --help          show this help message and exit
  --token TOKEN       openstf access token
  --host HOST         openstf host
  --list              list only requirements, filtered on given requirements
  --requirements R    requirements as json string
  --timeout t         allocation timeout
  --wait_timeout w    max wait time for suitable device allocation
  --verbose           appium logs to console. WARNING: this mix console prints
  --appium-logs file  appium logs to file

```

## License

This project is licensed under the MIT License - see the [LICENSE](LICENSE) file for details

            

Raw data

            {
    "_id": null,
    "home_page": "https://github.com/OpenTMI/stf-appium-python-client",
    "name": "stf-appium-client",
    "maintainer": null,
    "docs_url": null,
    "requires_python": ">=3.7",
    "maintainer_email": null,
    "keywords": "DeviceFarmer STF appium pytest robot-framework lockable resource android",
    "author": "Jussi Vatjus-Anttila",
    "author_email": "jussiva@gmail.com",
    "download_url": "https://files.pythonhosted.org/packages/01/75/76e679898b8d2c38676d04830a92f21ce2b11a6fd9fda3a9c1cfd928d4f4/stf_appium_client-0.12.0.tar.gz",
    "platform": null,
    "description": "## OpenSTF+Appium Client for test automation\n\n[![Unit tests](https://github.com/OpenTMI/stf-appium-python-client/actions/workflows/test.yml/badge.svg)](https://github.com/OpenTMI/stf-appium-python-client/actions/workflows/test.yml)\n[![Coverage Status](https://coveralls.io/repos/github/OpenTMI/stf-appium-python-client/badge.svg?branch=main&t=CQV17G)](https://coveralls.io/github/OpenTMI/stf-appium-python-client?branch=main)\n[![PyPI version](https://badge.fury.io/py/stf-appium-client.svg)](https://badge.fury.io/py/stf-appium-client)\n\nLibrary provides basic functionality for test automation which allows allocating\nphone from [STF](https://github.com/DeviceFarmer/stf) server using [python stf-client](https://pypi.org/project/stf-client/), initialise adb connection to it and \nstart [appium][https://github.com/appium/python-client] server for it.\n\nBasic idea is to run tests against remote openstf device farm with minimum\nrequirements.\n\n\n### Flow\n```mermaid\nsequenceDiagram\n    participant C as User\n    participant A as stf-appium-client\n    participant B as STF(device)\n    C->>A: allocation_context(requirements, wait_timeout, timeout, shuffle)\n    A->>B: Find suitable device\n    A->>B: allocate device\n    A->>B: remoteConnect\n    A->>B: ADB Connection\n    A->>A: Start AppiumServer(ADB)\n    A->>A: Start AppiumClient(AppiumServer)\n    A->>C: AppiumClient(AppiumServer(ADB))\n    C->>A: Run Appium Tests\n```\n\n\n### Getting Started\n\nThese instructions will get you a copy of the project up and running on your local machine for development and testing purposes. See deployment for notes on how to deploy the project on a live system.\n\n### Prerequisites\n* openstf server and access token \n* python >=3.8\n* adb\n* appium (`npm install appium`)\n  Library expects that appium is located to PATH\n  * appium 2 (`npm install appium@next`)\n    * remember to install appium drivers, e.g. `appium driver install uiautomator2`\n  * appium 1\n  * note that appium server and client need to be compatible with each other!\n    * see compatibility matrix from [python-client readme](https://github.com/appium/python-client?tab=readme-ov-file#compatibility-matrix)\n  \n### Installing\n\n* `pip install stf-appium-client`\n  \nor for development purpose:\n\n* `pip install -e .`\n\n### Running the tests\n\n`make test`\n\nCI runs tests against following environments:\n\n|      | ubuntu-latest | macos-latest | windows-latest |\n|------| ------------- | ------------- | ------------- |\n| 3.7  | \u2713  | \u2713  | \u2713  |\n| 3.8  | \u2713  | \u2713  | \u2713  |\n| 3.9  | \u2713  | \u2713  | \u2713  |\n| 3.10 | \u2713  | \u2713  | \u2713  |\n| 3.11 | \u2713  | \u2713  | \u2713  |\n\n### Deployment\n\nThis pip package could be installed together with test framework\nand utilise using CLI interface or via python interface. \nSee more usage examples below.\n\n### usage\n\n#### Python Library\n\n```\nclient = StfClient(host=environ.get('STF_HOST'))\nclient.connect(token=environ.get('STF_TOKEN'))\n\nwith client.allocation_context(\n        requirements=dict(version='10')) as device:\n    print('phone is now allocated and remote connected')\n    with AdbServer(device['remote_adb_url']) as adb_port:\n        print('adb server started with port: {adb_port}')\n            with AppiumServer() as appium:\n                print(\"Phone is ready for test automation..\")\n                # appium is running and ready for usage\n                with AppiumClient() as driver:\n                   print(driver)\n```\n\nSee examples from [examples](examples) -folder.\n\n##### Logging\n\nLibrary utilise python native logging module. Logger name is `StfAppiumClient`. \nBy default it configure default console handler for logger with `INFO` level.\n`STF_APPIUM_LOGGING` env variable can be used to use `DEBUG` logging level.\nIf any handlers for this logger is configured before `StfClient` instance \ncreation no default handlers are added.\n\n#### CLI\n\n```shell script\nstf --token 123456 --requirements \"{\\\"version\\\": \\\"9\\\"}\" \"echo $DEV1_SERIAL\"\n```\n\nCall robot framework\n```shell script\nstf --token 123456 --requirements \"{\\\"version\\\": \\\"9\\\"}\" \"robot phone/suite\" \n```\n\n\n```shell script\n$ stf --help\nusage: stf [-h] --token TOKEN [--host HOST] [--requirements R] [--list]\n           [command [command ...]]\n\nSTF client with appium.\n\nTool allocate phone, create adb and appium server and \ncall user given command with generated env variables:\nDEV1_ADB_PORT      ADB PORT that appium utilize.\nDEV1_APPIUM_HOST   appium host where user given command can connect, e.g. robot framework\nDEV1_SERIAL        device details..\nDEV1_VERSION\nDEV1_REQUIREMENTS  user given requirements\nDEV1_INFO          phone details\n\nExample: stf --token 123 -- echo \\$DEV1_SERIAL\n\n\npositional arguments:\n  command           Command to be execute during device allocation\n\noptional arguments:\n  -h, --help          show this help message and exit\n  --token TOKEN       openstf access token\n  --host HOST         openstf host\n  --list              list only requirements, filtered on given requirements\n  --requirements R    requirements as json string\n  --timeout t         allocation timeout\n  --wait_timeout w    max wait time for suitable device allocation\n  --verbose           appium logs to console. WARNING: this mix console prints\n  --appium-logs file  appium logs to file\n\n```\n\n## License\n\nThis project is licensed under the MIT License - see the [LICENSE](LICENSE) file for details\n",
    "bugtrack_url": null,
    "license": "MIT",
    "summary": "STF client with appium",
    "version": "0.12.0",
    "project_urls": {
        "Bug Reports": "https://github.com/OpenTMI/stf-appium-python-client/issues",
        "Homepage": "https://github.com/OpenTMI/stf-appium-python-client",
        "Source": "https://github.com/OpenTMI/stf-appium-python-client"
    },
    "split_keywords": [
        "devicefarmer",
        "stf",
        "appium",
        "pytest",
        "robot-framework",
        "lockable",
        "resource",
        "android"
    ],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "fc381de68c5453404ea9875ace68d9c3f537ec140cf45d1239687b98753fa030",
                "md5": "925011dfaa6324f4972c331059990840",
                "sha256": "db40a4041941f134e117bb112ad7077ea90575d1856a8efb5021a43b59ebe377"
            },
            "downloads": -1,
            "filename": "stf_appium_client-0.12.0-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "925011dfaa6324f4972c331059990840",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": ">=3.7",
            "size": 15013,
            "upload_time": "2024-09-24T08:15:18",
            "upload_time_iso_8601": "2024-09-24T08:15:18.019329Z",
            "url": "https://files.pythonhosted.org/packages/fc/38/1de68c5453404ea9875ace68d9c3f537ec140cf45d1239687b98753fa030/stf_appium_client-0.12.0-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "017576e679898b8d2c38676d04830a92f21ce2b11a6fd9fda3a9c1cfd928d4f4",
                "md5": "faaef9971f4978a766577a39ee8362d8",
                "sha256": "f38068b099a3be61102c776121bc3cc54a6ead338bf7dae51605e1f4016ae5f9"
            },
            "downloads": -1,
            "filename": "stf_appium_client-0.12.0.tar.gz",
            "has_sig": false,
            "md5_digest": "faaef9971f4978a766577a39ee8362d8",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": ">=3.7",
            "size": 26816,
            "upload_time": "2024-09-24T08:15:18",
            "upload_time_iso_8601": "2024-09-24T08:15:18.978125Z",
            "url": "https://files.pythonhosted.org/packages/01/75/76e679898b8d2c38676d04830a92f21ce2b11a6fd9fda3a9c1cfd928d4f4/stf_appium_client-0.12.0.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2024-09-24 08:15:18",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "OpenTMI",
    "github_project": "stf-appium-python-client",
    "travis_ci": false,
    "coveralls": true,
    "github_actions": true,
    "lcname": "stf-appium-client"
}
        
Elapsed time: 0.32359s