Exemple #1
0
    def tearDown(self):
        failed = True
        if hasattr(self, '_outcome'):
            # python3
            failed = not self._outcome.success
        elif hasattr(self, '_resultForDoCleanups') and hasattr(
                self._resultForDoCleanups, 'result'):
            # nose
            failed = not self._resultForDoCleanups.result.wasSuccessful()
        elif hasattr(self, '_resultForDoCleanups') and hasattr(
                self._resultForDoCleanups, 'current_failed'):
            # python2
            failed = self._resultForDoCleanups.current_failed

        if failed:
            name = self.id()
            filename = u'_'.join(
                [name,
                 self.browser.get_browser_initials(),
                 get_timestamp()])
            try:
                self.browser.save_screenshot(self.FAILED_SCREENSHOT_FOLDER,
                                             filename + u'.png')
            except Exception:
                formatted_exc = traceback.format_exc()
                self.browser.logger.info(formatted_exc)
        TestCase.tearDown(self)

        if self.browser.logger:
            self.browser.logger.info(u"-" * self.TC_NAME_WIDTH)
Exemple #2
0
 def __init__(self, browser_name=None, logger=None, timeout=5, **kwargs):
     if browser_name:
         self.__browser_name = browser_name
     else:
         self.__browser_name = self.DEFAULT_BROWSER
     self.logger = logger
     self.__timeout = timeout
     self._driver = self.__create_driver(self.__browser_name, **kwargs)
     prefix = u'easyselenium_' + get_timestamp() + u'_'
     self.__screenshot_path = tempfile.mkdtemp(prefix=prefix)
     self.mouse = Mouse(self)
Exemple #3
0
    def save_screenshot(self, saving_dir=None, filename=None):
        if not saving_dir:
            saving_dir = self.__screenshot_path
        if not filename:
            filename = get_timestamp() + '.png'
        path_to_file = os.path.abspath(os.path.join(saving_dir,
                                                    filename))

        self._safe_log(u"Saving screenshot to '%s'", path_to_file)

        self._driver.save_screenshot(path_to_file)
        return path_to_file
Exemple #4
0
    def save_screenshot(self, saving_dir=None, filename=None):
        if not saving_dir:
            saving_dir = self.__screenshot_path
        if not filename:
            filename = get_timestamp() + '.png'
        path_to_file = os.path.abspath(os.path.join(saving_dir,
                                                    filename))

        self._safe_log(u"Saving screenshot to '%s'",
                       path_to_file)

        self._driver.save_screenshot(path_to_file)
        return path_to_file
Exemple #5
0
    def tearDown(self):
        if (self._resultForDoCleanups.errors or
                self._resultForDoCleanups.failures):
            name = self.id()
            filename = u'_'.join([name,
                                  self.browser.get_browser_initials(),
                                  get_timestamp()])
            try:
                self.browser.save_screenshot(self.FAILED_SCREENSHOT_FOLDER,
                                             filename + u'.png')
            except Exception:
                formatted_exc = traceback.format_exc()
                self.browser.logger.info(formatted_exc)
        TestCase.tearDown(self)

        if self.browser.logger:
            self.browser.logger.info(u"-" * self.TC_NAME_WIDTH)