def wrapper(*args, **kwargs):
        try:
            log.i('  --> %s', func.__qualname__)
            ret = func(*args, **kwargs)
            log.i('  <-- %s, %s', func.__qualname__, 'Success')
            return ret
        except WebDriverException as e:
            log.e('WebDriverException, %s', e)
            log.e('  <-- %s, %s, %s', func.__qualname__, 'WebDriverException',
                  'Error')

            if flag in str(e):
                raise WebDriverException(message=e)
            else:
                raise WebDriverException(message=flag +
                                         _screenshot(func.__qualname__))
        except AssertionError as e:
            log.e('AssertionError, %s', e)
            log.e('  <-- %s, %s, %s', func.__qualname__, 'AssertionError',
                  'Error')

            if flag in str(e):
                raise AssertionError(e)
            else:
                raise AssertionError(flag + _screenshot(func.__qualname__))
        except Exception as e:
            log.e('Exception, %s', e)
            log.e('  <-- %s, %s, %s', func.__qualname__, 'Exception', 'Error')

            if flag in str(e):
                raise Exception(e)
            else:
                raise Exception(flag + _screenshot(func.__qualname__))
Beispiel #2
0
 def wrapper(*args, **kwargs):
     try:
         log.i('\t--> %s', func.__qualname__)
         ret = func(*args, **kwargs)
         return ret
     except WebDriverException:
         log.e('\t<-- %s, %s', func.__qualname__, 'Error')
         raise WebDriverException(message=flag +
                                  _screenshot(func.__qualname__))
    def click_element_by_accessibility_id(self,
                                          value,
                                          timeout=10000,
                                          interval=1000):
        """
        click element by accessibility id. in android, wait content-desc
        :param value: value
        :param timeout: timeout(ms) that wait the gaven strings
        :param interval: interval(ms)
        :return:

        raise:
            WebDriverException
        """
        result = self._wait_element('content-desc',
                                    value=value,
                                    timeout=timeout,
                                    interval=interval)
        if result is not None:
            x, y = self._parse_bounds(result.get('bounds'))
            self._tap(x, y)
        else:
            raise WebDriverException(
                'No such accessibility id that value was you gaven.')