Пример #1
0
    def end_setup(self):
        """Ends the setup part of the test

        @return: None
        """
        log('----------------------------- RunningTest -----------------------------'
            )
Пример #2
0
 def quit_drivers(self):
     log('Quitting WebDriver')
     for driver in self.webdriver_instances:
         try:
             driver.quit()
         except Exception, e:
             log('Could not quit the driver ({})'.format(e), INFO)
             pass
Пример #3
0
 def quit_drivers(self):
     log('Quitting WebDriver')
     for driver in self.webdriver_instances:
         try:
             driver.quit()
         except Exception as e:
             log('Could not quit the driver ({})'.format(e), INFO)
             pass
def get_firefox_binary():
    """Gets the firefox binary

    @rtype: FirefoxBinary
    """
    browser_config = BrowserConfig()
    constants_config = ConstantsConfig()
    log_dir = os.path.join(constants_config.get('logs_dir'), 'firefox')
    create_directory(log_dir)

    log_path = os.path.join(log_dir, '{}_{}.log'.format(datetime.datetime.now().isoformat('_'), words.random_word()))
    log_file = open(log_path, 'w')
    log('Firefox log file: {}'.format(log_path))

    binary = FirefoxBinary(log_file=log_file)

    return binary
def get_firefox_profile():
    # TODO: update this so that it is not browser-specific
    constants_config = ConstantsConfig()
    profile_directory = os.path.join(constants_config.get('webdriver_dir'), 'firefox', 'profile', 'tmp')
    create_directory(profile_directory)


    ffprofile = webdriver.FirefoxProfile(profile_directory)

    log_dir = os.path.join(constants_config.get('logs_dir'), 'webdriver')
    create_directory(log_dir)

    log_path = os.path.join(log_dir, '{}_{}.log'.format(datetime.datetime.now().isoformat('_'), words.random_word()))
    log('Selenium log file: {}'.format(log_path))

    # Accept firefox profiles
    ffprofile.set_preference('webdriver.log.file', log_path)
    return ffprofile
def get_firefox_binary():
    """Gets the firefox binary

    @rtype: FirefoxBinary
    """
    browser_config = BrowserConfig()
    constants_config = ConstantsConfig()
    log_dir = os.path.join(constants_config.get('logs_dir'), 'firefox')
    create_directory(log_dir)

    log_path = os.path.join(
        log_dir, '{}_{}.log'.format(datetime.datetime.now().isoformat('_'),
                                    words.random_word()))
    log_file = open(log_path, 'w')
    log('Firefox log file: {}'.format(log_path))

    binary = FirefoxBinary(log_file=log_file)

    return binary
Пример #7
0
    def setUp(self):
        log('----------------------------- SetUp -----------------------------'
            )
        # Order is LIFO, put cleanups in reverse order
        self.addCleanup(lambda: self.cleanup_by_logging_end_statement())
        self.addCleanup(lambda: self.quit_drivers())
        self.addCleanup(lambda: self.stop_displays())

        self.test_id = self.__class__.__name__ + datetime.datetime.now(
        ).strftime("-%Y%m%d-%H%M%S")
        self.is_passed = False

        log_config = LogConfig()
        # set log levels
        selenium_logger = logging.getLogger('easyprocess')
        selenium_logger.setLevel(
            log_config.getint('default_third_party_logging_level'))

        selenium_logger = logging.getLogger('pyvirtualdisplay')
        selenium_logger.setLevel(
            log_config.getint('default_third_party_logging_level'))

        selenium_logger = logging.getLogger('pyvirtualdisplay.abstractdisplay')
        selenium_logger.setLevel(
            log_config.getint('default_third_party_logging_level'))

        selenium_logger = logging.getLogger('paramiko.transport')
        selenium_logger.setLevel(
            log_config.getint('default_third_party_logging_level'))

        selenium_logger = logging.getLogger('requests')
        selenium_logger.setLevel(
            log_config.getint('default_third_party_logging_level'))

        # configure testing logger
        self.logger = Logger.get()
        log('Beginning test {}'.format(self.test_id))

        # Create a data class to use for storing data
        class data(object):
            """Data object for saving data to"""

        self.data = data()
