# Path: tests/base.py
# class TestCase(unittest.TestCase):
#     """Base class for testing wdom modules.
# 
#     This class is a sub class of the ``unittest.TestCase``. After all test
#     methods, reset wdom's global objects like document, application, and
#     elements. If you use ``tearDown`` method, do not forget to call
#     ``super().tearDown()``.
#     """
# 
#     def setUp(self) -> None:
#         """Reset WDOM states."""
#         super().setUp()
#         reset()
# 
#     def tearDown(self) -> None:
#         """Reset WDOM states."""
#         reset()
#         super().tearDown()
# 
#     def assertIsTrue(self, bl: bool) -> None:
#         """Check arg is exactly True, not truthy."""
#         self.assertIs(bl, True)
# 
#     def assertIsFalse(self, bl: bool) -> None:
#         """Check arg is exactly False, not falsy."""
#         self.assertIs(bl, False)
# 
# Path: tests/test_selenium/base.py
# def _get_chromedriver_path() -> str:
# def get_chrome_options() -> webdriver.ChromeOptions:
# def start_webdriver() -> None:
# def close_webdriver() -> None:
# def get_webdriver() -> WebDriver:
# def _clear() -> None:
# def start_remote_browser() -> None:
#     def start_browser() -> None:
# def close_remote_browser() -> None:
# def get_remote_browser() -> WebDriver:
#     def __init__(self, conn: Connection) -> None:
#     def set_element_by_id(self, id: int) -> Union[bool, str]:
#     def quit(self) -> str:
#     def close(self) -> str:
#     def _execute_method(self, method: str, args: Iterable[str]) -> None:
#     def run(self) -> None:  # noqa: C901
# def wait_for() -> str:
# async def wait_coro() -> str:
# def _get_properties(cls: type) -> Set[str]:
#     def __getattr__(self, attr: str) -> Connection:
#         def wrapper(*args: str) -> str:
#     def start(self) -> None:
#     def tearDown(self) -> None:
#     def port(self) -> Optional[str]:
#     def wait(self, timeout: float = None, times: int = 1) -> None:
#     def wait_until(self, func: Callable[[], Any],
#                    timeout: float = None) -> None:
#     def _set_element(self, node: Element) -> Union[bool, str]:
#     def set_element(self, node: Element, timeout: float = None) -> bool:
#     def setUpClass(cls) -> None:  # noqa: D102
#     def tearDownClass(cls) -> None:  # noqa: D102
#     def start(self) -> None:
#         def start_server(port: int) -> None:
#     def tearDown(self) -> None:
#     def wait(self, timeout: float = None, times: int = 1) -> None:
#     def wait_until(self, func: Callable[[], Any],
#                    timeout: float = None) -> None:
#     def send_keys(self, element: Element, keys: str) -> None:
# class BrowserController:
# class Controller:
# class ProcessController(Controller):
# class RemoteBrowserController(Controller):
# class RemoteElementController(Controller):
# class TimeoutError(Exception):
# class RemoteBrowserTestCase:
# class WebDriverTestCase:
# 
# Path: tests/test_selenium/base.py
# def get_webdriver() -> WebDriver:
#     """Return WebDriver of current process.
# 
#     If it is not started yet, start and return it.
#     """
#     if globals().get('local_webdriver') is None:
#         start_webdriver()
#     return local_webdriver
# 
# def close_webdriver() -> None:
#     """Close WebDriver."""
#     global local_webdriver
#     if local_webdriver is not None:
#         local_webdriver.close()
#         local_webdriver = None


import sys
import os
import asyncio
import subprocess
import unittest
from os import path
from tempfile import NamedTemporaryFile
from selenium.common.exceptions import NoSuchElementException
from syncer import sync
from ..base import TestCase
from .base import free_port, browser_implict_wait
from .base import get_webdriver, close_webdriver
doc = get_document()
doc.body.appendChild(H1('FIRST', id='h1'))
doc.add_cssfile('testdir/test.css')
server.add_static_path('testdir', '{curdir}/testdir')  # noqa: E501
server.start_server(loop=loop, check_time=10)
loop.run_forever()
'''.format(curdir=CURDIR)

css_path = path.join(CURDIR, 'testdir/test.css')
src_css = '''
h1 {color: #000000;}
'''
src_css_post = '''
h1 {color: #ff0000;}
'''

_src = src_base.splitlines()
_src.insert(12, 'server.exclude_patterns.append(r\'test.css\')')
src_exclude_css = '\n'.join(_src)
_src = src_base.splitlines()
_src.insert(12, 'server.exclude_patterns.append(r\'testdi*\')')
src_exclude_dir = '\n'.join(_src)


@unittest.skipIf('TRAVIS' in os.environ, 'skip selenium tests on Travis')
class TestAutoReload(TestCase):
    wait_time = 3 if os.getenv('TRAVIS') else 1

    @classmethod
    def setUpClass(cls):

# Path: tests/base.py
# class TestCase(unittest.TestCase):
#     """Base class for testing wdom modules.
# 
#     This class is a sub class of the ``unittest.TestCase``. After all test
#     methods, reset wdom's global objects like document, application, and
#     elements. If you use ``tearDown`` method, do not forget to call
#     ``super().tearDown()``.
#     """
# 
#     def setUp(self) -> None:
#         """Reset WDOM states."""
#         super().setUp()
#         reset()
# 
#     def tearDown(self) -> None:
#         """Reset WDOM states."""
#         reset()
#         super().tearDown()
# 
#     def assertIsTrue(self, bl: bool) -> None:
#         """Check arg is exactly True, not truthy."""
#         self.assertIs(bl, True)
# 
#     def assertIsFalse(self, bl: bool) -> None:
#         """Check arg is exactly False, not falsy."""
#         self.assertIs(bl, False)
# 
# Path: tests/test_selenium/base.py
# def _get_chromedriver_path() -> str:
# def get_chrome_options() -> webdriver.ChromeOptions:
# def start_webdriver() -> None:
# def close_webdriver() -> None:
# def get_webdriver() -> WebDriver:
# def _clear() -> None:
# def start_remote_browser() -> None:
#     def start_browser() -> None:
# def close_remote_browser() -> None:
# def get_remote_browser() -> WebDriver:
#     def __init__(self, conn: Connection) -> None:
#     def set_element_by_id(self, id: int) -> Union[bool, str]:
#     def quit(self) -> str:
#     def close(self) -> str:
#     def _execute_method(self, method: str, args: Iterable[str]) -> None:
#     def run(self) -> None:  # noqa: C901
# def wait_for() -> str:
# async def wait_coro() -> str:
# def _get_properties(cls: type) -> Set[str]:
#     def __getattr__(self, attr: str) -> Connection:
#         def wrapper(*args: str) -> str:
#     def start(self) -> None:
#     def tearDown(self) -> None:
#     def port(self) -> Optional[str]:
#     def wait(self, timeout: float = None, times: int = 1) -> None:
#     def wait_until(self, func: Callable[[], Any],
#                    timeout: float = None) -> None:
#     def _set_element(self, node: Element) -> Union[bool, str]:
#     def set_element(self, node: Element, timeout: float = None) -> bool:
#     def setUpClass(cls) -> None:  # noqa: D102
#     def tearDownClass(cls) -> None:  # noqa: D102
#     def start(self) -> None:
#         def start_server(port: int) -> None:
#     def tearDown(self) -> None:
#     def wait(self, timeout: float = None, times: int = 1) -> None:
#     def wait_until(self, func: Callable[[], Any],
#                    timeout: float = None) -> None:
#     def send_keys(self, element: Element, keys: str) -> None:
# class BrowserController:
# class Controller:
# class ProcessController(Controller):
# class RemoteBrowserController(Controller):
# class RemoteElementController(Controller):
# class TimeoutError(Exception):
# class RemoteBrowserTestCase:
# class WebDriverTestCase:
# 
# Path: tests/test_selenium/base.py
# def get_webdriver() -> WebDriver:
#     """Return WebDriver of current process.
# 
#     If it is not started yet, start and return it.
#     """
#     if globals().get('local_webdriver') is None:
#         start_webdriver()
#     return local_webdriver
# 
# def close_webdriver() -> None:
#     """Close WebDriver."""
#     global local_webdriver
#     if local_webdriver is not None:
#         local_webdriver.close()
#         local_webdriver = None


# Path: tests/test_selenium/test_server.py
import sys
import os
import asyncio
import subprocess
import unittest
from os import path
from tempfile import NamedTemporaryFile
from selenium.common.exceptions import NoSuchElementException
from syncer import sync
from ..base import TestCase
from .base import free_port, browser_implict_wait
from .base import get_webdriver, close_webdriver

doc = get_document()
doc.body.appendChild(H1('FIRST', id='h1'))
doc.add_cssfile('testdir/test.css')
server.add_static_path('testdir', '{curdir}/testdir')  # noqa: E501
server.start_server(loop=loop, check_time=10)
loop.run_forever()
'''.format(curdir=CURDIR)

css_path = path.join(CURDIR, 'testdir/test.css')
src_css = '''
h1 {color: #000000;}
'''
src_css_post = '''
h1 {color: #ff0000;}
'''

_src = src_base.splitlines()
_src.insert(12, 'server.exclude_patterns.append(r\'test.css\')')
src_exclude_css = '\n'.join(_src)
_src = src_base.splitlines()
_src.insert(12, 'server.exclude_patterns.append(r\'testdi*\')')
src_exclude_dir = '\n'.join(_src)


@unittest.skipIf('TRAVIS' in os.environ, 'skip selenium tests on Travis')
class TestAutoReload(TestCase):
    wait_time = 3 if os.getenv('TRAVIS') else 1

    @classmethod
    def setUpClass(cls):

        cls.wd = get_webdriver()