Appium starts waiting for alert window as execution takes longer

This is regarding already known topic https://github.com/appium/appium/issues/16222 on appium side i understand The logic is to wait for an atom to complete for maximum one second. If the completion takes more than that then execute an alert checking loop to verify if there is a native alert which covers the view and preventing the atom from being completed. If there is an alert then an error is thrown immediately otherwise the loop continues until a timeout is reached and the above error is thrown.

so what i faced is in my tests randomly i get the above error and i am not sure why it would take more than a sec for an atom to execute, if this is the case automating with appium is really difficult, as the atom’s execution time is not in our control i think? if findElement can take 1sec or more how can i control this, can someone please help me with this :frowning: any tips on how to avoid this issue

I believe here the atom means findElement that is internal method of appium/selenium that we have no control? so if it is taking more than 1 sec not sure how can i control that.

other than that i tried to wait for a page to load by checking document.readyState()
even after that i can see this type of abrupt failures happening, please help with this issue or guide me if i need to be clarified. this issue has been coming since long time in our tests and making it unstable

Thanks you in advance

Although you seem to give Appium the responsibility for this, the reality is that the device and app states fluctuate. You have no control over that. The OS (whichever it is) is in constant task management. It can help to uninstall or disable any apps that you don’t interact with in automation, and reduce the device down to bare essentials, many people have done that with a high degree of success but it this not foolproof.

Your example is a perfect one. If it takes longer than 1 second, you should account for that with a wait of some kind (like an implicit wait). There are ample tools for doing this, and the reason there are ample tools is because this is the essential challenge of automating an app on a device.

If it was easy, everyone would do it. Learn and get good at this for ensured job security. :wink:

oh ok, Thank you very much for responding, actually i have tried with implicit waits and even explicit waits, i have learned over the course of automation how to use the explicit waits using polling etc still sometimes this kind of issue happens which again i understand might be requiring tweaking of waits, thanks for clarifying though, will try some more on my end.