- Clone this repo
- Do
poetry install
- Open project in PyCharm, setup interpreter
- Sign up on BrowserStack
- Get your username, access key and sample app id (somewhere from your browserstack dashboard getting started guide;))
- Copy
browserstack_sample.py
from github.com/browserstack/python-appium-app-browserstack/blob/w3c/android/browserstack_sample.py to project root or createddemo
python package, and set your credentials and app id remembered in previous step;) - Run file from PyCharm
- Check the build status (find it in the BrowserStack dashboard - sidebar)
To run available tests from this project, in addition to 1-5 steps from above, do:
- Copy
config.personal.env.example
toconfig.personal.env
inside the project root - Inside
config.personal.env
, setbrowserstack.userName
andbrowserstack.accessKey
to your values, got on step 5. - Run tests either from PyCharm or from unix terminal (on Windows, use Git Bash or WSL)
pytest tests/android/patched_style/test_wikipedia.py --alluredir reports/
Notice that, when running from terminal, you can omit the existing env file, by providing all needed options by calling a env
command (available in unix terminals like Git Bash or WSL)
env -S "app='bs://c700ce60cf13ae8ed97705a55b8e022f13c5827c' appName='org.wikipedia.alpha' remote_url='http://hub.browserstack.com/wd/hub' browserstack.userName='harrypotter_qiHHSb' browserstack.accessKey='fSnAmPdKHW2xsDkV95Zs'" pytest tests/android/patched_style/test_wikipedia.py --alluredir reports/
Or you can store all needed options values in a different config.*.env
file, where * is one of values defined (you can extend them, of course) in config.py at the following lines:
from typing import Literal
EnvContext = Literal['personal', 'test', 'stage', 'prod']
Hence, instead of using config.personal.env, you can create, for example the config.stage.env
file, store there all needed options, and then run tests by something like:
env -S "context=stage" pytest tests/android/patched_style/test_wikipedia.py --alluredir reports/
You also can run tests and execute allure reports in «one shot» by something like:
env -S "context=stage" pytest tests/android/patched_style/test_wikipedia.py --alluredir reports/; allure serve /reports
Run the following cURL (available from unix terminal, like Git Bash on windows) request (by providing your userName and accessKey in the -u "<userName>:<accessKey>"
section) to upload an Android app:
curl -u "alexandersantalov_bsAqLc:N8yqKqzaEWS5DX9ibcJF" -X POST "https://api-cloud.browserstack.com/app-automate/upload" -F "file=@/path/to/app/file/application-debug.apk"
You should get the following response:
{
"app_url":"bs://f7c874f21852ba57957a3fdc33f47514288c4ba4"
}
Now you can use the app_url
value (like "bs://f7c874f21852ba57957a3fdc33f47514288c4ba4"
from above) to set the corresponding app
capability in your options to driver (e.g. by setting corresponding env variable in your dotenv files)
See Official Documentation to know more.
Here is an example of desired capabilities for Windows:
{
"automationName": "UIAutomator2",
"platformName": "Android",
"app": "F:\\app\\wiki.apk",
"appWaitActivity": "org.wikipedia.*"
}
Notice that there is no appium:
prefix for some capabilities, that it's Ok to set on Mac OS.
Use Scrcpy app ;). See Documentation | Downloads
To use, for example, the Wikipedia application on your device with the English interface, change the interface of your device to English.