コード例 #1
0
 def on_call(*args, **kwargs):
     _cls_name = args[0].__class__.__name__
     _met_name = func.__name__
     _element_name = args[0].name
     try:
         result = func(*args, **kwargs)
         if result is not None:
             logger.debug(
                 '[Call]: {0} >> {1} >> {2} [Return]: {3}'.format(
                     _cls_name, _met_name, _element_name, result))
         else:
             logger.debug('[Call]: {0} >> {1} >> {2}'.format(
                 _cls_name, _met_name, _element_name))
         return result
     except NoSuchElementException:
         logger.error(
             '[NoSuchElementException]: Fail to locate element {0}'.
             format(_element_name))
     except WebDriverException as e:
         exc_type, _, _ = sys.exc_info()
         logger.error('[{0}]: {1}'.format(exc_type.__name__,
                                          e).rstrip())
         raise
     except Exception:
         logger.exception('[UnwantedException]:')
         raise
コード例 #2
0
 def send_specific_keys(self, *args):
     keys_set = set()
     redundant_keys = [
         'BACK_SPACE', 'LEFT_SHIFT', 'LEFT_CONTROL', 'LEFT_ALT',
         'ARROW_LEFT', 'ARROW_UP', 'ARROW_RIGHT', 'ARROW_DOWN'
     ]
     try:
         keys_mapping = dict(
             filter(lambda d: d[0] not in redundant_keys,
                    Keys.__dict__.items()))
         for arg in args:
             pattern = re.compile(arg, re.IGNORECASE)
             for attr in keys_mapping:
                 result = re.search(pattern, attr)
                 if result:
                     keys_set.add(attr)
         if keys_set:
             self.driver.send_keys(*keys_set)
             logger.debug(
                 '[Call]: KeyActions >> send_specific_keys >> {0}'.format(
                     ' + '.join(keys_set)))
         else:
             self.driver.send_keys('')
             logger.warning(
                 '[Call]: KeyActions >> send_specific_keys >> empty content'
             )
     except WebDriverException as e:
         exc_type, _, _ = sys.exc_info()
         logger.error('[{0}]: {1}'.format(exc_type.__name__, e).rstrip())
         raise
     except Exception:
         logger.exception('[UnwantedException]:')
         raise
コード例 #3
0
 def wrapper(*args, **kwargs):
     try:
         logger.debug('[Assert]: {0} >> {1}'.format(func.__name__,
                                                    format(args[1:])))
         return func(*args, **kwargs)
     except AssertionError as e:
         args[0].Exc_Stack.append(e)
コード例 #4
0
 def wrapper(*args, **kwargs):
     try:
         result = func(*args, **kwargs)
         logger.debug('Parse "{0}", get config value "{1}"'.format(func.__name__, result))
         return result
     except Exception as e:
         logger.error('Fail to parse "{0}": {1}'.format(func.__name__, e))
         raise e
コード例 #5
0
 def on_call(*args, **kwargs):
     _cls_name = args[0].__class__.__name__
     _met_name = func.__name__
     try:
         result = func(*args, **kwargs)
         _result = True if result else False
         logger.debug('[Call]: {0} >> {1} [Return]: {2}'.format(
             _cls_name, _met_name, _result))
         return result
     except TimeoutException as e:
         logger.warning('[TimeoutException]: {0}'.format(e).rstrip())
     except WebDriverException as e:
         exc_type, _, _ = sys.exc_info()
         logger.error('[{0}]: {1}'.format(exc_type.__name__,
                                          e).rstrip())
         raise
     except Exception:
         logger.exception('[UnwantedException]:')
         raise
コード例 #6
0
 def __getattr__(self, attr):
     logger.debug('Call: {0} >> {1}'.format(cls.__name__, attr))
     method = getattr(self.wrapped, attr)
     return method