Skip to content

Repo for automated tests of mobile android native app using Typescript, Webdriver.io and Appium

Notifications You must be signed in to change notification settings

Tesena-smart-testing/ma-alza-ts

Repository files navigation

Testing native mobile app on Android using Webdriver.io and Appium

Preconditions

Installation

  • clone repo using git clone [email protected]:Tesena-smart-testing/templates_for_MA_training.git
  • run npm i
  • check wdio.conf.ts file and its capabilities prop. Create AVD emulation in the Android Studio accordingly, so this setup would work. Otherwise, adjust setup values to your emulated mobile device.

How to run tests

  • start Android Studio and correct mobile phone emulation
  • run npx wdio run ./wdio.conf.ts

CI/CD Github pipeline

  • implementation is based on standard node.js setup
  • AVD is created using this excellent github action
    • read the documentation of the action repo

Test artefacts storage

  • tests are creating HTML test reports including video recordings of each test in reports/html-reports
  • configuration is in wdio.conf.ts
  • this solution uses video-reporter and HTML reporter
  • if tests are run on CI/CD pipeline, then they are stored using actions/upload-artifact. You can access the report from the details of the given job run - e.g. HERE, in the Artifacts section

How to create completely new project

  • run npm init wdio@latest ./path/to/new/project or npm init wdio@latest . if you are already in your selected project folder
  • when prompted by CLI wizard, select needed options. Do not forget to select Typescript compiler and appium installation
  • wait until project is created
  • see detailed GUIDE

How to run tests against real device

  • enable development mode on your phone
  • connect to the computer via USB
  • if you have Android Studio installed, then go to C:\Users\<username>\AppData\Local\Sdk\platform-tools and run .\adb.exe devices. You should see your device connected. If not, try to run .\adb.exe usb and on you mobile device confirm the connection and authorization.
  • If you have Android 14, then you can just run npx wdio run ./wdio.adb.conf.ts. Otherwise adjust capabilities in the wdio conf file.

How to create real devices farm using stf

WARNING: Unfortunately, I am able to build an image and run the service, but detecting devices fails and I am at my wits end.

  • have Docker installed
  • if you are in the ROOT of this project, then run docker build -t stf -f ./stf/Dockerfile ./stf to build the image
  • then start the service using docker run -it -p 7100:7100 -p 7110:7110 -p 28015:28015 stf /bin/bash
  • then open http://127.0.0.1:7100 in your browser
  • login as administrator with password [email protected]

Documentation

If you are using ESET Antivirus

  • be careful, latest update of ESET as of 23.04.2024 breaks nodejs and npm functionalities due to nodejs handling of the certificates. ESET newly implemented scanning of HTTPS protocol and blocks nodejs' network calls. Current workaround is to disable the https scanning or wait few days until this is fixed and rolled out from ESET. See HERE

If you have problems with appium wdio service

Sometimes, at least in my case, the appium service does not work correctly, due to selected port blockage. Best way to resolve this is to disable appium service in the wdio.conf.ts file and run appium manually in the second console. Ensure, that port in wdio.conf.ts is the same, as when running command npx appium --port <port>.

About

Repo for automated tests of mobile android native app using Typescript, Webdriver.io and Appium

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published