Appium server freezes randomly for 5-10 seconds during test case execution

I am facing a huge problem while executing 10+ test cases, I have observed that Appium server freezes randomly for around 5-10 seconds and then resumes from the last step only. Now the problem is, during this time if a dynamic element gets displayed like toast message or dialog message that will disappear in 2-3 seconds after invoking, will never able to find it using driver.findElement(By.xpath(“(//android.widget.Toast)[1]”).getAttribute(“name”)); and throw the NoSuchElementFoundException when the Appium resumes automatically. I tried with both implicit wait driver.manage().timeouts().impicitWait(Duration.ofSeconds(10)); and explicit wait wait().until(ExpectedConditions.visibilityOf(“(//android.widget.Toast)[1]”)); and obviously, our good-old Thread.sleep(<desired_time>) after selecting the button so that element can get visible properly.

I checked the logs multiple times, it doesn’t throw any exception or error, It just pauses the whole process for 5-10 seconds. I have tried both approaches.

  1. Starting the appium server programmatically to start the test execution.
  2. Started the local appium server manually and test started the test execution.

If anyone can help to resolve this it would be a great help. I would share the logs as well if required.

Note: Android test app doesn’t get stuck or crash during this time.

Please could you drop your logs to help debug this?

error_log.txt (40.5 KB)
This is the error logs, I had intentionally stopped the appium server as soon as I got the issue. If you want I can share you the whole process error logs as well but it will be from another execution process. You will see that I got stale element exception for toast message but then appium server got freezon and toast message was already triggered so it got displayed and disappeared after 2-3 seconds and when the appium resumed it started to look for the toast message element, hence noSuchElementFoundException

@mykola-mokhnach @BrowningL Any ideas that what might be going wrong in this?

try tune waitForIdleTimeout from default 10 sec to e.g. 1 sec

more to read GitHub - appium/appium-uiautomator2-driver: Appium driver for Android UIAutomator2

1 Like

Thanks @Aleksei I will try to implement this. I will set it to 5 seconds, setting 0 seconds will be too difficult to manage as we have to maintain the API responses of the app and other performance issues.