Why I am getting this " An element could not be located ..." message again and again

An element could not be located on the page using the given search parameters. (WARNING: The server did not provide any stacktrace information)
Command duration or timeout: 65 milliseconds

Next time if I run the same program then the same code works successfully without showing an error message.
Why is it happening?

This generally happens when the element you are looking for is not loaded and not in view. Some times the screen is loaded appropriately and then the element is found easily. Make sure you try to do any operation on the element when page/screen is loaded successfully

You should read this article on using explicit waits:

https://saucelabs.com/resources/articles/appium-bootcamp-chapter-4

I use the Selenium::WebDriver::Wait which will poll for an element for the time you specify. Once the element is visible it will immediately return, allowing us to efficiently poll.

1 Like