[Need help] Click some times doesn't fire

Hey I am new for appium. I am currently doing some POC of appium and I got blocked by following scripts. The app is build with Cordova. And the issue only happen to Android.

.elementByName(“menu”).click()
.elementByName(“Browse”).click()
.elementByName(“input-field”).sendKeys(“https://www.google.com”) //input field with google URL.
.sleep(2000)
.elementByName(“GO”).click()
.sleep(2000)
.back()
.elementByName(“menu”).click()

What test does is simply click slide menu, go to browse page, enter a url and navigate to a page. back from the page after, then click slide menu again.

What happens is the last click got fired but nothing happened and there are no error also.

1 Like

Please put some wait after back(); and before menu click();

Hope this helps…

No. I tried that already. Even with 10 sec sleep.

I can also reproduce same scenario by manually using Appium GUI tool.

I sometimes had issues clicking items which were not displayed or enabled.

Can you verify that the element with that:
.elementByName(“menu”).isDisplayed() == true
.elementByName(“menu”).isEnabled() == true

Can you also check out the appium logs and dump them from when the click is done

Hey pittsd,

I checked as you said, before the click
.elementByName(“menu”).isDisplayed() == false
.elementByName(“menu”).isEnabled() == false

after the click
.elementByName(“menu”).isDisplayed() == true
.elementByName(“menu”).isEnabled() == false

Is that correct? Now I am even more confused. Why with isEnabled === false, I can click?

Here I also append the console log

CALL setImplicitWaitTimeout(4000)
POST /session/:sessionID/timeouts/implicit_wait {“ms”:4000}
RESPONSE setImplicitWaitTimeout(4000)
CALL isDisplayed()
GET /session/:sessionID/element/function%20(err)%20%7B%0A%20%20%20%20%20%20if(err)%20%7B%0A%20%20%20%20%20%20%20%20err.message%20=%20%27[%27%20+%20name%20+%20niceArgs(fargs.all)%20+%20%22]%20%22%20+%20err.message;%0A%20%20%20%20%20%20%20%20if(fargs.callback)%20%7B%20fargs.callback(err);%20%7D%0A%20%20%20%20%20%20%7D%20else%20%7B%0A%20%20%20%20%20%20%20%20var%20cbArgs%20=%20__slice.call(arguments,%200);%0A%20%20%20%20%20%20%20%20_this.emit(%27command%27,%20%22RESPONSE%22%20,%20name%20+%20niceArgs(fargs.all),%0A%20%20%20%20%20%20%20%20%20%20niceResp(.rest(cbArgs)));%0A%20%20%20%20%20%20%20%20if(fargs.callback)%20%7B%20fargs.callback.apply(null,%20cbArgs);%20%7D%0A%20%20%20%20%20%20%7D%0A%20%20%20%20%7D/displayed
RESPONSE isDisplayed() false
CALL isEnabled()
GET /session/:sessionID/element/function%20(err)%20%7B%0A%20%20%20%20%20%20if(err)%20%7B%0A%20%20%20%20%20%20%20%20err.message%20=%20%27[%27%20+%20name%20+%20niceArgs(fargs.all)%20+%20%22]%20%22%20+%20err.message;%0A%20%20%20%20%20%20%20%20if(fargs.callback)%20%7B%20fargs.callback(err);%20%7D%0A%20%20%20%20%20%20%7D%20else%20%7B%0A%20%20%20%20%20%20%20%20var%20cbArgs%20=%20__slice.call(arguments,%200);%0A%20%20%20%20%20%20%20%20_this.emit(%27command%27,%20%22RESPONSE%22%20,%20name%20+%20niceArgs(fargs.all),%0A%20%20%20%20%20%20%20%20%20%20niceResp(
.rest(cbArgs)));%0A%20%20%20%20%20%20%20%20if(fargs.callback)%20%7B%20fargs.callback.apply(null,%20cbArgs);%20%7D%0A%20%20%20%20%20%20%7D%0A%20%20%20%20%7D/enabled
RESPONSE isEnabled() false
CALL elementByName(“”)
POST /session/:sessionID/element {“using”:“name”,“value”:“”}
RESPONSE elementByName(“”) {“ELEMENT”:“1”}
CALL element.click()
POST /session/:sessionID/element/1/click
RESPONSE element.click()
CALL element.isDisplayed()
GET /session/:sessionID/element/1/displayed
RESPONSE element.isDisplayed() true
CALL isEnabled()
GET /session/:sessionID/element/function%20(err)%20%7B%0A%20%20%20%20%20%20if(err)%20%7B%0A%20%20%20%20%20%20%20%20err.message%20=%20%27[%27%20+%20name%20+%20niceArgs(fargs.all)%20+%20%22]%20%22%20+%20err.message;%0A%20%20%20%20%20%20%20%20if(fargs.callback)%20%7B%20fargs.callback(err);%20%7D%0A%20%20%20%20%20%20%7D%20else%20%7B%0A%20%20%20%20%20%20%20%20var%20cbArgs%20=%20__slice.call(arguments,%200);%0A%20%20%20%20%20%20%20%20_this.emit(%27command%27,%20%22RESPONSE%22%20,%20name%20+%20niceArgs(fargs.all),%0A%20%20%20%20%20%20%20%20%20%20niceResp(_.rest(cbArgs)));%0A%20%20%20%20%20%20%20%20if(fargs.callback)%20%7B%20fargs.callback.apply(null,%20cbArgs);%20%7D%0A%20%20%20%20%20%20%7D%0A%20%20%20%20%7D/enabled
RESPONSE isEnabled() false

So - it makes sense that the click doesn’t work as the element is disabled.

Can you output the appium logs after the click is done on the element?

Do you need to put a delay in before you click the menu again? Is the page fully loaded?

Hey pittsd,

Thanks for your help. But now I don’t understand why the first time click could work.

As I said, before the first time click, both enabled and displayed are false. You can see that from the console log. (The elementByName(“”) is the menu button)

About the delay, no matter how long delay I gave, it always work like that. The only different I can see from first time click and 2nd time click is. Before the first time click, there is an implicit waite, and after the click it is a sleep. I don’t know if that matters.

The page is fully loaded. And same page works on iOS

indeed we also met sometimes with hard to click on some objects.
for very stubborn items we made special click functions:

  • tapElemToHideByElement (tapElem, hideElem)
  • tapElemToShowByElement (tapElem, showElem)

inside we have 5 retries to tap

Hey @amedvedev, can you explain you approach bit more? All you do is 5 times tap in one go?

after click in all cases you are expecting either something appear or disappear -> thus loop itself is:

  1. tap on tapElem
  2. check that hideElem disappeared or showElem appeared
  3. step2 = true -> exit / step2 = false repeat from step1

and just added control increment should not exceed in loop more then 5 times to avoid infinite loops.

Thanks everyone,

I found the issue. The problem is in the webview we have two same dom objects and we switch using them for some reason. I didn’t know that. So for fixing the issue, I get both elements and click on the activated one. that solve my problem.

Anyway, Thank you all

1 Like