Element is seemingly clicked but in fact no action is performed (Android)

My code:

AndroidDriver driver;
driver.findElement(By.id(“Button_Start”); // the button is clicked
driver.runAppInBackground(3);
driver.findElement(By.id(“Button_Start”); //here is my problem.

The button is not clicked (no errors). I’m working with native app (Android)

Can somebody help me?

Thanks

If you are running App in background , then how would Appium would click start button.

after runAppInBackground the app is reopen.

Seems like a timing issue. You should try an implicit wait:

http://www.seleniumhq.org/docs/04_webdriver_advanced.jsp

I tried with wait same result.

No errors, element is seemingly clicked but in fact no action is performed.

Any idea?

Can you post the log?

Hi All,

I too face the same issue as mentioned. And also tried with Implicit Wait but still no go.

info: → GET /wd/hub/session/eb8d899f-5ff8-466a-b06a-9943dd643de6 {}
info: [debug] Responding to client with success: {“status”:0,“value”:{“platform”:“LINUX”,“browserName”:“Android”,“platformVersion”:“6.0”,“webStorageEnabled”:false,“takesScreenshot”:true,“javascriptEnabled”:true,“databaseEnabled”:false,“networkConnectionEnabled”:true,“locationContextEnabled”:false,“warnings”:{},“desired”:{“app”:“E:\Radian_Appium_Android\Radian_Android\apk\android-debug.apk”,“platformName”:“Android”,“deviceName”:“emulator-5554”,“platformVersion”:“6.0”},“app”:“E:\Radian_Appium_Android\Radian_Android\apk\android-debug.apk”,“platformName”:“Android”,“deviceName”:“emulator-5554”},“sessionId”:“eb8d899f-5ff8-466a-b06a-9943dd643de6”}
info: ← GET /wd/hub/session/eb8d899f-5ff8-466a-b06a-9943dd643de6 200 0.508 ms - 607 {“status”:0,“value”:{“platform”:“LINUX”,“browserName”:“Android”,“platformVersion”:“6.0”,“webStorageEnabled”:false,“takesScreenshot”:true,“javascriptEnabled”:true,“databaseEnabled”:false,“networkConnectionEnabled”:true,“locationContextEnabled”:false,“warnings”:{},“desired”:{“app”:“E:\Radian_Appium_Android\Radian_Android\apk\android-debug.apk”,“platformName”:“Android”,“deviceName”:“emulator-5554”,“platformVersion”:“6.0”},“app”:“E:\Radian_Appium_Android\Radian_Android\apk\android-debug.apk”,“platformName”:“Android”,“deviceName”:“emulator-5554”},“sessionId”:“eb8d899f-5ff8-466a-b06a-9943dd643de6”}
info: → POST /wd/hub/session/eb8d899f-5ff8-466a-b06a-9943dd643de6/element {“using”:“xpath”,“value”:“//android.widget.Button[@content-desc=‘RADIAN RATES’]”}
info: [debug] Waiting up to 0ms for condition
info: [debug] Pushing command to appium work queue: [“find”,{“strategy”:“xpath”,“selector”:“//android.widget.Button[@content-desc=‘RADIAN RATES’]”,“context”:“”,“multiple”:false}]
info: [debug] [BOOTSTRAP] [debug] Got data from client: {“cmd”:“action”,“action”:“find”,“params”:{“strategy”:“xpath”,“selector”:“//android.widget.Button[@content-desc=‘RADIAN RATES’]”,“context”:“”,“multiple”:false}}
info: [debug] [BOOTSTRAP] [debug] Got command of type ACTION
info: [debug] [BOOTSTRAP] [debug] Got command action: find
info: [debug] [BOOTSTRAP] [debug] Finding //android.widget.Button[@content-desc=‘RADIAN RATES’] using XPATH with the contextId: multiple: false
info: [debug] [BOOTSTRAP] [debug] Using: UiSelector[CLASS=android.widget.Button, INSTANCE=0]
info: [debug] Responding to client with success: {“status”:0,“value”:{“ELEMENT”:“1”},“sessionId”:“eb8d899f-5ff8-466a-b06a-9943dd643de6”}
info: ← POST /wd/hub/session/eb8d899f-5ff8-466a-b06a-9943dd643de6/element 200 39.625 ms - 87 {“status”:0,“value”:{“ELEMENT”:“1”},“sessionId”:“eb8d899f-5ff8-466a-b06a-9943dd643de6”}
info: [debug] [BOOTSTRAP] [debug] Returning result: {“status”:0,“value”:{“ELEMENT”:“1”}}
info: → POST /wd/hub/session/eb8d899f-5ff8-466a-b06a-9943dd643de6/element/1/click {“id”:“1”}
info: [debug] Pushing command to appium work queue: [“element:click”,{“elementId”:“1”}]
info: [debug] [BOOTSTRAP] [debug] Got data from client: {“cmd”:“action”,“action”:“element:click”,“params”:{“elementId”:“1”}}
info: [debug] [BOOTSTRAP] [debug] Got command of type ACTION
info: [debug] [BOOTSTRAP] [debug] Got command action: click
info: [debug] Responding to client with success: {“status”:0,“value”:true,“sessionId”:“eb8d899f-5ff8-466a-b06a-9943dd643de6”}
info: ← POST /wd/hub/session/eb8d899f-5ff8-466a-b06a-9943dd643de6/element/1/click 200 177.571 ms - 76 {“status”:0,“value”:true,“sessionId”:“eb8d899f-5ff8-466a-b06a-9943dd643de6”}
info: [debug] [BOOTSTRAP] [debug] Returning result: {“status”:0,“value”:true}
info: → POST /wd/hub/session/eb8d899f-5ff8-466a-b06a-9943dd643de6/element {“using”:“xpath”,“value”:“//android.widget.Button[@index=‘4’]”}
info: [debug] Waiting up to 0ms for condition
info: [debug] Pushing command to appium work queue: [“find”,{“strategy”:“xpath”,“selector”:“//android.widget.Button[@index=‘4’]”,“context”:“”,“multiple”:false}]
info: [debug] [BOOTSTRAP] [debug] Got data from client: {“cmd”:“action”,“action”:“find”,“params”:{“strategy”:“xpath”,“selector”:“//android.widget.Button[@index=‘4’]”,“context”:“”,“multiple”:false}}
info: [debug] [BOOTSTRAP] [debug] Got command of type ACTION
info: [debug] [BOOTSTRAP] [debug] Got command action: find
info: [debug] [BOOTSTRAP] [debug] Finding //android.widget.Button[@index=‘4’] using XPATH with the contextId: multiple: false
info: [debug] [BOOTSTRAP] [debug] Using: UiSelector[CLASS=android.widget.Button, INSTANCE=3]
info: [debug] [BOOTSTRAP] [debug] Returning result: {“status”:0,“value”:{“ELEMENT”:“2”}}
info: [debug] Responding to client with success: {“status”:0,“value”:{“ELEMENT”:“2”},“sessionId”:“eb8d899f-5ff8-466a-b06a-9943dd643de6”}
info: ← POST /wd/hub/session/eb8d899f-5ff8-466a-b06a-9943dd643de6/element 200 13.499 ms - 87 {“status”:0,“value”:{“ELEMENT”:“2”},“sessionId”:“eb8d899f-5ff8-466a-b06a-9943dd643de6”}
info: → POST /wd/hub/session/eb8d899f-5ff8-466a-b06a-9943dd643de6/element/2/click {“id”:“2”}
info: [debug] Pushing command to appium work queue: [“element:click”,{“elementId”:“2”}]
info: [debug] [BOOTSTRAP] [debug] Got data from client: {“cmd”:“action”,“action”:“element:click”,“params”:{“elementId”:“2”}}
info: [debug] [BOOTSTRAP] [debug] Got command of type ACTION
info: [debug] [BOOTSTRAP] [debug] Got command action: click
info: [debug] Responding to client with success: {“status”:0,“value”:true,“sessionId”:“eb8d899f-5ff8-466a-b06a-9943dd643de6”}
info: ← POST /wd/hub/session/eb8d899f-5ff8-466a-b06a-9943dd643de6/element/2/click 200 277.934 ms - 76 {“status”:0,“value”:true,“sessionId”:“eb8d899f-5ff8-466a-b06a-9943dd643de6”}
info: [debug] [BOOTSTRAP] [debug] Returning result: {“status”:0,“value”:true}
info: → POST /wd/hub/session/eb8d899f-5ff8-466a-b06a-9943dd643de6/timeouts {“type”:“implicit”,“ms”:10000}
info: [debug] Set Android implicit wait to 10000ms
info: [debug] Responding to client with success: {“status”:0,“value”:null,“sessionId”:“eb8d899f-5ff8-466a-b06a-9943dd643de6”}
info: ← POST /wd/hub/session/eb8d899f-5ff8-466a-b06a-9943dd643de6/timeouts 200 1.568 ms - 76 {“status”:0,“value”:null,“sessionId”:“eb8d899f-5ff8-466a-b06a-9943dd643de6”}
info: → POST /wd/hub/session/eb8d899f-5ff8-466a-b06a-9943dd643de6/element {“using”:“xpath”,“value”:“//android.widget.Button[@content-desc='CREATE NEW PRESET ']”}
info: [debug] Waiting up to 10000ms for condition
info: [debug] Pushing command to appium work queue: [“find”,{“strategy”:“xpath”,“selector”:“//android.widget.Button[@content-desc='CREATE NEW PRESET ']”,“context”:“”,“multiple”:false}]
info: [debug] [BOOTSTRAP] [debug] Got data from client: {“cmd”:“action”,“action”:“find”,“params”:{“strategy”:“xpath”,“selector”:“//android.widget.Button[@content-desc='CREATE NEW PRESET ']”,“context”:“”,“multiple”:false}}
info: [debug] [BOOTSTRAP] [debug] Got command of type ACTION
info: [debug] [BOOTSTRAP] [debug] Got command action: find
info: [debug] [BOOTSTRAP] [debug] Finding //android.widget.Button[@content-desc='CREATE NEW PRESET '] using XPATH with the contextId: multiple: false
info: [debug] [BOOTSTRAP] [debug] Using: UiSelector[CLASS=android.widget.Button, INSTANCE=5]
info: [debug] [BOOTSTRAP] [debug] Failed to locate element. Clearing Accessibility cache and retrying.
info: [debug] [BOOTSTRAP] [debug] Finding //android.widget.Button[@content-desc='CREATE NEW PRESET '] using XPATH with the contextId: multiple: false
info: [debug] [BOOTSTRAP] [debug] Using: UiSelector[CLASS=android.widget.Button, INSTANCE=1]
info: [debug] [BOOTSTRAP] [debug] Returning result: {“status”:0,“value”:{“ELEMENT”:“3”}}
info: [debug] Responding to client with success: {“status”:0,“value”:{“ELEMENT”:“3”},“sessionId”:“eb8d899f-5ff8-466a-b06a-9943dd643de6”}
info: ← POST /wd/hub/session/eb8d899f-5ff8-466a-b06a-9943dd643de6/element 200 1090.662 ms - 87 {“status”:0,“value”:{“ELEMENT”:“3”},“sessionId”:“eb8d899f-5ff8-466a-b06a-9943dd643de6”}
info: → POST /wd/hub/session/eb8d899f-5ff8-466a-b06a-9943dd643de6/element/3/click {“id”:“3”}
info: [debug] Pushing command to appium work queue: [“element:click”,{“elementId”:“3”}]
info: [debug] [BOOTSTRAP] [debug] Got data from client: {“cmd”:“action”,“action”:“element:click”,“params”:{“elementId”:“3”}}
info: [debug] [BOOTSTRAP] [debug] Got command of type ACTION
info: [debug] [BOOTSTRAP] [debug] Got command action: click
info: [debug] Responding to client with success: {“status”:0,“value”:true,“sessionId”:“eb8d899f-5ff8-466a-b06a-9943dd643de6”}
info: ← POST /wd/hub/session/eb8d899f-5ff8-466a-b06a-9943dd643de6/element/3/click 200 3115.796 ms - 76 {“status”:0,“value”:true,“sessionId”:“eb8d899f-5ff8-466a-b06a-9943dd643de6”}
info: [debug] [BOOTSTRAP] [debug] Returning result: {“status”:0,“value”:true}
info: [debug] Didn’t get a new command in 60 secs, shutting down…

If you are not getting any error for clicking the element means, some where else it is clicking.
Enable show touches, show pointer locations in developer options in android device and then execute the script once so, it will show the touch point location in device.