Skip to main content


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

Error: Unable to find an active device or emulator with OS 8.1. The following are available: emulator-5554 (7.1)
If you encounter this error then you need to specify PLATFORM_VERSION capability as following -

capabilities.setCapability(MobileCapabilityType.PLATFORM_VERSION, "7.1");
I used version 7.1, use which ever version is applicable for your device

Popular posts from this blog

How can you save resources when instantiaing driver?

I asked on my previous post about what was wrong in instantiating driver on set up method? And here is the solution video on my YouTube channel (After 5 years of gap I finally added new video tutorial :)) The solution described on video tutorial uses following set up - public class BaseClassOnDemandDriverSetup { private WebDriver driver ; @BeforeMethod public void setupTest () { // Any other set up goes here } @AfterMethod public void teardown () { if ( driver != null ) { driver .quit() ; } } public WebDriver getDriver () { if ( driver == null ) { WebDriverManager. chromedriver ().setup() ; driver = new ChromeDriver() ; } return driver ; } }

Using chrome console to test xPath and css selectors

Since the advent of selenium there have been many plugin to test xPath / css selectors but you don’t need any of them if you have chrome browser. Using Chrome console you can test both xPath and css selectors. Launch website to be tested in chrome browser and hit F-12 and you would see chrome console opened in lower pane of application - Hit escape key and console would open another pane to write element locators - And now you can start writing xPath or css selectors in chrome console and test them - The syntax for writing css id - $$(“ ”) And hit the enter key. If your expression is right then html snippet of the application element corresponding to the css selector would be displayed - If you mouse over the html snippet in chrome console then it would highlight the corresponding element in application - If you want to clean console of previously written element selectors then just hit ctrl+L keys and chrome console would be empty again. Pro

Security Testing and Selenium

I have come across many articles which talk of carrying out security testing with selenium however I found it very cumbersome to set up such tests. This is what this tutorial is going to make easy for you. It cover. My next Security Testing and Selenium YouTube video covers following - Importance of having security testing on CI What is dynamic application security testing Recommended tools from What is ?   Using    Project setup  <dependency> <groupId> org.zaproxy </groupId> <artifactId> zap-clientapi </artifactId> <version> 1.9.0 </version> </dependency> <dependency> <groupId> org.zaproxy </groupId> <artifactId> zap </artifactId> <version> 2.10.0 </version> </dependency> Start ZAP daemom (headless) mode  ./ -daemon -host -port 8080 -config api.addrs.a