Application crashes with StaleElementReferenceException when running multiple scenarios

I’m facing an issue while running multiple scenarios in Appium using python where the application crashes and I encounter a StaleElementReferenceException. However, when I run each scenario individually, everything works correctly. I’m seeking your guidance to understand whether the problem lies in my code or with the application APK.

Here’s the traceback of the error I’m encountering:

Traceback (most recent call last):
  File "path/to/", line 1329, in run
  File "path/to/", line 98, in run
    self.func(context, *args, **kwargs)
  File "features/steps/", line 57, in step_impl
    password_field.send_keys(password)  # Enter the provided password value
  Caused by: androidx.test.uiautomator.StaleObjectException
    at androidx.test.uiautomator.UiObject2.getAccessibilityNodeInfo(
    at io.appium.uiautomator2.handler.request.SafeRequestHandler.handle(
    ... 33 more


  1. Could this issue be caused by my code, or is it more likely to be related to the application APK?
  2. What steps can I take to troubleshoot and resolve this issue?
  3. Are there any best practices or recommendations for handling stale elements in Appium when running multiple scenarios?

Might just be an old version of Uiautomator 2: