PyTest Integration with local or Momentum Suite real mobile farm devices
- Selenium v4 and Appium 2.0 (W3C)
- Native or Hybrid Android and iOS apps (APK, AAB, IPA)
- Page Object Model (POM) usage with pytest
- Local testing or using Momentum Suite's 150+ Android or iOS devices
- Auto generated HTML Allure test report after test
Requirements:
- Python version 3.7+ (required by Appium Python Client v2.6 and pytest)
- Install the Allure command-line tool (required to process the results directory after test run)
Install the dependencies:
Run the following command in project's base directory :
pip3 install -r requirements.txt
Getting Started with Appium tests using Python PyTest on Momentum Suite couldn't be easier! With a Momentum Suite account, You need 4 things to start without any Appium or Android SDK dependencies.
- momentum:user Usually it could be your email address
- momentum:token Your unique access token learned from momentumsuite.com
- momentum:gw Comma seperated Momentum Suite mobile device ID list (4 digit number) to run the test. First number will be your default phone for all except parallel-testing.
- appium:app Your uploaded IPA, APK or AAB app file from Momentum Suite Application Library. Example format is ms:// Optionally you can use a public accessible web URL.
Do not forget to set these 4 Appium capability values and check hostname, port, path and protocol values on your test_settings.json file.
Open for editing your test_settings.json file under root directory.
Set momentum.user, momentum.token, momentum.deviceList, momentum.app on test_settings.json file.
Test script is available in getting_started directory
Run the following command in project's base directory :
python3 -m pytest examples/getting_started/first_android_test.py --alluredir=allure_results
Same with Android, but need to change test_settings.json file.
Run the following command in project's base directory :
python3 -m pytest examples/getting_started/first_ios_test.py --alluredir=allure_results
Use Local testing that access resources hosted in your development or testing environments. You need to install Appium and it's all dependencies like Android SDK, Xcode, Command Line tools. At the same sime you will need to run a real device or simulator/emulator. Do not forget to check hostname, port, path and protocol values on your test_settings.json file with your own Appium server.
Run the following command in project's base directory :
python3 -m pytest examples/local_test/local_android_test.py --alluredir=allure_results
python3 -m pytest examples/getting_started/first_android_test.py --alluredir=allure_results
python3 -m pytest examples/getting_started/first_ios_test.py --alluredir=allure_results
python3 -m pytest examples/local_test/local_android_test.py --alluredir=allure_results
python3 -m pytest examples/local_test/local_ios_test.py --alluredir=allure_results
python3 -m pytest examples/pom_test/tests/pom_android_test.py --alluredir=allure_results
Run the following command in project's base directory after test run has been completed. This command will open a browser window with HTML test results.
allure serve allure_results
If you are running into any issues or have any queries, please check Momentum Suite Contact page or get in touch with us.
Our Technical Documentation space is here.