Python automation boilerplate
This is a boilerplate for testing mobile hybrid apps on Web, iOS & Android.
Python
pip
pyenv
virtualenv
In order to get the tests to run locally, you need to install the following pieces of software.
NOTE: All commands shall be executed from Automation Project root directory:
### MacOS
1. Install Homebrew with `ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"`
1.1. Fix commandline `sudo installer -pkg /Library/Developer/CommandLineTools/Packages/macOS_SDK_headers_for_macOS_10.14.pkg -target /`
2. Install Pyenv with `brew install pyenv` This is a python version manager.<br />
Add the following to *~/.bash_profile*
```# Pyenv
export PYENV_ROOT="$HOME/.pyenv"
export PATH="$PYENV_ROOT/bin:$PATH"
export PATH="$PYENV_ROOT/shims:$PATH"
export PATH="$PYENV_ROOT/completions/pyenv.bash:$PATH"
pyenv install 3.7.5
pyenv global 3.7.5
python3 -m pip install --user virtualenv
python3 -m virtualenv .venv
source ./.venv/bin/activate
pip install -r requirements.txt
which python
. [PROJECT_DIR]/tests/UI/.venv_boilerplate/bin/python
python -m pip install --user virtualenv
python -m virtualenv .venv
source ./.venv/Scripts/activate
pip install -r requirements.txt
which python
. [PROJECT_DIR]/tests/UI/.venv_boilerplate/Scripts/python
python -m pytest -vv --gherkin-terminal-reporter --driver Chrome --driver-path ./selenium_drivers/chromedriver_mac --base-url http://localhost:3001 --variables webdriver/capabilities_web.json --variables i18n.json --variables variables.json --tags=""
python -m pytest -vv --gherkin-terminal-reporter --driver Appium --appium-capability app ./[APP_NAME].apk --appium-capability platformName Android --appium-capability platformVersion '7.0' --appium-capability deviceName device --capability env Android --capability os_version 7.0 --tags="" --variables variables.json --variables i18n.json
python -m pytest -vv --gherkin-terminal-reporter --driver Appium --appium-capability browserName Chrome --appium-capability base_url https://beep.modus.app --appium-capability platformName Android --appium-capability platformVersion '7.0' --appium-capability deviceName device --tags="" --variables variables.json --variables i18n.json
Please read BS documentation for more details on configurations:
-n=3 --dist=loadscope
args and remove --gherkin-terminal-reporter
as this reporting type is not compatible with parallel testingn=3
means 3 parallel testsdist=loadscope
means that parallelism is done at .features file level
Script Path = [UI_TESTS_PATH]
Additional Arguments = -vv --gherkin-terminal-reporter --driver Chrome --driver-path ./selenium_drivers/chromedriver_mac --variables variables.json --variables i18n.json
Python Interpreter = 'Previously created virtualenv'
Working Directory = [UI_TESTS_PATH]
Firefox
Script Path = [UI_TESTS_PATH]
Additional Arguments = -vv --gherkin-terminal-reporter --driver Firefox --driver-path ./selenium_drivers/geckodriver_mac --variables variables.json --variables i18n.json
Python Interpreter = 'Previously created virtualenv'
Working Directory = [UI_TESTS_PATH]
iOS App: -vv —gherkin-terminal-reporter —driver Appium —host ‘[BS_USERNAME]:[BS_KEY]@hub-cloud.browserstack.com’ —port 80 —variables webdriver/capabilities_ios_app.json —variables i18n.json —variables variables.json —tags=””
iOS Web: -vv —gherkin-terminal-reporter —driver BrowserStack —capability device ‘iPad Pro 12.9 2018’ —capability os_version ‘12.0’ —base-url [BASE_URL] —variables variables.json —variables i18n.json
IE: -vv —gherkin-terminal-reporter —driver BrowserStack —capability browser ‘IE’ —capability browser_version ‘11’ —base-url http://localhost:3001 —variables webdriver/capabilities_web.json —variables i18n.json —variables variables.json —tags=””
Edge: -vv —gherkin-terminal-reporter —driver BrowserStack —capability browser ‘Edge’ —capability browser_version ‘18.0’ —base-url http://localhost:3001 —variables webdriver/capabilities_web.json —variables i18n.json —variables variables.json —tags=””
Chrome: -vv —gherkin-terminal-reporter —driver Browserstack —capability build ‘[NAME_OF_BUILD_APP_OR_FEATURE]’ —base-url [BASE_URL] —variables webdriver/capabilities_web.json —variables webdriver/capabilities_web.json —variables i18n.json —variables variables.json —tags=””
Safari: -vv —gherkin-terminal-reporter —driver BrowserStack —capability browser ‘Safari’ —capability browser_version ‘12.0’ —base-url [BASE_URL] —variables webdriver/capabilities_web.json —variables i18n.json —variables variables.json —tags=””
2. Run or Debug with the above configurations
## Code Quality
Linting = the process of analyzing the source code to flag programming errors, bugs, stylistic errors, and suspicious constructs.
**IMPORTANT:** Lint your code before any commit
- Go to _tests_root_ folder
- Run `pylint ./**/**.py`
- There should be only one Error: `E: 4, 0: invalid syntax (<string>, line 4) (syntax-error)`
- This is due to a _pylint_ issue: root files or folders cannot be ignored from linting. Will follow the fix
- A rating above 9.00 should be kept for the code
## Package tests for AWS CI
TODO
# Browserstack Configuration:
Add BrowserStack API credentials to `./.browserstack` file
[credentials]
username=TODO
key=TODO
# TestRail Integration
This is HOW TO guide for TestRail integration of this project
## Configuration:
Add TestRail API credentials to `./.testrailapi` file
[credentials]
email=TODO
key=TODO
url=https://moduscreateinc.testrail.io
verify_ssl=True
Note: Please follow instructions for generating user_key: http://docs.gurock.com/testrail-api2/accessing
**!DO NOT PUSH your credentials into git repo**
## Export test cases to TestRail
- From project root directory
- Run:
**To import/update test Scenarios for ALL feature files**
- ```python -m pytest -vv --export_tests_path "features" --variables variables.json --variables i18n.json
To import/update test Scenarios for INDIVIDUAL .feature file
python -m pytest -vv --export_tests_path "features/[DIR_NAME]/[FILE_NAME].feature" --variables variables.json --variables i18n.json
Feature: Create User - Email registration
As an anonymous user
I open the app for the first time
I want to be able to register with email
Scenario: Add two numbers
Given I have powered calculator on
When I enter <50> into the calculator
When I enter <70> into the calculator
When I press add
Then The result should be <120> on the screen
Examples:
| number_1 | number_2 | result |
| 10 | 20 | 30 |
| 50 | 60 | 120 |
project
Go to variables.json
```
“project”: {
“id”: 1,
“name”: “JIRA”,
“language”: “en”,
“tags”:””,
“test_plan”: “JIRA_Sprint_1”,
“market”: “us”
}
Info
--export_results
- this will run and publish tests resultsTo benefit from autocomplete please set UI folder as Sources Root