Example #1
0
    def find_element(self, path):
        if path.type:
            try:
                WebDriverWait(self.driver, 30).until(
                    EC.presence_of_element_located((path.type, path.value)))
            except TimeoutException as e:
                logging.error(traceback.format_exc())
                handle_screenshot(self.driver, settings.EXCEPTION_IMAGE_PATH)
        _fun = getattr(self.driver, path.func)
        element = _fun(path.value)
        # need auto screenshot
        if not path.need_shot:
            return element
        for action in ['click', 'send_keys']:
            fun = getattr(element, action)

            def wrap(args=None, _fun=fun, _action=action):
                if args:
                    _fun(args)
                else:
                    _fun()
                handle_screenshot(self.driver, settings.NORMAL_IMAGE_PATH)

            setattr(element, action, wrap)
        return element
Example #2
0
 def wrapped_tear_down(self):
     tear_down(self)
     errors = self._outcome.errors
     val = None
     for error in errors:
         val = val or error[1]
     if val:
         etype, value, tb = val
         trace = ''.join(
             traceback.format_exception(etype=etype,
                                        value=value,
                                        tb=tb,
                                        limit=None))
         logging.error(trace)
         handle_screenshot(self.driver, settings.EXCEPTION_IMAGE_PATH)
     logging.info('Test Case Finish: {}'.format(repr(self)))
Example #3
0
 def wrap(args=None, _fun=fun, _action=action):
     if args:
         _fun(args)
     else:
         _fun()
     handle_screenshot(self.driver, settings.NORMAL_IMAGE_PATH)