# Path: selene/support/shared/browser.py
# class SharedBrowser(Browser):
#         class CallableString(str):
#     def __init__(self, config: SharedConfig):
#     def config(self) -> SharedConfig:
#     def with_(self, config: Config = None, **config_as_kwargs) -> Browser:
#     def open(self, relative_or_absolute_url: str):
#     def driver(self) -> WebDriver:
#         def return_driver(this) -> WebDriver:
#     def save_screenshot(self, file: str = None):
#     def last_screenshot(self) -> str:
#     def latest_screenshot(self) -> str:
#             def __new__(cls, value):
#             def __call__(self, *args, **kwargs):
#             def __bool__(self):
#     def save_page_source(self, file: str = None) -> Optional[str]:
#     def last_page_source(self) -> str:
#     def latest_page_source(self):
#     def quit(self) -> None:
#     def quit_driver(self):
#     def close(self):
#     def set_driver(self, webdriver: WebDriver):
#     def open_url(self, absolute_or_relative_url):
#     def elements(self, css_or_xpath_or_by: Union[str, tuple]) -> Collection:
#     def wait_to(self, webdriver_condition, timeout=None, polling=None):
#     def execute_script(self, script, *args):
#     def title(self):
#     def take_screenshot(self, path=None, filename=None):
# 
# Path: selene/support/webdriver.py
# class Help:  # todo: should we make it private? like call it _Help (or think on better name)
#     # what about this style for example: ExtendedWebdriver(driver).is_alive() ?
#     # over: Help(driver).has_browser_still_alive() ?
# 
#     def __init__(self, driver: WebDriver):
#         self._driver = driver
# 
#     def has_browser_still_alive(self):
#         return on_error_return_false(lambda: self._driver.title is not None)
# 
#     def save_page_source(self, file: str) -> Optional[str]:
#         if not file.lower().endswith('.html'):
#             warnings.warn(
#                 "name used for saved pagesource does not match file "
#                 "type. It should end with an `.html` extension",
#                 UserWarning,
#             )
# 
#         html = self._driver.page_source
# 
#         try:
#             with open(file, 'w', encoding="utf-8") as f:
#                 f.write(html)
#         except OSError:
#             return None
#         finally:
#             del html
# 
#         return file
# 
#     def save_screenshot(self, file: str) -> Optional[str]:
#         if not file.lower().endswith('.png'):
#             warnings.warn(
#                 "name used for saved pagesource does not match file "
#                 "type. It should end with an `.png` extension",
#                 UserWarning,
#             )
# 
#         return file if self._driver.get_screenshot_as_file(file) else None


from selenium import webdriver
from selenium.webdriver.chrome.service import Service
from webdriver_manager.chrome import ChromeDriverManager
from webdriver_manager.utils import ChromeType
from selene.support.shared import browser
from selene.support.webdriver import Help
# MIT License
#
# Copyright (c) 2015-2021 Iakiv Kramarenko
#
# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documentation files (the "Software"), to deal
# in the Software without restriction, including without limitation the rights
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
# copies of the Software, and to permit persons to whom the Software is
# furnished to do so, subject to the following conditions:
#
# The above copyright notice and this permission notice shall be included in all
# copies or substantial portions of the Software.
#
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
# SOFTWARE.




def teardown_module():
    browser.quit()


def test_automatic_quit_for_previous_driver():

# Path: selene/support/shared/browser.py
# class SharedBrowser(Browser):
#         class CallableString(str):
#     def __init__(self, config: SharedConfig):
#     def config(self) -> SharedConfig:
#     def with_(self, config: Config = None, **config_as_kwargs) -> Browser:
#     def open(self, relative_or_absolute_url: str):
#     def driver(self) -> WebDriver:
#         def return_driver(this) -> WebDriver:
#     def save_screenshot(self, file: str = None):
#     def last_screenshot(self) -> str:
#     def latest_screenshot(self) -> str:
#             def __new__(cls, value):
#             def __call__(self, *args, **kwargs):
#             def __bool__(self):
#     def save_page_source(self, file: str = None) -> Optional[str]:
#     def last_page_source(self) -> str:
#     def latest_page_source(self):
#     def quit(self) -> None:
#     def quit_driver(self):
#     def close(self):
#     def set_driver(self, webdriver: WebDriver):
#     def open_url(self, absolute_or_relative_url):
#     def elements(self, css_or_xpath_or_by: Union[str, tuple]) -> Collection:
#     def wait_to(self, webdriver_condition, timeout=None, polling=None):
#     def execute_script(self, script, *args):
#     def title(self):
#     def take_screenshot(self, path=None, filename=None):
# 
# Path: selene/support/webdriver.py
# class Help:  # todo: should we make it private? like call it _Help (or think on better name)
#     # what about this style for example: ExtendedWebdriver(driver).is_alive() ?
#     # over: Help(driver).has_browser_still_alive() ?
# 
#     def __init__(self, driver: WebDriver):
#         self._driver = driver
# 
#     def has_browser_still_alive(self):
#         return on_error_return_false(lambda: self._driver.title is not None)
# 
#     def save_page_source(self, file: str) -> Optional[str]:
#         if not file.lower().endswith('.html'):
#             warnings.warn(
#                 "name used for saved pagesource does not match file "
#                 "type. It should end with an `.html` extension",
#                 UserWarning,
#             )
# 
#         html = self._driver.page_source
# 
#         try:
#             with open(file, 'w', encoding="utf-8") as f:
#                 f.write(html)
#         except OSError:
#             return None
#         finally:
#             del html
# 
#         return file
# 
#     def save_screenshot(self, file: str) -> Optional[str]:
#         if not file.lower().endswith('.png'):
#             warnings.warn(
#                 "name used for saved pagesource does not match file "
#                 "type. It should end with an `.png` extension",
#                 UserWarning,
#             )
# 
#         return file if self._driver.get_screenshot_as_file(file) else None


# Path: tests/acceptance/mixed_driver_management/e_shared_browser_closes_its_opened_driver_if_new_custom_driver_passed_test.py
from selenium import webdriver
from selenium.webdriver.chrome.service import Service
from webdriver_manager.chrome import ChromeDriverManager
from webdriver_manager.utils import ChromeType
from selene.support.shared import browser
from selene.support.webdriver import Help

# MIT License
#
# Copyright (c) 2015-2021 Iakiv Kramarenko
#
# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documentation files (the "Software"), to deal
# in the Software without restriction, including without limitation the rights
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
# copies of the Software, and to permit persons to whom the Software is
# furnished to do so, subject to the following conditions:
#
# The above copyright notice and this permission notice shall be included in all
# copies or substantial portions of the Software.
#
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
# SOFTWARE.




def teardown_module():
    browser.quit()


def test_automatic_quit_for_previous_driver():

    driver_from_test_d = browser.config.driver