Appium clicking on incorrect element

Hi all,
After running multiple methods and the first method passes, the second method starts and clicks on an incorrect element.
I tried wait to visibility/ Thread sleep/ Clear element, but always wrong element is clicked.

If I run each method separately its work fine.


getAppElement method:
return wait.withTimeout(Duration.ofSeconds(timeout)).until(
ExpectedConditions.presenceOfElementLocated( + id)

fun before(){

fun after(method: Method) {

based on how objects work, it’s clicking on the thing you located, if however the app is doing something else behind your back, you may just be observing an issue where the element you located is not the right element, but works intermently in some scenarios because the app is using the button as a dynamic element and changing it’s text and meaning at runtime, or the element is merely moving up and down the Z order at the time you click.

Note that the screenshot is often about 1000ms after you click, so the screenshot could be very old by the time it happens.

1 Like

Thanks for the answer, I fixed it after removing double search for an element that I had.
Issue can be closed :slight_smile:

double search, OK, so it was a timing issue was it? Or just a coding mistake?
That’s why I like having a team and let them review my changes :slight_smile: