Git Product home page Git Product logo

qa_guru_python_3_20's Introduction

Mobile tests on BrowserStack with Python + Pytest + Selene + Appium + Allure

Lesson plan

Demo Sample

  1. Clone this repo
  2. Do poetry install
  3. Open project in PyCharm, setup interpreter
  4. Sign up on BrowserStack
  5. Get your username, access key and sample app id (somewhere from your browserstack dashboard getting started guide;))
  6. Copy browserstack_sample.py from github.com/browserstack/python-appium-app-browserstack/blob/w3c/android/browserstack_sample.py to project root or created demo python package, and set your credentials and app id remembered in previous step;)
  7. Run file from PyCharm
  8. Check the build status (find it in the BrowserStack dashboard - sidebar)

Run existing tests from simple project framework

To run available tests from this project, in addition to 1-5 steps from above, do:

  1. Copy config.personal.env.example to config.personal.env inside the project root
  2. Inside config.personal.env, set browserstack.userName and browserstack.accessKey to your values, got on step 5.
  3. 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

FAQ

How to upload your own version of application to Browserstack?

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.

How to properly pass desired capabilites in Appium Inspector at Windows?

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.

How to stream the connected real device screen at your desktop?

Use Scrcpy app ;). See Documentation | Downloads

How to run the english version of a mobile application on your device?

To use, for example, the Wikipedia application on your device with the English interface, change the interface of your device to English.

qa_guru_python_3_20's People

Contributors

evensty avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.