def get_element_with_traits_and_lazy_evaluation(value): an_element = ElementWithTraits('an element') if not value: an_element.with_eager_evaluation() an_element.add_trait(lambda: False, 'never true #1') an_element.add_trait(lambda: False, 'never true #2') return an_element
def test_raises_exception_when_there_are_no_traits(self): element = ElementWithTraits('an_element') assert_that( calling(element.wait_until_loaded).with_args(1, 0.5), raises(IllegalStateException))
def test_raises_timeout_when_traits_do_not_load(self): element = ElementWithTraits('an_element').add_trait( lambda: False, 'never loading') assert_that( calling(element.wait_until_loaded).with_args(1, 0.5), raises(TimeoutException))
def test_can_wait_until_traits_are_loaded(self): element = ElementWithTraits('an_element').add_trait( lambda: True, 'always present') assert_that(element.wait_until_loaded(5, 1), equal_to(element))
def __init__(self, driver, name): ElementWithTraits.__init__(self, name) self.driver = driver
def __init__(self, driver, name, locator=None): ElementWithTraits.__init__(self, name) self.driver = driver self.__locator = locator self._web_element = None self.__cache = False