Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
if isinstance(
err.data,
six.string_types) and 'UiAutomation not connected' in err.data:
err.__class__ = UiAutomationNotConnectedError
elif err.message:
if is_exception(err, 'uiautomator.UiObjectNotFoundException'):
err.__class__ = UiObjectNotFoundError
elif is_exception(err, 'android.support.test.uiautomator.StaleObjectException'):
# StaleObjectException
# https://developer.android.com/reference/android/support/test/uiautomator/StaleObjectException.html
# A StaleObjectException exception is thrown when a UiObject2 is used after the underlying View has been destroyed.
# In this case, it is necessary to call findObject(BySelector) to obtain a new UiObject2 instance.
err.__class__ = StaleObjectExceptionError
elif is_exception(err, 'java.lang.NullObjectException'):
err.__class__ = NullObjectExceptionError
elif is_exception(err, 'java.lang.NullPointerException'):
err.__class__ = NullPointerExceptionError
raise err