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

    returned_value = user.attempts_to(
        navigate_to(test_page),
        find_element((By.ID, 'third_text')).and_store_as('textbox'),
        enter_text('Hello World').into_stored_element('textbox'),
        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_a_stored_on_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),
        find_element((By.ID, 'first')).and_store_as('button'),
        click_on().stored_element('button'),
        find_element((By.ID, 'output')).and_store_as('output_div'),
        text_of().stored_element('output_div')
    )

    assert returned_value == 'first'
Exemplo n.º 3
0
def test_the_value_of_a_stored_element_is_returned():
    user = Actor.named('user').who_can(browse_the_web.using_Chrome())

    returned_value = user.attempts_to(
        navigate_to(test_page),
        find_element((By.ID, 'fourth_text')).and_store_as('textbox'),
        value_of().stored_element('textbox'))

    assert returned_value == 'fourth textbox'
Exemplo n.º 4
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'
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_finding_an_element_that_does_not_exists_stores_and_returns_None():
    user = Actor.named('user').who_can(browse_the_web.using_Chrome())

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

    assert returned_value is None

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

    assert stored_value is None
def test_an_element_that_exists_is_found_is_stored_and_returned():
    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'))

    assert returned_value.text == 'hello'

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

    assert stored_value.text == 'hello'
Exemplo n.º 8
0
def test_a_whitespace_stripped_value_of_a_stored_element_is_returned():
    user = Actor.named('user').who_can(browse_the_web.using_Chrome())

    locator = (By.ID, 'third_text')

    returned_value = user.attempts_to(
        navigate_to(test_page),
        enter_text('  text  ').into_element(locator),
        find_element(locator).and_store_as('textbox'),
        value_of().stored_element('textbox').stripped_of_whitespace())

    assert returned_value == 'text'
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'
def test_finding_a_subelement_of_a_stored_element_is_stored_and_returned():
    user = Actor.named('user').who_can(browse_the_web.using_Chrome())

    returned_value = user.attempts_to(
        navigate_to(test_page),
        find_element((By.ID, 'parent')).and_store_as('parent'),
        find_sub_element(
            (By.ID,
             'child')).from_stored_element('parent').and_store_as('child'))

    assert returned_value.text == 'child'

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

    assert stored_value.text == 'child'
def test_hiding_the_text_from_the_log_when_entering_text_into_a_stored_element(
):
    user = Actor.named('user').who_can(browse_the_web.using_Chrome())

    user.attempts_to(
        navigate_to(test_page),
        find_element((By.ID, 'third_text')).and_store_as('textbox'))

    Log.to_actions()

    log_text = capture_log_messages(
        user,
        enter_text('Hello World').into_stored_element(
            'textbox').and_do_not_log_text())

    assert len(
        log_text
    ) == 1, "Only expected 1 log message, actually {n} message(s)".format(
        n=len(log_text))
    assert log_text[0].strip(
    ) == 'Enter text \'**hidden**\' into element "textbox"'