def test_clicks_a_link_with_no_text_content_but_an_img_child( self, browser): from nerodia.wait.wait import Wait browser.link(href=compile(r'definition_lists.html')).click() Wait.until_not( lambda: browser.title == 'Images' or browser.title == '') assert browser.title == 'definition_lists'
def test_invokes_subsequent_method_calls_when_the_element_becomes_enabled(self, browser): browser.link(id='enable_btn').click() btn = browser.button(id='btn') btn.wait_until(timeout=2, method=lambda b: b.enabled).click() Wait.until_not(lambda: btn.enabled) assert btn.disabled
def test_uses_provided_interval(self): count = {'value': 0} def method(): count['value'] += 1 try: Wait.until_not(timeout=0.4, interval=0.2, method=method) except TimeoutError: pass assert count.get('value') == 2
def test_is_used_by_wait_until_not(self, browser): start_time = time() with pytest.raises(TimeoutError): Wait.until_not(lambda: True) assert nerodia.default_timeout < time( ) - start_time < nerodia.default_timeout + 1
def test_uses_timer_for_waiting(self, mocker): mocker.patch('nerodia.wait.wait.Timer.wait') Wait.until_not(timeout=0.5, method=lambda: True) Timer.wait.assert_called_once()
def test_times_out_with_a_custom_message(self): msg = 'oops' with pytest.raises(TimeoutError) as e: Wait.until_not(timeout=0.5, message=msg, method=lambda: True) assert e.value.args[0] == 'timed out after 0.5 seconds, {}'.format(msg)
def test_times_out(self): with pytest.raises(TimeoutError): Wait.until_not(timeout=0.5, method=lambda: True)
def test_exeuctes_method_if_timeout_is_zero(self): assert Wait.until_not(timeout=0, method=lambda: False)
def test_waits_while_the_method_returns_true(self): assert Wait.until_not(timeout=0.5, method=lambda: False)