# Path: webdriverwrapper/exceptions.py
# class ErrorPageException(WebdriverWrapperException):
#     """
#     Exception raised when there is some unexpected error page. Like page 404,
#     500 and so on.
#     """
# 
#     def __init__(self, url, error_page, expected_error_page, allowed_error_pages, traceback=None):
#         if expected_error_page:
#             msg = 'Expected error page "{}", but found "{}" instead.'.format(expected_error_page, error_page)
#         else:
#             msg = 'Unexpected error page "{}".'.format(error_page)
#         if allowed_error_pages:
#             msg += ' Allowed error pages: "{}"'.format(allowed_error_pages)
#         if traceback:
#             msg += '\n\nTraceback:\n{}'.format(traceback)
#         super(ErrorPageException, self).__init__(url, msg)
# 
# class ErrorMessagesException(WebdriverWrapperException):
#     """
#     Exception raised when there is some unexpected error message. Like "some
#     field is mandatory", "wrong e-mail" and so on.
#     """
# 
#     def __init__(self, url, error_messages, expected_error_messages, allowed_error_messages):
#         if expected_error_messages:
#             msg = 'Expected error messages "{}", but found "{}" instead.'.format(expected_error_messages, error_messages)
#         else:
#             msg = 'Unexpected error messages "{}".'.format(error_messages)
#         if allowed_error_messages:
#             msg += ' Allowed error messages: "{}"'.format(allowed_error_messages)
#         super(ErrorMessagesException, self).__init__(url, msg)
# 
# class JSErrorsException(WebdriverWrapperException):
#     """
#     Exception raised when there is some JS error.
# 
#     See :py:meth:`get_js_errors <webdriverwrapper.errors.WebdriverWrapperErrorMixin.get_js_errors>`
#     for more information.
#     """
# 
#     def __init__(self, url, js_errors):
#         msg = 'Unexpected JavaScript errors "{}".'.format(js_errors)
#         super(JSErrorsException, self).__init__(url, msg)


from selenium.common.exceptions import NoSuchElementException
from .exceptions import ErrorPageException, ErrorMessagesException, JSErrorsException
        :py:func:`.expected_error_page`, :py:func:`.allowed_error_pages`,
        :py:func:`.expected_error_messages` and :py:func:`.allowed_error_messages`.
        """
        # Close unexpected alerts (it's blocking).
        self.close_alert(ignore_exception=True)

        expected_error_pages = set([expected_error_page]) if expected_error_page else set()
        allowed_error_pages = set(allowed_error_pages)
        error_page = self.get_error_page()
        error_pages = set([error_page]) if error_page else set()
        if (
                error_pages & expected_error_pages != expected_error_pages
                or
                error_pages - (expected_error_pages | allowed_error_pages)
        ):
            traceback = self.get_error_traceback()
            raise ErrorPageException(self.current_url, error_page, expected_error_page, allowed_error_pages, traceback)

        error_messages = set(self.get_error_messages())
        expected_error_messages = set(expected_error_messages)
        allowed_error_messages = error_messages if allowed_error_messages is ANY else set(allowed_error_messages)
        if (
                error_messages & expected_error_messages != expected_error_messages
                or
                error_messages - (expected_error_messages | allowed_error_messages)
        ):
            raise ErrorMessagesException(self.current_url, error_messages, expected_error_messages, allowed_error_messages)

        js_errors = self.get_js_errors()
        if js_errors:

# Path: webdriverwrapper/exceptions.py
# class ErrorPageException(WebdriverWrapperException):
#     """
#     Exception raised when there is some unexpected error page. Like page 404,
#     500 and so on.
#     """
# 
#     def __init__(self, url, error_page, expected_error_page, allowed_error_pages, traceback=None):
#         if expected_error_page:
#             msg = 'Expected error page "{}", but found "{}" instead.'.format(expected_error_page, error_page)
#         else:
#             msg = 'Unexpected error page "{}".'.format(error_page)
#         if allowed_error_pages:
#             msg += ' Allowed error pages: "{}"'.format(allowed_error_pages)
#         if traceback:
#             msg += '\n\nTraceback:\n{}'.format(traceback)
#         super(ErrorPageException, self).__init__(url, msg)
# 
# class ErrorMessagesException(WebdriverWrapperException):
#     """
#     Exception raised when there is some unexpected error message. Like "some
#     field is mandatory", "wrong e-mail" and so on.
#     """
# 
#     def __init__(self, url, error_messages, expected_error_messages, allowed_error_messages):
#         if expected_error_messages:
#             msg = 'Expected error messages "{}", but found "{}" instead.'.format(expected_error_messages, error_messages)
#         else:
#             msg = 'Unexpected error messages "{}".'.format(error_messages)
#         if allowed_error_messages:
#             msg += ' Allowed error messages: "{}"'.format(allowed_error_messages)
#         super(ErrorMessagesException, self).__init__(url, msg)
# 
# class JSErrorsException(WebdriverWrapperException):
#     """
#     Exception raised when there is some JS error.
# 
#     See :py:meth:`get_js_errors <webdriverwrapper.errors.WebdriverWrapperErrorMixin.get_js_errors>`
#     for more information.
#     """
# 
#     def __init__(self, url, js_errors):
#         msg = 'Unexpected JavaScript errors "{}".'.format(js_errors)
#         super(JSErrorsException, self).__init__(url, msg)


# Path: webdriverwrapper/errors.py
from selenium.common.exceptions import NoSuchElementException
from .exceptions import ErrorPageException, ErrorMessagesException, JSErrorsException

        :py:func:`.expected_error_page`, :py:func:`.allowed_error_pages`,
        :py:func:`.expected_error_messages` and :py:func:`.allowed_error_messages`.
        """
        # Close unexpected alerts (it's blocking).
        self.close_alert(ignore_exception=True)

        expected_error_pages = set([expected_error_page]) if expected_error_page else set()
        allowed_error_pages = set(allowed_error_pages)
        error_page = self.get_error_page()
        error_pages = set([error_page]) if error_page else set()
        if (
                error_pages & expected_error_pages != expected_error_pages
                or
                error_pages - (expected_error_pages | allowed_error_pages)
        ):
            traceback = self.get_error_traceback()
            raise ErrorPageException(self.current_url, error_page, expected_error_page, allowed_error_pages, traceback)

        error_messages = set(self.get_error_messages())
        expected_error_messages = set(expected_error_messages)
        allowed_error_messages = error_messages if allowed_error_messages is ANY else set(allowed_error_messages)
        if (
                error_messages & expected_error_messages != expected_error_messages
                or
                error_messages - (expected_error_messages | allowed_error_messages)
        ):
            raise ErrorMessagesException(self.current_url, error_messages, expected_error_messages, allowed_error_messages)

        js_errors = self.get_js_errors()
        if js_errors:

            raise JSErrorsException(self.current_url, js_errors)