Appium on Real Devices – Appium FAQ

  April 18, 2014

Appium is a mobile UI testing framework supporting cross-platform testing of native, hybrid and mobile web apps for iOS and Android. Appium enables you to execute your tests on real mobile devices irrespective of the device OS. This is because the framework is basically a wrapper that translates Selenium Webdriver commands into UIAutomation (iOS) or UIAutomator (Android) commands depending on the device type.

Download This Appium Beginner’s Guide to Learn All the Basics and How to Set Up your Appium Testing Environment

What languages can I use to write the TestScripts?
You can write TestScripts in any language that Selenium WebDriver dependency is available for. This includes C#, Closure, Java, JavaScript with Node.js, Obj-C, Perl, Python, Ruby.

Do I need to care about the Appium Server depending on the language I wrote my tests with?
No, the server is exactly the same irrespective of the scripting language. This is because the TestScript implements the Selenium WebDriver and communicates with Appium Server via JSON Wire Protocol (a standardized JSON over HTTP protocol).

Where would the Appium server be running?
A great advantage of using Appium is the HTTP communication (see the question above) between TestScript and Appium Server, allowing the server to be running on a separate machine than the TestScript. This allows us to take care of the Appium server-side and the devices to be maintained at the Cloud, while you can run your TestScripts locally from your machine.

How is running Appium different than other frameworks available at Bitbar Testing?
Appium TestScripts is “Live”. This means that you do not upload the TestScript along with your app to the Cloud. Instead, you instigate the script locally from your own machine, and on receiving a request, the Cloud reserves the requested device and creates an Appium session for it.

Can I use the same TestScript for both my iOS and Android apps?
Although the TestScripts will be written in the same language and will be almost similar, you would still need to prepare separate TestScripts for iOS and Android, or at least two flavors of the TestScript. This is because of the differences in UI elements on the two platforms. Sometimes the difference is as subtle as having to use different array indices.

Moving from your localhost to Bitbar Testing

If you have been using Appium at your localhost on a real device, switching to Bitbar Testing is fairly easy. All you need to do is make two changes in your TestScript. If you haven’t been, here’s a little introduction to how Appium works. You start Appium Server instance on your machine while specifying a connected device’s UDID.

$ appium --port 4723 -U

Next, you instigate your TestScript implementing the Selenium  WebDriver connecting to the Appium Server at http://localhost:4723/wd/hub

appium test script on real devices

Note that one Appium instance handles only one test session at a time. If you want to test your Android application on multiple devices, you can connect multiple Android devices to your machine, start multiple Appium instances on different ports with different UDIDs, and instigate multiple TestScripts pointing to different ports. Unfortunately, however, you cannot do the same for iOS. This is because Appium uses native Instrumentation to communicate with the device, and Instrumentation allows only one device at a time.

At Bitbar Testing, however, you can use over 300+ different Android and iOS devices simultaneously. That’s an awesome platform for testing.

appium tests executed on real devices

If you have been using Appium at your localhost on a real device, switching to Bitbar Testing is fairly easy. All you need to do is make two changes in your TestScript.

→ Change the Remote WebDriver address from ‘localhost:port’ and point it to Bitbar Testing.
→ Add ‘testdroid_’ Desired Capabilities in addition to the existing Desired Capabilities in your TestScript.

Running your first Appium test on Bitbar Testing

1. Upload your application (.apk or .ipa) or host it yourself an on public URI.

You can use a plain HTTP address like ‘http://domain.com/files/myApp.ipa’ for us to download your application form, or you can upload the application to Bitbar Testing via command line.

Upload Request:

POST: http://appium.testdroid.com/upload
Authentication: Basic-Auth
Multipart: True
Parameter Name: any
Parameter Value: Application File (.ipa/.apk)

Example using Curl:

curl -s --user [email protected]:pas$w0rd  -F myFile=@"/Users/username/Documents/BitbarIOSSample.ipa" "http://appium.testdroid.com/upload"

Response:

You’ll receive a JSON in response to the upload request with a Session-ID pointing to your uploaded application on Bitbar Testing. Save the Session-ID for later use.

“myFile”: “4e31cede-5741-484c-b58d-8a6d04bc03d5/BitbarIOSSample.ipa“.

2. Select a device

Log into cloud.testdroid.com, select a device you want to run your test on, and copy its name. For example ‘iPhone 5c 7.0.4 A1532‘.

before running appium tests on real devices

3. Add the ‘testdroid_’ Desired Capabilities.

In addition to the standard Desired Capabilities, you have in your TestScript (for example, the minimum required Caps for iOS are shown in the figure below)

appium tests on ios devices

Add ‘testdroid_’ Desired Capabilities in addition to these Capabilities.

configuring appium tests

4. Point the WebDriver to http://appium.testdroid.com/wd/hub

webdriver

5. Run the TestScript

6. Get results from Web UI

test results

and Appium.log from the Web UI