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}}
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.
vk123
August 18, 2016, 4:03pm
14
@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?
varun
January 29, 2019, 10:18am
20
Hi,
driver.executeScript(“mobile: performEditorAction”, ImmutableMap.of(“action”, “done”));
## How To Emulate IME Actions Generation
Very often Android developers use [onEditorAction](https://developer.android.com/reference/android/widget/TextView.OnEditorActionListener.html#onEditorAction(android.widget.TextView,%20int,%20android.view.KeyEvent)) callback with `actionId` argument to implement actions handling, for example, when `Search` or `Done` button is pressed on the on-screen keyboard. Appium since version 1.9.2 allows to automate the generation of such actions by providing the special `mobile:` command.
### mobile: performEditorAction
Executes the given editor action on the _currently focused_ element.
#### Supported arguments
* _action_: The name or an integer code of the editor action to be executed. The following action names are supported: `normal, unspecified, none, go, search, send, next, done, previous`. Read https://developer.android.com/reference/android/view/inputmethod/EditorInfo for more details on this topic.
#### Usage examples
```java
// Java
driver.executeScript("mobile: performEditorAction", ImmutableMap.of("action", "Go"));
```
This file has been truncated. show original
its worked for me