Esempio n. 1
0
    def __init__(self,
                 driver_wrapper,
                 msg='WebDriverWrapper Exception',
                 execute_on_error=None):

        js_executor = JavascriptExecutor.JavascriptExecutor(driver_wrapper)
        error_message = None

        try:
            # error_message sometimes has encoding problems
            error_message = "Message: {} || Page Title: {} || Current URL: {}"\
                .format(msg, driver_wrapper.driver.title, driver_wrapper.driver.current_url)

            # insert the error message into the page
            js_executor.execute_template('messageInjectorTemplate',
                                         {'message': error_message})

        except Exception as e:
            error_message = 'Unable to build error message: {}'.format(
                e) if error_message is None else error_message

        finally:
            Logger.get().warn(error_message)
            WebDriverException.__init__(self, error_message)

        # pass it an anonymous function to execute on instantiation
        if execute_on_error is not None and hasattr(execute_on_error,
                                                    '__call__'):
            execute_on_error()
Esempio n. 2
0
    def __init__(self, driver=None, driver_wrapper=None, logger=None):
        """
        @type driver_wrapper: WebDriverWrapper
        @param driver_wrapper: Driver Wrapper
        """
        self.logger = logger if logger is not None else Logger.get()

        if driver is not None:
            self.driver = driver
            self.title = self.driver.title
            self.current_url = self.driver.current_url
            self.page_source = self.driver.page_source
        elif driver_wrapper is not None:
            self.driver_wrapper = driver_wrapper
            self.dw = self.driver_wrapper
            self.title = self.driver_wrapper.title()
            self.current_url = self.driver_wrapper.current_url()
            self.page_source = self.driver_wrapper.page_source()
Esempio n. 3
0
    def __init__(self, driver=None, driver_wrapper=None, logger=None):
        """
        @type driver_wrapper: WebDriverWrapper
        @param driver_wrapper: Driver Wrapper
        """
        self.logger = logger if logger is not None else Logger.get()

        if driver is not None:
            self.driver = driver
            self.title = self.driver.title
            self.current_url = self.driver.current_url
            self.page_source = self.driver.page_source
        elif driver_wrapper is not None:
            self.driver_wrapper = driver_wrapper
            self.dw = self.driver_wrapper
            self.title = self.driver_wrapper.title()
            self.current_url = self.driver_wrapper.current_url()
            self.page_source = self.driver_wrapper.page_source()
Esempio n. 4
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()
Esempio n. 5
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()
Esempio n. 6
0
class WebDriverWrapperException(WebDriverException):
    def __init__(self,
                 driver_wrapper,
                 msg='WebDriverWrapper Exception',
                 execute_on_error=None):

        js_executor = JavascriptExecutor.JavascriptExecutor(driver_wrapper)
        error_message = None

        try:
            # error_message sometimes has encoding problems
            error_message = "Message: {} || Page Title: {} || Current URL: {}"\
                .format(msg, driver_wrapper.driver.title, driver_wrapper.driver.current_url)

            # insert the error message into the page
            js_executor.execute_template('messageInjectorTemplate',
                                         {'message': error_message})

        except Exception, e:
            error_message = 'Unable to build error message: {}'.format(
                e) if error_message is None else error_message

        finally:
            Logger.get().warn(error_message)
            WebDriverException.__init__(self, error_message)

        # pass it an anonymous function to execute on instantiation
        if execute_on_error is not None and hasattr(execute_on_error,
                                                    '__call__'):
            execute_on_error()
from selenium.common.exceptions import WebDriverException

from coyote_framework.log import Logger


class WebDriverWrapperException(WebDriverException):

    def __init__(self, driver_wrapper, msg='WebDriverWrapper Exception', execute_on_error=None):

        js_executor = JavascriptExecutor.JavascriptExecutor(driver_wrapper)
        error_message = None

        try:
            # error_message sometimes has encoding problems
            error_message = "Message: {} || Page Title: {} || Current URL: {}"\
                .format(msg, driver_wrapper.driver.title, driver_wrapper.driver.current_url)

            # insert the error message into the page
            js_executor.execute_template('messageInjectorTemplate', {'message': error_message})

        except Exception, e:
            error_message = 'Unable to build error message: {}'.format(e) if error_message is None else error_message

        finally:
            Logger.get().warn(error_message)
            WebDriverException.__init__(self, error_message)

        # pass it an anonymous function to execute on instantiation
        if execute_on_error is not None and hasattr(execute_on_error, '__call__'):
            execute_on_error()