.click() not working on button for Android?

I am using Appium 1.5.3 on ubuntu. The .click() and tap() isn’t working for button. My code is:
> webDriver.findElement(By.id(“btn_login”));

    TouchAction Action = new TouchAction((MobileDriver) webDriver);
    Action.tap(webDriver.findElement(By.id("btn_login")));

what is the output displaying over appium server after this action ?

AndroidBootstrap] [BOOTSTRAP LOG] [debug] Got command of type ACTION
[AndroidBootstrap] [BOOTSTRAP LOG] [debug] Got command action: find
[AndroidBootstrap] [BOOTSTRAP LOG] [debug] Finding ‘btn_login’ using ‘ID’ with the contextId: ‘’ multiple: false
[AndroidBootstrap] [BOOTSTRAP LOG] [debug] Using: UiSelector[INSTANCE=0, RESOURCE_ID=org.odk.collect.android:id/btn_login]
[AndroidBootstrap] [BOOTSTRAP LOG] [debug] Returning result: {“value”:{“ELEMENT”:“4”},“status”:0}
[debug] [AndroidBootstrap] Received command result from bootstrap
[MJSONWP] Responding to client with driver.findElement() result: {“ELEMENT”:“4”}
[HTTP] <-- POST /wd/hub/session/d8f64663-4b62-49ca-86e2-0fd606bc8797/element 200 52 ms - 87
[HTTP] --> POST /wd/hub/session/d8f64663-4b62-49ca-86e2-0fd606bc8797/touch/perform {“actions”:[{“action”:“tap”,“options”:{“element”:“4”}}]}
[MJSONWP] Calling AppiumDriver.performTouch() with args: [[{“action”:“tap”,“options”…
[debug] [AndroidBootstrap] Sending command to android: {“cmd”:“action”,“action”:“element:getLocation”,“params”:{“elementId”:“4”}}
[AndroidBootstrap] [BOOTSTRAP LOG] [debug] Got data from client: {“cmd”:“action”,“action”:“element:getLocation”,“params”:{“elementId”:“4”}}
[AndroidBootstrap] [BOOTSTRAP LOG] [debug] Got command of type ACTION
[AndroidBootstrap] [BOOTSTRAP LOG] [debug] Got command action: getLocation
[AndroidBootstrap] [BOOTSTRAP LOG] [debug] Returning result: {“value”:{“y”:861,“x”:92},“status”:0}
[debug] [AndroidBootstrap] Received command result from bootstrap
[debug] [AndroidBootstrap] Sending command to android: {“cmd”:“action”,“action”:“element:getSize”,“params”:{“elementId”:“4”}}
[AndroidBootstrap] [BOOTSTRAP LOG] [debug] Got data from client: {“cmd”:“action”,“action”:“element:getSize”,“params”:{“elementId”:“4”}}
[AndroidBootstrap] [BOOTSTRAP LOG] [debug] Got command of type ACTION
[AndroidBootstrap] [BOOTSTRAP LOG] [debug] Got command action: getSize
[AndroidBootstrap] [BOOTSTRAP LOG] [debug] Returning result: {“value”:{“height”:96,“width”:536},“status”:0}
[debug] [AndroidBootstrap] Received command result from bootstrap
[debug] [AndroidBootstrap] Sending command to android: {“cmd”:“action”,“action”:“element:click”,“params”:{“elementId”:“4”,“x”:360,“y”:909}}
[AndroidBootstrap] [BOOTSTRAP LOG] [debug] Got data from client: {“cmd”:“action”,“action”:“element:click”,“params”:{“elementId”:“4”,“x”:360,“y”:909}}
[AndroidBootstrap] [BOOTSTRAP LOG] [debug] Got command of type ACTION
[AndroidBootstrap] [BOOTSTRAP LOG] [debug] Got command action: click
[AndroidBootstrap] [BOOTSTRAP LOG] [debug] Returning result: {“value”:true,“status”:0}
[debug] [AndroidBootstrap] Received command result from bootstrap
[MJSONWP] Responding to client with driver.performTouch() result: null
[HTTP] <-- POST /wd/hub/session/d8f64663-4b62-49ca-86e2-0fd606bc8797/touch/perform 200 602 ms - 76
[HTTP] --> POST /wd/hub/session/d8f64663-4b62-49ca-86e2-0fd606bc8797/element {“using”:“class name”,“value”:“android.widget.TextView”}
[MJSONWP] Calling AppiumDriver.findElement() with args: [“class name”,“android.widg…
[debug] [BaseDriver] Waiting up to 80000 ms for condition
[debug] [AndroidBootstrap] Sending command to android: {“cmd”:“action”,“action”:“find”,“params”:{“strategy”:“class name”,“selector”:“android.widget.TextView”,“context”:”",“multiple”:false}}
[AndroidBootstrap] [BOOTSTRAP LOG] [debug] Got data from client: {“cmd”:“action”,“action”:“find”,“params”:{“strategy”:“class name”,“selector”:“android.widget.TextView”,“context”:"",“multiple”:false}}

Missing the .perform() ?

Tried with .perform() also,still not working.

please provide the screenshot of uiautomatorviewer for that particular button

[AndroidBootstrap] [BOOTSTRAP LOG] [debug] Finding ‘btn_login’ using ‘ID’ with the contextId: ‘’ multiple: false
[AndroidBootstrap] [BOOTSTRAP LOG] [debug] Using: UiSelector[INSTANCE=0, RESOURCE_ID=org.odk.collect.android:id/btn_login]
[AndroidBootstrap] [BOOTSTRAP LOG] [debug] Returning result: {“value”:{“ELEMENT”:“4”},“status”:0}
[debug] [AndroidBootstrap] Received command result from bootstrap
[MJSONWP] Responding to client with driver.findElement() result: {“ELEMENT”:“4”}
[HTTP] <-- POST /wd/hub/session/0bcfb741-6c89-4018-bf71-a005352ec4b1/element 200 87 ms - 87
[HTTP] --> POST /wd/hub/session/0bcfb741-6c89-4018-bf71-a005352ec4b1/touch/perform {“actions”:[{“action”:“tap”,“options”:{“element”:“4”}}]}
[MJSONWP] Calling AppiumDriver.performTouch() with args: [[{“action”:“tap”,“options”…
[debug] [AndroidBootstrap] Sending command to android: {“cmd”:“action”,“action”:“element:getLocation”,“params”:{“elementId”:“4”}}
[AndroidBootstrap] [BOOTSTRAP LOG] [debug] Got data from client: {“cmd”:“action”,“action”:“element:getLocation”,“params”:{“elementId”:“4”}}
[AndroidBootstrap] [BOOTSTRAP LOG] [debug] Got command of type ACTION
[AndroidBootstrap] [BOOTSTRAP LOG] [debug] Got command action: getLocation
[AndroidBootstrap] [BOOTSTRAP LOG] [debug] Returning result: {“value”:{“y”:861,“x”:92},“status”:0}
[debug] [AndroidBootstrap] Received command result from bootstrap
[debug] [AndroidBootstrap] Sending command to android: {“cmd”:“action”,“action”:“element:getSize”,“params”:{“elementId”:“4”}}
[AndroidBootstrap] [BOOTSTRAP LOG] [debug] Got data from client: {“cmd”:“action”,“action”:“element:getSize”,“params”:{“elementId”:“4”}}
[AndroidBootstrap] [BOOTSTRAP LOG] [debug] Got command of type ACTION
[AndroidBootstrap] [BOOTSTRAP LOG] [debug] Got command action: getSize
[AndroidBootstrap] [BOOTSTRAP LOG] [debug] Returning result: {“value”:{“height”:96,“width”:536},“status”:0}
[debug] [AndroidBootstrap] Received command result from bootstrap
[debug] [AndroidBootstrap] Sending command to android: {“cmd”:“action”,“action”:“element:click”,“params”:{“elementId”:“4”,“x”:360,“y”:909}}
[AndroidBootstrap] [BOOTSTRAP LOG] [debug] Got data from client: {“cmd”:“action”,“action”:“element:click”,“params”:{“elementId”:“4”,“x”:360,“y”:909}}
[AndroidBootstrap] [BOOTSTRAP LOG] [debug] Got command of type ACTION
[AndroidBootstrap] [BOOTSTRAP LOG] [debug] Got command action: click
[AndroidBootstrap] [BOOTSTRAP LOG] [debug] Returning result: {“value”:true,“status”:0}
[debug] [AndroidBootstrap] Received command result from bootstrap
[MJSONWP] Responding to client with driver.performTouch() result: null
[HTTP] <-- POST /wd/hub/session/0bcfb741-6c89-4018-bf71-a005352ec4b1/touch/perform 200 1097 ms - 76

I said about the uiauotomatorviewer output not the console output

sorry but where do we get output in uiautomatorviewer?

I mean the screenshot of inspecting the element using uiautomatorviewer (You can open uiautomatorviewer directly type it over cmd or terminal)

Here you mentioned different id for button and the id displaying in uiautomatorviewer is different . please recheck it and try again

i am using btn_login only.

Seems like similar issue with click on android i posted here - Cannot click on a web element in Chrome (possible when Selendroid is used)

@Garima_Mody you can find element by ID or xpath in this case. See below - Use any of them

driver.findElement(By.id(“btn_login”)).click();
driver.findElement(By.xpath(“//android.widget.Button[@text=‘Login’]”)).click();

Hi
You may try this: add scroll to the location of element before click, this worked for me when click the button in Chrome of android mobile
> public void clickElement(WebElement el) {
> try {
> if(Base.platformName.equalsIgnoreCase(ConstantName.ANDROID))
> ((JavascriptExecutor) Base.base.getDriver()).executeScript(“window.scrollTo(0,” +el.getLocation().x+ “)”);
> TouchActions ta = new TouchActions(Base.base.getDriver());
> ta.singleTap(el).perform();
> } catch (WebDriverException ex) {
> throw ex;
> }
> }

What is correct solution for this?

Use Appium Desktop to investigate the mobile element.

Maybe the Mobile element isn’t set to be clickable or tappable?

-T.J. Maher

I have same issue. I have opened it on appium desktop and mobile element isn’t set to be clickable or tappable.
what is the solution of this issue?

Hi,

driver.executeScript(“mobile: performEditorAction”, ImmutableMap.of(“action”, “done”));

its worked for me