# 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




class ViceroyTestCase(unittest.TestCase):
    viceroy_url = '/'
    viceroy_timeout = 30
    viceroy_driver_class = None

    @classmethod
    @contextlib.contextmanager
    def viceroy_server(cls):
        raise NotImplementedError()

    @classmethod
    @contextlib.contextmanager
    def viceroy_driver(cls):
        if isinstance(cls.viceroy_driver_class, webdriver.Remote):
            driver_class = cls.viceroy_driver_class
        elif isinstance(cls.viceroy_driver_class, str):
            driver_class = getattr(webdriver, cls.viceroy_driver_class)
        elif 'SELENIUM_WEBDRIVER' in os.environ:
            driver_class = getattr(webdriver, os.environ['SELENIUM_WEBDRIVER'])
        else:
            driver_class = webdriver.Firefox
        driver = driver_class()
        try:

            yield driver

# 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





class ViceroyTestCase(unittest.TestCase):
    viceroy_url = '/'
    viceroy_timeout = 30
    viceroy_driver_class = None

    @classmethod
    @contextlib.contextmanager
    def viceroy_server(cls):
        raise NotImplementedError()

    @classmethod
    @contextlib.contextmanager
    def viceroy_driver(cls):
        if isinstance(cls.viceroy_driver_class, webdriver.Remote):
            driver_class = cls.viceroy_driver_class
        elif isinstance(cls.viceroy_driver_class, str):
            driver_class = getattr(webdriver, cls.viceroy_driver_class)
        elif 'SELENIUM_WEBDRIVER' in os.environ:
            driver_class = getattr(webdriver, os.environ['SELENIUM_WEBDRIVER'])
        else:
            driver_class = webdriver.Firefox
        driver = driver_class()
        try:

            yield driver

        finally: