def test_the_text_of_a_stored_element_is_only_returned_if_no_request_to_store_is_requested(
):
    user = Actor.named('user').who_can(browse_the_web.using_Chrome())

    returned_value = user.attempts_to(
        navigate_to(test_page),
        find_element((By.ID, 'hello_id')).and_store_as('hello'),
        text_of().stored_element('hello'))

    assert returned_value == 'hello'
def test_a_located_element_can_be_clicked_on():
    user = Actor.named('user').who_can(browse_the_web.using_Chrome())

    returned_value = user.attempts_to(
        navigate_to(test_page),
        click_on().element((By.ID, 'first')),
        find_element((By.ID, 'output')).and_store_as('output_div'),
        text_of().stored_element('output_div')
    )

    assert returned_value == 'first'
def test_text_can_be_entered_into_a_located_element():
    user = Actor.named('user').who_can(browse_the_web.using_Chrome())

    returned_value = user.attempts_to(
        navigate_to(test_page),
        enter_text('Hello World').into_element((By.ID, 'third_text')),
        click_on().element((By.ID, 'third')),
        find_element((By.ID, 'output')).and_store_as('output_div'),
        text_of().stored_element('output_div'))

    assert returned_value == 'Hello World'
def test_stripping_the_text_removes_whitespace():
    user = Actor.named('user').who_can(browse_the_web.using_Chrome())

    returned_value = user.attempts_to(
        navigate_to(test_page),
        find_element((By.ID, 'world_id')).and_store_as('world'),
        text_of().stored_element(
            'world').stripped_of_whitespace().and_store_as('text'))

    assert returned_value == 'world'

    stored_value = user.state['text'].value

    assert stored_value == 'world'
Exemplo n.º 5
0
def test_a_subelement_of_a_WebElement_can_be_clicked_on():
    user = Actor.named('user').who_can(browse_the_web.using_Chrome())

    element = user.attempts_to(
        navigate_to(test_page),
        find_element((By.ID, 'second_div'))
    )

    user.attempts_to(
        click_on_sub_element((By.ID, 'second')).of_WebElement(element),
    )

    returned_value = user.attempts_to(
        find_element((By.ID, 'output')).and_store_as('output_div'),
        text_of().stored_element('output_div')
    )

    assert returned_value == 'second'