This site is in read only mode. Please continue to browse, but replying, likes, and other actions are disabled for now.
18 / 20
Jun 2017

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")));

  • created

    Jul '16
  • last reply

    Jan '19
  • 19

    replies

  • 5.0k

    views

  • 10

    users

  • 2

    links

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}}

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

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

1 month later

@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;
	}
}
9 months later

Use Appium Desktop to investigate the mobile element.

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

-T.J. Maher

3 months later

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?

1 year later

Hi,

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

its worked for me