Skip to content

Appium server and capabilities

Anto edited this page Jun 15, 2020 · 2 revisions

Now we need to start our first steps with appium:

  1. Open your appium desktop application
  2. Start appium server (click on the button Start Server)
  3. Connect the device where the application is install to your PC / Use a virtual device and run the application there using Android Studio (official Android documentation)
  4. Open the app we want to automate
  5. Execute the script script_capabilities.py. This script automates the process of executing different adb commands to get the capabilities we need for our webdriver and provides a JSON file for them (which will be used later by this framework when running test cases). We will have to provide a name for the resulting JSON file that will be saved in folder profiles. NOTE: We running a test from its test suite, we will look for the JSON file that has the same name that the page object class where we are creating our webdriver but in lowercase. However, this script might fail as sometimes the capabilities we need are not given when executing those commands and we will have to run the following manually:

adb shell getprop -> For here, we will have to search for the following properties: ro.build.software.version -> This will provide the capabilities: platformName and platformVersion. If this is not returned, there are alternatives: gsm.operator.alpha -> This will provide the capability platformName ro.build.version.release -> This will provide the capability ro.product.device

adb shell "dumpsys window windows | grep -E "mCurrentFocus" -> For appPackage and appActivity

adb shell "dumpsys window windows | grep -E "mObscuringWindow" -> For appPackage and appActivity

adb shell "dumpsys window windows | grep -E 'Window'" -> For appActivity

adb shell "dumpsys package | grep <your app>" -> For appPackage

You will have to add those variables to the following JSON template: {"platformName": " ", "platformVersion": " ", "deviceName": " ", "automationName": <"UiAutomator1"/"UiAutomator2">, -> One of the two "appPackage": " ", "appActivity": " ", "adbExecTimeout": "200000"} -> Or other timeout

Save it in folder profiles

Now back to appium desktop application, press in the button Search (the icon looks like a magnifying glass) in the top right.

In the section JSON representation, click on the button Edit (the icon looks like a pencil): Paste there the content of the JSON file in the folder profile (the one we got/made when running our app)

Click on the button Start Session

Now, our app will be execute and a new window will appear with the app opened. Here we can get the xpaths, ids,... needed for the files in the folder selector

These files must have the same name as the class from which there are called in folder "app_window_objects" and look like this:

So if the app window object class is called CalculatorMainApp the file has to be called calculatormainapp.ini so our class will look for it when creating the corresponding object from that class

BITBAR:

In case, we are using the integration with bitbar, we have to create and use a JSON file that serves as a profile, but it's a file with the same format but different capabilities. To get the JSON needed for the file, go to this URL and choose your device

Clone this wiki locally