How to use the uiautomator2.exceptions.NullPointerExceptionError function in uiautomator2

To help you get started, we’ve selected a few uiautomator2 examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github openatx / uiautomator2 / uiautomator2 / __init__.py View on Github external
            NullObjectExceptionError, NullPointerExceptionError,
            StaleObjectExceptionError),
           delay=3.0,
           jitter=0.5,
           tries=3)
    def jsonrpc_retry_call(self, *args,
                           **kwargs):  # method, params=[], http_timeout=60):

        # if self.__uiautomator_failed:
        #     self.reset_uiautomator()

        try:
            return self.jsonrpc_call(*args, **kwargs)
        except (GatewayError, ):
            warnings.warn(
                "uiautomator2 is not reponding, restart uiautomator2 automatically",
                RuntimeWarning,
github openatx / uiautomator2 / uiautomator2 / __init__.py View on Github external
except (GatewayError, ):
            warnings.warn(
                "uiautomator2 is not reponding, restart uiautomator2 automatically",
                RuntimeWarning,
                stacklevel=1)
            self.reset_uiautomator("uiautomator not running")
            # self.__uiautomator_failed = True
            raise
        except UiAutomationNotConnectedError:
            # warnings.warn("UiAutomation not connected, restart uiautoamtor",
            #               RuntimeWarning,
            #               stacklevel=1)
            self.reset_uiautomator("UiAutomation not connected")
            # self.__uiautomator_failed = True
            raise
        except (NullObjectExceptionError, NullPointerExceptionError,
                StaleObjectExceptionError) as e:
            if args[1] != 'dumpWindowHierarchy':  # args[1] method
                warnings.warn(
                    "uiautomator2 raise exception %s, and run code again" % e,
                    RuntimeWarning,
                    stacklevel=1)
            time.sleep(1)
            return self.jsonrpc_call(*args, **kwargs)
github openatx / uiautomator2 / uiautomator2 / __init__.py View on Github external
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