Test script crashes after running for some time

Hi . i am new to appium and automating an iOS app.
I am using xpath to locate the elements and IntelliJ as my IDE
Everything works fine untill i loop my script and let it run multiple times.
Loop does work fine but suddenly crashes after some loops.
IntelliJ shows me this error “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”

please help.

It crashed nothing @Syed_Umar. The root cause may come from network connection, app loading, etc… Whatever and the actions couldn’t find the elements to interact with.

Did you try to wait the element like:

WebDriverWait wait = new WebDriverWait(webDriver, timeoutInSeconds);

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

You can search around to apply exactly. Hopefully it helps.

I tried this. Was helpful for some extent but i again faced the same issue.
The appium is not reading the xpaths after running the loop for >10 times.

Kindky help!

Besides, we have some other types. Please give a try with: until(ExpectedConditions.presenceOfElementLocated((By.xpath…