How to select values from autocomplete dropdown in android using javascript+mocha

I want to click and select the options in location autocomplete dropdown but can’t find its id by using uiautomator viewer.

the only approach you can use is tap with offset. If element not visible hardly you can do more.

Can you attach the UIDump??

How to get the UIDump?

Thanks and Regards
Shashi Kumar Raja

open Uiautomator viewer( which would be at Android/sdk/tools/uiautomatorviewer click on 2nd icon and then 4th icon.

@Aleksei can you provide me the JavaScript code to tap on the screen.Also, how will I know the exact coordinates.

@shashikumarraja sorry i m with java

@Aleksei: Can you share how to find the co-ordinates?


what coordinates? of element?

@Aleksei: yes, do we have an option to find the element co-ordinates??


as i remember something like …


((MobileElement) el).getCenter().getX();
((MobileElement) el).getCenter().getY();

left upper corner:


Attaching the uidump.

So far I have tried using

        return driver.elementById(this.enterLocationTextBox).getLocation()
        .then(function (location) {
             el = driver.elementById(this.mobileNumberSelectedText);
            var tapOpts = {
                x: location.x, // in pixels from left
                y: location.y + 50, // in pixels from top
                element: el.value // the id of the element we want to tap
        return driver.execute("mobile: tap", [tapOpts])


but I am getting error:

   Error: [execute("mobile: tap",[{"x":210,"y":816}])] Error response status: 13, , UnknownError - An unknown server-side error occurred while processing the command. Selenium error: Method has not yet been implemented

Was able to make it work using:

var TouchAction = wd.TouchAction;
exports.selectLocationFromAutoComplete = function (driver, callback) {
return driver.elementById(this.enterLocationTextBox).getLocation()
    .then(function (location) {
        el = driver.elementById(this.enterLocationTextBox);
        var tapOpts = {
            x: location.x, // in pixels from left
            y: location.y - 100 // in pixels from top
        //steps to perform tap action on the screen
        var action = new TouchAction(driver);
        action.tap(el.value, tapOpts);
        action.perform().then(function(err, res){
            return callback(err, res);