-
-
Notifications
You must be signed in to change notification settings - Fork 153
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* CHORE: build & deploy docs in master repo only * TESTS: core wait tests
- Loading branch information
1 parent
047376d
commit ce62f8f
Showing
1 changed file
with
46 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |