Client Side Appium¶
With Bitbar Cloud it is possible to execute Appium tests similarly as when running the tests on your local machine. The difference is that Appium server and the tested device are in cloud.
The below steps guide you how to get your existing Appium tests running against devices hosted in cloud.
Upload Your App To Cloud¶
First the app under test needs to be uploaded to Bitbar Cloud. This can be done either using curl on the command line as below or some automated CI solution.
The preferred way to authenticate yourself to the cloud is using the apiKey, a unique token that can be copied or changed at any time from user’s My account in Bitbar Cloud.
$ curl -H "Accept: application/json" -u xYY5...PeOA6: -F myAppFile=@"/absolute/file/path/example.apk" http://appium.bitbar.com/upload
Running this upload command will return an answer with the app file name to be used in test capabilities.
The myAppFile above response is the uploaded app file name in cloud: “myAppFile”:”bb8e4336-e6ea-4ba7-9b4x-a6824f1c60aa/Testdroid.apk”. This value (“bb8e4336-…”) is needed in Appium capabilities.
Edit Desired Capabilities¶
Common values used in tests:
- testdroid_apiKey - a personal unique key allowing you to connect to Bitbar Testing without using username and passwords in tests. Api key is found under “My account” in Bitbar Testing Cloud UI.
- testdroid_project - the project name in Bitbar Testing. Each project must have a unique name, which can be modified (in Cloud)
- testdroid_testrun - name of this test run inside of testdroid_project. Each test run can have it’s own name (eg. date + time)
- testdroid_app - name of the app uploaded using upload.py script or curl command. Example filename could be ‘f4660af0-10f4-46e9-9345-0633f497b0d2/Testdroid.apk’. To rerun against the last uploaded application the value “latest” can be used.
In addition to the above capabilities, default Appium capabilities are supported. It is worth checking the list of supported Desired Capabilities.
Selecting a Device¶
With client side Appium runs, Bitbar Cloud gives preference on
providing some available device over an exact match. This preference can
be changed with the desired capability
capability allows the user to get a similar device to the one requested
or the exact requested. Device similarity is defined by device name
similarity matching. This means running the same test twice with
testdroid_findDevice='true', the device selected by cloud can be
To enforce selecting a specific device, one should check for the exact
name from Bitbar Cloud and set the
false. If the selected device is currently busy, a new
session is tried for a few minutes. The connection is closed if device
does not become available during this time.
Updating Existing Tests For Cloud¶
Online samples on Github, accessible here, help getting started on running Appium tests. The samples are available in Python, Java, C# and Ruby.
For running your existing Appium runs against Bitbar cloud, your existing desired capabilities need to be updated. Mainly authentication information and selecting the appropriate device need to be provided. The app name is the name from the above curl upload. Below example shows the additional capabilities that need to be added.
'app' : 'com.bitbar.testdroid.BitbarIOSSample', 'device' : 'iphone'
'app' : 'com.bitbar.testdroid.BitbarIOSSample', 'device' : 'iphone', 'testdroid_apiKey' : '<your apiKey>', 'testdroid_project' : 'Appium iOS Project', 'testdroid_testrun' : 'Test run 1', 'testdroid_device' : 'iPhone 5c', 'testdroid_app' : 'bb8e4336-e6ea-4ba7-9b4x-a6824f1c60aa/Testdroid.ipa', 'testdroid_locale' : 'fi_FI' # optional
Change WebDriver Address¶
When running Appium locally, the web driver address is running on
http://localhost:4723/wd/hub). When running the test from your
local machine against a cloud device, you must update the Appium server location
Upload Results to Cloud (Optional)¶
If your test suite generates a JUnit XML results file, you can upload the XML to Bitbar Cloud. Doing this will allow you to check your test cases and their run statuses on the web UI, and let you download test reports in various formats.
Add the testdroid_junitWaitTime Desired Capability in your TestScript with an appropriate value in seconds. Eg. 60 seconds should be sufficient.
Get Appium session ID from your test script (after the WebDriver connection has been established) by printing the property:
self.utils.log("Driver session id: "+ self.driver.session_id)
After your test run has finished, and JUnit XML has been generated, use Curl to upload the XML to Cloud:
curl -s -F result=@"/absolute/file/path/TEST-all.xml" http://appium.bitbar.com//upload/result?sessionId=<SESSION_ID>