{"id":20447559,"url":"https://github.com/doamaral/python-mobile-pytest","last_synced_at":"2025-08-25T23:11:42.830Z","repository":{"id":239844826,"uuid":"800763158","full_name":"doamaral/python-mobile-pytest","owner":"doamaral","description":"This repo has some code related to what could be a basic structure for a multiplatform mobile app test framework","archived":false,"fork":false,"pushed_at":"2024-05-27T19:23:00.000Z","size":48,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-03-05T08:51:25.262Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/doamaral.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2024-05-15T00:25:40.000Z","updated_at":"2024-05-27T19:23:04.000Z","dependencies_parsed_at":"2024-11-15T10:42:29.910Z","dependency_job_id":null,"html_url":"https://github.com/doamaral/python-mobile-pytest","commit_stats":null,"previous_names":["doamaral/python-mobile-pytest"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/doamaral/python-mobile-pytest","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/doamaral%2Fpython-mobile-pytest","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/doamaral%2Fpython-mobile-pytest/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/doamaral%2Fpython-mobile-pytest/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/doamaral%2Fpython-mobile-pytest/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/doamaral","download_url":"https://codeload.github.com/doamaral/python-mobile-pytest/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/doamaral%2Fpython-mobile-pytest/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":272144654,"owners_count":24881141,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","status":"online","status_checked_at":"2025-08-25T02:00:12.092Z","response_time":1107,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-11-15T10:27:49.622Z","updated_at":"2025-08-25T23:11:42.788Z","avatar_url":"https://github.com/doamaral.png","language":"Python","readme":"# Multiplatform Mobile app Test Framework\nThis is a sample project just to ilustrate how a multiplatform mobile test framework could look like to preserve the same code base for running tests against `iOS` or `Android` platforms.\nThe idea behind the abstraction is the initial information of which platform should we use. If no platform is informed, we should use `Android` as default.\n\n## Pre requisites\n- Node.js run time\n- Python 3.12+\n- All the environment set up for Appium solutions\n  - Install Android Studio\n  - Install Appium: `npm install -g appium` This is the appium server\n  - Install UIAutomator2: `appium driver install uiautomator2`. The platform specific driver\n  - Set JAVA_HOME and ANDROID_HOME to $PATH\n\n- Non mandatory, but helpful\n  - Install Appium Inspector: Useful to inspect the app to find elements locators\n  - Install Appium doctor: Useful to check environment dependencies\n\nfor more info on setting up environment for mobile test automation using Appium, check:\n- https://nshthshah.medium.com/appium-tutorial-step-by-step-android-automation-97b84de2fc55\n- https://appium.io/docs/en/2.1/quickstart/\n- https://www.freecodecamp.org/news/how-to-download-and-install-xcode/\n- https://courtneyzhan.medium.com/set-up-appium-2-to-run-xcuitest-for-ios-d4fb557403f\n- https://github.com/appium/python-client/blob/master/README.md\n\n\n## Main libraries used\n- [Pytest](https://pypi.org/project/pytest/): To support all test management\n- [Dotenv](https://pypi.org/project/python-dotenv/): To support the use of `.env` files\n- [Appium Client](https://pypi.org/project/Appium-Python-Client/): the API to interact with the app through drivers like `UIAutomator2` or `XCUITest`\n\n## Project setup\n- Clone the repo and cd to the folder\n- Set python environment: `python3 -m venv .venv`\n- Activate python environment: `source .venv/bin/active`\n- Install dependencies: `python3 -m pip install -r requirements.txt`\n- Create `app` folder on the root of the project\n  - Download [Android and iOS releases](https://github.com/webdriverio/native-demo-app/releases/tag/v1.0.8)\n  - To use the iOS version unzip it on the app folder\n- Spin up Emulator/Simulator\n\n## Project Structure\n### Core package\ncore package is responsible for the driver management. The main idea is abstract the driver instatiation to provide a single interface to be used throught the code.\n\n- `DriverFactory`\n  - Responsible to manage which specific driver is going to be instantiated according to the `PLATFORM` environment variable\n  - Make sure we have only one instance available (Singleton)\n  - Tests should only call this Class to manage drivers\n- `AndroidDriver` and `IOSDriver` are the specific drivers that interface with `Appium Driver` (or the Mocked version) binding the desired capabilities for each platform\n- `MockAppiumDriver` is just a dummy class to mock actual Appium/Selenium drivers\n\n### Test files\n- `test_driverfactory.py` is the test file\n- `hooks.py` is a file to manage hooks used on the tests\n- `conftest.py` is a special pytest file to glue any file to the tests\n\n## Running tests\nIn order to run the tests, we need to pass the value for PLATFORM environment variable. Currently this project supports `Android` and `iOS` values.\n\n\u003e [!IMPORTANT]\n\u003e Make sure your environment is good to go for both Android and iOS\n\nThere are 2 basic ways to set this variable value:\n\n### Using .env file\nTo use env file you will need to rename `.env_sample` file to `.env` and set `PLATFORM` variable with the expected value.\n```\nPLATFORM=Android \n```\nor\n```\nPLATFORM=iOS \n```\nafter setting up `.env` file, go to the command line and run:\n- `$ pytest -s`\n\n**WARNING**: According to `python-dotenv` [library docs](https://pypi.org/project/python-dotenv/), as we use `load_dotenv(override=False)` the precedence of environment variables value will be:\n- Value of that variable in the environment.\n- Value of that variable in the .env file.\n- Default value, if provided.\n- Empty string.\n\n### Using on Command line\nHere we inform the value for `PLATFORM` straight on the command line, as it follows:\n```\n$ PLATFORM=iOS pytest -s\n```\nor\n```\n$ PLATFORM=Android pytest -s\n```\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdoamaral%2Fpython-mobile-pytest","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fdoamaral%2Fpython-mobile-pytest","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdoamaral%2Fpython-mobile-pytest/lists"}