Please post your Web Driver questions in official Web Driver forum

Thursday, May 28, 2015


Element Location Strategy  - 

Launch UIAutomationViewer as - 

uiautomatorviewer &

Following is an example for UIAutomationViewer and using it to find elements on Android App. Herein an image of UIAutomationViewer with calculator application - 

The Element 64 can be identified as - 
  • driver.findElement("64"));
  • driver.findElement(""));
  • driver.findElement(By.className("android.widget.EditText"));
Element location by TagName is deprecated. Refer Stackoverflow post1 and post2 for more on this.
You can also use xPath strategy to identify element as described in this post.

Appium also supports Mobile JSON Wire Protocol locator strategy -

  • -ios uiautomation: a string corresponding to a recursive element search using the UIAutomation library (iOS-only)
  • -android uiautomator: a string corresponding to a recursive element search using the UiAutomator Api (Android-only)
  • accessibility id: a string corresponding to a recursive element search using the Id/Name that the native Accessibility options utilize

Update chrome driver binaries -
At times chrome browser on real device may not work and can be fixed by updating chrome driver binaries which are downloaded by appium. download latest chrome driver binaries from -
And replace them in your appium download location, The location looks as following on my Ubuntu - /home/tarun/node-v0.12.2-linux-x64/lib/node_modules/appium/build/chromedriver/linux
Using Chrome browser on non rooted devices -
If you have a non rooted device then chrome would work for only version higher than 33, so if you using a version of chrome lower than 33.0 then upgrade it to higher version. This may be far easier than rooting the device :-) Moreover since chrome browser update automatically on Android hence you would like to test on latest version of chrome browser.
Killing a running instance of adb -

If you come across following error when executing tests -
org.openqa.selenium.SessionNotCreatedException: A new session could not be created. (Original error: Command failed: /bin/sh -c /home/tarun/Documents/mine/lib/android-sdk-linux/platform-tools/adb -s adb server is out of date.  killing... wait-for-device ADB server didn't ACK * could not start server *)
then you may already have adb server up and running and you would have kill it. kill adb from command line as following -
killall -9 adb

How do I find the device version and name -
Couple of examples on other sites set VERSION and deviceName capabilities for android but appium seem to ignore it for android. Any way, these capabilities may be used by Appium in future and can be set as - 

capabilities.setCapability(CapabilityType.VERSION, “4.4”);
If your device is running 4.4.2 then VERSION is 4.4, if your device is running 5.1.1 then version is 5.1 and so on
With appium version 1.3.7 following message is logged in appium server which indicates that VERSION capability is anyway ignored by appium -

info: [debug] The following desired capabilities were provided, but not recognized by appium. They will be passed on to any other services running on this server. : version
The deviceName capability can be set as - 

capabilities.setCapability(“deviceName”, “111bd508″);
The device name is found using adb command as - 
adb devices -l

List of devices attached 
emulator-5554          device product:sdk_phone_x86_64 model:Android_SDK_built_for_x86_64 device:generic_x86_64
Herein emulator-5554 is the deviceName

The deviceName capability is currently ignored for Android. Reference 
Fork me on GitHub