def wait_until_loaded(self, timeout=DEFAULT_TIMEOUT, polling_time=DEFAULT_POLLING_TIME): self.timeout = timeout self.polling_time = polling_time wait = Wait(self.timeout, self.polling_time)\ .with_ignored_exceptions(StaleElementReferenceException) if len(self.traits) == 0: raise IllegalStateException("Element '{0}' has no traits".format(self.name)) else: wait.until_traits_are_present(self) return self
def wait_until_loaded(self, timeout=DEFAULT_TIMEOUT, polling_time=DEFAULT_POLLING_TIME): self.timeout = timeout self.polling_time = polling_time wait = Wait(self.timeout, self.polling_time)\ .with_ignored_exceptions(StaleElementReferenceException) if len(self.traits) == 0: raise IllegalStateException("Element '{0}' has no traits".format( self.name)) else: wait.until_traits_are_present(self) return self
def test_wait_until_raises_TimeoutException(self): assert_that(calling(Wait(0).until_condition).with_args(always_false, 'always false'), raises(TimeoutException))
def test_wait_until_returns_evaluated_value(self): wait_until = Wait(1).until_condition(function, 'always true') assert_that(wait_until, equal_to('the value'))
def test_wait_until_gives_an_exceptions_for_a_non_callable(self): assert_that(calling(Wait(1).until_condition).with_args(function(), 'a non callable'), raises(TypeError))
def test_ignored_exceptions_can_be_iterable(self): wait = Wait(1).with_ignored_exceptions(FirstException, SecondException) assert_that(wait._ignored_exceptions, equal_to((NoSuchElementException, FirstException, SecondException)))
def test_ignored_exceptions_can_be_not_iterable(self): wait = Wait(1, ignored_exceptions=FirstException) assert_that(wait._ignored_exceptions, equal_to((NoSuchElementException, FirstException)))
def test_set_driver(self): driver = MockedWebDriver() wait = Wait(10).with_driver(driver) assert_that(wait._driver.session_id, equal_to(driver.session_id))
def test_set_poll_interval(self): wait = Wait(10).with_poll_interval(1) assert_that(wait._poll, equal_to(1), 'poll interval can be set')
def test_set_time_out(self): wait = Wait(1).with_timeout(10) assert_that(wait._timeout, equal_to(10), 'timeout can be set')