def test_raises_error_if_default_max_wait_time_is_less_than_timeout( self, session): button = session.find("css", "#openWindowWithLongerTimeout") with capybara.using_wait_time(0.4): with pytest.raises(WindowError): session.window_opened_by(lambda: button.click()) assert_windows_open(session, 2)
def test_ensures_wait_time_is_reset(self): previous_wait_time = capybara.default_max_wait_time with pytest.raises(RuntimeError) as excinfo: with capybara.using_wait_time(6): raise RuntimeError("hell") assert "hell" in str(excinfo.value) assert capybara.default_max_wait_time == previous_wait_time
def test_raises_error_if_it_appears_after_given_wait_duration( self, session): with capybara.using_wait_time(0): session.visit("/with_js") session.find("css", "#reload-list").click() el = session.find("css", "#the-list", visible=False) with pytest.raises(ExpectationNotMet): el.assert_text("all", "Foo Bar", wait=0.3)
def test_does_not_find_elements_if_they_appear_after_given_wait_duration( self, session): with capybara.using_wait_time(0.1): session.visit("/with_js") session.click_link("Click me") session.assert_none_of_selectors("css", "#new_field", "a#has-been-clicked", wait=0.1)
def test_finds_element_if_it_appears_before_given_wait_duration( self, session): with capybara.using_wait_time(0.1): session.visit("/with_js") session.click_link("Click me") session.assert_selector("css", "a#has-been-clicked", text="Has been clicked", wait=0.9)
def test_does_not_raise_error_if_all_the_elements_appear_before_given_wait_duration( self, session): with capybara.using_wait_time(0.1): session.visit("/with_js") session.click_link("Click me") session.assert_all_of_selectors("css", "a#clickable", "a#has-been-clicked", "#drag", wait=0.9)
def test_finds_element_if_it_appears_before_given_wait_duration(self, session): with capybara.using_wait_time(0.1): session.visit("/with_js") session.click_link("Click me") assert session.has_text("Has been clicked", wait=0.9)
def test_finds_window_if_default_max_wait_time_is_more_than_timeout( self, session): button = session.find("css", "#openWindowWithTimeout") with capybara.using_wait_time(1.5): window = session.window_opened_by(lambda: button.click()) assert isinstance(window, Window)
def test_finds_element_if_it_appears_before_given_wait_duration( self, session): with capybara.using_wait_time(0): session.visit("/with_js") session.find("css", "#reload-list").click() session.find("css", "#the-list").assert_text("Foo Bar", wait=0.9)
def test_switches_and_restores_the_wait_time(self): previous_wait_time = capybara.default_max_wait_time with capybara.using_wait_time(6): in_context = capybara.default_max_wait_time assert in_context == 6 assert capybara.default_max_wait_time == previous_wait_time