# Path: selene/core/exceptions.py
# class TimeoutException(AssertionError):
#     def __init__(self, msg=None):
#         self.msg = msg
# 
#     def __str__(self):
#         exception_msg = "Message: %s\n" % self.msg
#         return exception_msg
# 
# Path: tests/integration/helpers/givenpage.py
# class GivenPage:
#     def __init__(self, driver):
#         self._driver = driver
# 
#     def load_body_with_timeout(self, body, timeout):
#         return LoadedHtmlPage(self._driver).render_body_with_timeout(
#             body, timeout
#         )
# 
#     def opened_with_body_with_timeout(self, body, timeout):
#         return LoadingHtmlPage(timeout, body).load_in(self._driver)
# 
#     def opened_with_body(self, body):
#         return self.opened_with_body_with_timeout(body, 0)
# 
#     def opened_empty(self):
#         return LoadingHtmlPage().load_in(self._driver)
# 
#     def load_body(self, body):
#         return LoadedHtmlPage(self._driver).render_body(body)
# 
#     def execute_script_with_timeout(self, script, timeout):
#         LoadedHtmlPage(self._driver).execute_script_with_timeout(
#             script, timeout
#         )


import pytest
from selene.core.exceptions import TimeoutException
from tests.integration.helpers.givenpage import GivenPage

    session_browser.all('a')[0].click()

    assert "second" in session_browser.driver.current_url


def test_waits_first_for_present_in_dom_then_visibility(session_browser):
    page = GivenPage(session_browser.driver)
    page.opened_with_body(
        '''
        <h2 id="second">Heading 2</h2>
        '''
    )
    page.load_body_with_timeout(
        '''
        <a href="#second" style="display:none">go to Heading 2</a>
        <h2 id="second">Heading 2</h2>
        ''',
        0.25,
    ).execute_script_with_timeout(
        'document.getElementsByTagName("a")[0].style = "display:block";', 0.5
    )

    session_browser.all('a')[0].click()

    assert "second" in session_browser.driver.current_url


def test_fails_on_timeout_during_waiting_for_visibility(session_browser):
    browser = session_browser.with_(timeout=0.25)

# Path: selene/core/exceptions.py
# class TimeoutException(AssertionError):
#     def __init__(self, msg=None):
#         self.msg = msg
# 
#     def __str__(self):
#         exception_msg = "Message: %s\n" % self.msg
#         return exception_msg
# 
# Path: tests/integration/helpers/givenpage.py
# class GivenPage:
#     def __init__(self, driver):
#         self._driver = driver
# 
#     def load_body_with_timeout(self, body, timeout):
#         return LoadedHtmlPage(self._driver).render_body_with_timeout(
#             body, timeout
#         )
# 
#     def opened_with_body_with_timeout(self, body, timeout):
#         return LoadingHtmlPage(timeout, body).load_in(self._driver)
# 
#     def opened_with_body(self, body):
#         return self.opened_with_body_with_timeout(body, 0)
# 
#     def opened_empty(self):
#         return LoadingHtmlPage().load_in(self._driver)
# 
#     def load_body(self, body):
#         return LoadedHtmlPage(self._driver).render_body(body)
# 
#     def execute_script_with_timeout(self, script, timeout):
#         LoadedHtmlPage(self._driver).execute_script_with_timeout(
#             script, timeout
#         )


# Path: tests/integration/collection__indexed_element__waiting_search_on_actions_like_click_test.py
import pytest
from selene.core.exceptions import TimeoutException
from tests.integration.helpers.givenpage import GivenPage


    session_browser.all('a')[0].click()

    assert "second" in session_browser.driver.current_url


def test_waits_first_for_present_in_dom_then_visibility(session_browser):
    page = GivenPage(session_browser.driver)
    page.opened_with_body(
        '''
        <h2 id="second">Heading 2</h2>
        '''
    )
    page.load_body_with_timeout(
        '''
        <a href="#second" style="display:none">go to Heading 2</a>
        <h2 id="second">Heading 2</h2>
        ''',
        0.25,
    ).execute_script_with_timeout(
        'document.getElementsByTagName("a")[0].style = "display:block";', 0.5
    )

    session_browser.all('a')[0].click()

    assert "second" in session_browser.driver.current_url


def test_fails_on_timeout_during_waiting_for_visibility(session_browser):
    browser = session_browser.with_(timeout=0.25)

    page = GivenPage(browser.driver)