Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Increase code coverage #559

Merged
merged 4 commits into from
Nov 24, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
46 changes: 46 additions & 0 deletions tests/integration/core_wait_test.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
import time

from selene import be
from tests.integration.helpers.givenpage import GivenPage


def test_waits_for_visibility_minimum_needed_time(session_browser):
page = GivenPage(session_browser.driver)
page.opened_with_body(
'''
<a href="#second" style="display:none">go to Heading 2</a>
<h2 id="second">Heading 2</h2>
'''
).execute_script_with_timeout(
'document.getElementsByTagName("a")[0].style = "display:block";', 1
)
stamp_before = time.time_ns()
session_browser.element('a').wait.at_most(1).for_(be.visible)

session_browser.driver.find_element_by_css_selector('a').click()

stamp_after = time.time_ns()
deviation_sec = 0.2
assert stamp_after - stamp_before < (1 + deviation_sec) * pow(10, 9)
assert "second" in session_browser.driver.current_url


def test_fails_on_timeout_during_waits_first_for_present_in_dom_then_visibility(session_browser):
page = GivenPage(session_browser.driver)
page.opened_with_body(
'''
<a href="#second" style="display:none">go to Heading 2</a>
<h2 id="second">Heading 2</h2>
'''
).execute_script_with_timeout(
'document.getElementsByTagName("a")[0].style = "display:block";', 1.1
)
stamp_before = time.time_ns()
session_browser.element('a').wait.at_most(1).for_(be.visible)

session_browser.driver.find_element_by_css_selector('a').click()

stamp_after = time.time_ns()
deviation_sec = 0.2
assert stamp_after - stamp_before < (1 + deviation_sec) * pow(10, 9)
assert "second" in session_browser.driver.current_url
Loading