# 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
#         )


from tests.integration.helpers.givenpage import GivenPage
def test_search_is_updated_on_next_actual_action_like_questioning_displayed(
    session_browser,
):
    element = session_browser.element('#will-be-existing-element').element(
        '.will-exist-inner'
    )
    page = GivenPage(session_browser.driver)
    page.opened_with_body(
        '''
        <h1 id="will-be-existing-element">
            <span class="will-exist-inner">Hello</span> kitty:*
        </h1>
        '''
    )
    assert element().is_displayed() is True

    page.load_body(
        '''
        <h1 id="will-be-existing-element">
            <span class="will-exist-inner" style="display:none">
              Hello
            </span> kitty:*
        </h1>'''
    )
    new_answer = element().is_displayed()

    assert new_answer is False


def test_search_finds_exactly_inside_parent(session_browser):

# 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/element__element__lazy_search_test.py
from tests.integration.helpers.givenpage import GivenPage

def test_search_is_updated_on_next_actual_action_like_questioning_displayed(
    session_browser,
):
    element = session_browser.element('#will-be-existing-element').element(
        '.will-exist-inner'
    )
    page = GivenPage(session_browser.driver)
    page.opened_with_body(
        '''
        <h1 id="will-be-existing-element">
            <span class="will-exist-inner">Hello</span> kitty:*
        </h1>
        '''
    )
    assert element().is_displayed() is True

    page.load_body(
        '''
        <h1 id="will-be-existing-element">
            <span class="will-exist-inner" style="display:none">
              Hello
            </span> kitty:*
        </h1>'''
    )
    new_answer = element().is_displayed()

    assert new_answer is False


def test_search_finds_exactly_inside_parent(session_browser):

    page = GivenPage(session_browser.driver)