def get_firefox_profile():
    # TODO: update this so that it is not browser-specific
    constants_config = ConstantsConfig()
    profile_directory = os.path.join(constants_config.get('webdriver_dir'),
                                     'firefox', 'profile', 'tmp')
    create_directory(profile_directory)

    ffprofile = webdriver.FirefoxProfile(profile_directory)

    log_dir = os.path.join(constants_config.get('logs_dir'), 'webdriver')
    create_directory(log_dir)

    log_path = os.path.join(
        log_dir, '{}_{}.log'.format(datetime.datetime.now().isoformat('_'),
                                    words.random_word()))
    log('Selenium log file: {}'.format(log_path))

    # Accept firefox profiles
    ffprofile.set_preference('webdriver.log.file', log_path)
    return ffprofile
Пример #9
0
    def setUp(self):
        log('----------------------------- SetUp -----------------------------')
        # Order is LIFO, put cleanups in reverse order
        self.addCleanup(lambda: self.cleanup_by_logging_end_statement())
        self.addCleanup(lambda: self.quit_drivers())
        self.addCleanup(lambda: self.stop_displays())

        self.test_id = self.__class__.__name__ + datetime.datetime.now().strftime("-%Y%m%d-%H%M%S")
        self.is_passed = False

        log_config = LogConfig()
        # set log levels
        selenium_logger = logging.getLogger('easyprocess')
        selenium_logger.setLevel(log_config.getint('default_third_party_logging_level'))

        selenium_logger = logging.getLogger('pyvirtualdisplay')
        selenium_logger.setLevel(log_config.getint('default_third_party_logging_level'))

        selenium_logger = logging.getLogger('pyvirtualdisplay.abstractdisplay')
        selenium_logger.setLevel(log_config.getint('default_third_party_logging_level'))

        selenium_logger = logging.getLogger('paramiko.transport')
        selenium_logger.setLevel(log_config.getint('default_third_party_logging_level'))

        selenium_logger = logging.getLogger('requests')
        selenium_logger.setLevel(log_config.getint('default_third_party_logging_level'))

        # configure testing logger
        self.logger = Logger.get()
        log('Beginning test {}'.format(self.test_id))

        # Create a data class to use for storing data
        class data(object):
            """Data object for saving data to"""

        self.data = data()
Пример #10
0
 def tearDown(self):
     log('----------------------------- TearDown -----------------------------')
     self.check_for_and_set_current_result()
     log('TEST PASSED' if self.is_passed else 'TEST FAILURE')
Пример #11
0
    def end_setup(self):
        """Ends the setup part of the test

        @return: None
        """
        log('----------------------------- RunningTest -----------------------------')
Пример #12
0
 def _skip(self, with_warn=True):
     if with_warn:
         log('Skipped test {}'.format(self.test_id), WARN)
     else:
         log('Skipped test {}'.format(self.test_id))
     raise SkipTest
Пример #13
0
 def cleanup_by_logging_end_statement(self):
     log('Ending test {}'.format(self.test_id))
Пример #14
0
 def stop_displays(self):
     for display in self.display_instances:
         try:
             display.stop()
         except Exception as e:
             log('Could not quit the display ({})'.format(display), INFO)
Пример #15
0
 def stop_displays(self):
     for display in self.display_instances:
         try:
             display.stop()
         except Exception, e:
             log('Could not quit the display ({})'.format(display), INFO)
Пример #16
0
 def _skip(self, with_warn=True):
     if with_warn:
         log('Skipped test {}'.format(self.test_id), WARN)
     else:
         log('Skipped test {}'.format(self.test_id))
     raise SkipTest
Пример #17
0
 def tearDown(self):
     log('----------------------------- TearDown -----------------------------'
         )
     self.check_for_and_set_current_result()
     log('TEST PASSED' if self.is_passed else 'TEST FAILURE')
Пример #18
0
 def cleanup_by_logging_end_statement(self):
     log('Ending test {}'.format(self.test_id))