# Path: viceroy/exceptions.py
# class ResultNotFound(ViceroyException):
#     pass
# 
# Path: viceroy/exceptions.py
# class JavascriptError(ViceroyException):
#     pass


import contextlib
import os
import unittest
from selenium import webdriver
from selenium.webdriver.support.wait import WebDriverWait
from .exceptions import ResultNotFound
from .exceptions import JavascriptError
        try:

            yield driver
        finally:
            driver.quit()

    @classmethod
    def viceroy_get_results(cls):
        with cls.viceroy_server() as port:
            with cls.viceroy_driver() as driver:
                driver.get(
                    'http://localhost:{}{}'.format(port, cls.viceroy_url)
                )
                WebDriverWait(
                    driver,
                    cls.viceroy_timeout
                ).until(
                    lambda _: driver.execute_script(
                        'return window.VICEROY && window.VICEROY.DONE;'
                    )
                )
                return driver.execute_script('return window.VICEROY.RESULTS;')

    @classmethod
    def setUpClass(cls):
        super(ViceroyTestCase, cls).setUpClass()
        cls.viceroy_cache = cls.viceroy_get_results()

    @classmethod
    def tearDownClass(cls):

# Path: viceroy/exceptions.py
# class ResultNotFound(ViceroyException):
#     pass
# 
# Path: viceroy/exceptions.py
# class JavascriptError(ViceroyException):
#     pass


# Path: viceroy/api.py
import contextlib
import os
import unittest
from selenium import webdriver
from selenium.webdriver.support.wait import WebDriverWait
from .exceptions import ResultNotFound
from .exceptions import JavascriptError

        try:

            yield driver
        finally:
            driver.quit()

    @classmethod
    def viceroy_get_results(cls):
        with cls.viceroy_server() as port:
            with cls.viceroy_driver() as driver:
                driver.get(
                    'http://localhost:{}{}'.format(port, cls.viceroy_url)
                )
                WebDriverWait(
                    driver,
                    cls.viceroy_timeout
                ).until(
                    lambda _: driver.execute_script(
                        'return window.VICEROY && window.VICEROY.DONE;'
                    )
                )
                return driver.execute_script('return window.VICEROY.RESULTS;')

    @classmethod
    def setUpClass(cls):
        super(ViceroyTestCase, cls).setUpClass()
        cls.viceroy_cache = cls.viceroy_get_results()

    @classmethod
    def tearDownClass(cls):

        if hasattr(cls, 'viceroy_cache'):