Exemplo n.º 1
0
def fill_in_textfield(step, field_name, value):
    text_field = find_field(world.browser, 'text', field_name) or \
        find_field(world.browser, 'textarea', field_name) or \
        find_field(world.browser, 'password', field_name)
    assert_false(text_field == False,'Can not find a field named "%s"' % field_name)
    text_field.clear()
    text_field.send_keys(value)
Exemplo n.º 2
0
def fill_in_textfield(step, field_name, value):
    text_field = find_field(world.browser, 'text', field_name) or \
        find_field(world.browser, 'textarea', field_name) or \
        find_field(world.browser, 'password', field_name)
    assert_false(text_field == False,
                 'Can not find a field named "%s"' % field_name)
    text_field.clear()
    text_field.send_keys(value)
Exemplo n.º 3
0
def fill_in_textfield(step, field_name, value):
    with AssertContextManager(step):
        text_field = (
            find_field(world.browser, "text", field_name)
            or find_field(world.browser, "textarea", field_name)
            or find_field(world.browser, "password", field_name)
        )
        assert_false(step, text_field == False, 'Can not find a field named "%s"' % field_name)
        text_field.clear()
        text_field.send_keys(value)
Exemplo n.º 4
0
def input_has_value(step, field_name, value):
    """
    Check that the form input element has given value.
    """
    with AssertContextManager(step):
        text_field = find_field(world.browser, 'text', field_name) or \
            find_field(world.browser, 'textarea', field_name) or \
            find_field(world.browser, 'password', field_name)
        assert_false(step, text_field is False,
                     'Can not find a field named "%s"' % field_name)
        assert_equals(text_field.get_attribute('value'), value)
Exemplo n.º 5
0
def input_has_value(step, field_name, value):
    """
    Check that the form input element has given value.
    """
    with AssertContextManager(step):
        text_field = find_field(world.browser, 'text', field_name) or \
            find_field(world.browser, 'textarea', field_name) or \
            find_field(world.browser, 'password', field_name)
        assert_false(step, text_field is False,
                     'Can not find a field named "%s"' % field_name)
        assert_equals(text_field.get_attribute('value'), value)
Exemplo n.º 6
0
def assert_multi_selected(step, select_name):
    # Ensure its not selected unless its one of our options
    option_names = step.multiline.split('\n')
    select_box = find_field(world.browser, 'select', select_name)
    option_elems = select_box.find_elements_by_xpath('./option')
    for option in option_elems:
        if option.get_attribute('id') in option_names or \
           option.get_attribute('name') in option_names or \
           option.get_attribute('value') in option_names or \
           option.text in option_names:
            assert_true(option.is_selected())
        else:
            assert_true(not option.is_selected())
Exemplo n.º 7
0
def assert_multi_selected(step, select_name):
    # Ensure its not selected unless its one of our options
    option_names = step.multiline.split('\n')
    select_box = find_field(world.browser, 'select', select_name)
    option_elems = select_box.find_elements_by_xpath('./option')
    for option in option_elems:
        if option.get_attribute('id') in option_names or \
           option.get_attribute('name') in option_names or \
           option.get_attribute('value') in option_names or \
           option.text in option_names:
            assert_true(option.is_selected())
        else:
            assert_true(not option.is_selected())
Exemplo n.º 8
0
def select_multi_items(step, select_name):
    # Ensure only the options selected are actually selected
    option_names = step.multiline.split('\n')
    select_box = find_field(world.browser, 'select', select_name)
    option_elems = select_box.find_elements_by_xpath('./option')
    for option in option_elems:
        if option.get_attribute('id') in option_names or \
           option.get_attribute('name') in option_names or \
           option.get_attribute('value') in option_names or \
           option.text in option_names:
            option.select()
        else:
            if option.is_selected():
                option.toggle()
Exemplo n.º 9
0
def select_multi_items(step, select_name):
    with AssertContextManager(step):
        # Ensure only the options selected are actually selected
        option_names = step.multiline.split('\n')
        select_box = find_field(world.browser, 'select', select_name)

        select = Select(select_box)
        select.deselect_all()

        for option in option_names:
            try:
                select.select_by_value(option)
            except NoSuchElementException:
                select.select_by_visible_text(option)
Exemplo n.º 10
0
 def check(self, step, id_element, status):
     """
     Click on the checkbox identified but the given id
     depending on the given status.
     :param step: current Lettuce step.
     :param id_element: id of the checkbox element.
     :param status: status of the checkbox to be set.
     """
     with AssertContextManager(step):
         check_box = find_field(world.browser, 'checkbox', id_element)
         if not check_box.is_selected() and status == 'True':
             check_box.click()
         if check_box.is_selected() and status == 'False':
             check_box.click()
Exemplo n.º 11
0
def select_multi_items(step, select_name):
    with AssertContextManager(step):
        # Ensure only the options selected are actually selected
        option_names = step.multiline.split('\n')
        select_box = find_field(world.browser, 'select', select_name)

        select = Select(select_box)
        select.deselect_all()

        for option in option_names:
            try:
                select.select_by_value(option)
            except NoSuchElementException:
                select.select_by_visible_text(option)
Exemplo n.º 12
0
def the_page_validates_correctly(step):
    page_source = world.browser.page_source

    # Fix doctype which Firefox & validator disagree upon
    page_source = re.sub(u"^<!DOCTYPE HTML ", u"<!DOCTYPE html ", page_source)

    # Post to validator
    world.slow_browser.get("http://validator.w3.org/#validate_by_input")
    field = find_field(world.slow_browser, 'textarea', 'fragment')
    field.clear()
    field.send_keys(page_source)
    field.submit()

    assert_true("Congratulations" in world.slow_browser.page_source)
Exemplo n.º 13
0
def select_multi_items(step, select_name):
    # Ensure only the options selected are actually selected
    option_names = step.multiline.split('\n')
    select_box = find_field(world.browser, 'select', select_name)
    option_elems = select_box.find_elements_by_xpath('./option')
    for option in option_elems:
        if option.get_attribute('id') in option_names or \
           option.get_attribute('name') in option_names or \
           option.get_attribute('value') in option_names or \
           option.text in option_names:
            option.select()
        else:
            if option.is_selected():
                option.toggle()
Exemplo n.º 14
0
def assert_multi_selected(step, select_name):
    with AssertContextManager(step):
        # Ensure its not selected unless its one of our options
        option_names = step.multiline.split("\n")
        select_box = find_field(world.browser, "select", select_name)
        option_elems = select_box.find_elements_by_xpath("./option")
        for option in option_elems:
            if (
                option.get_attribute("id") in option_names
                or option.get_attribute("name") in option_names
                or option.get_attribute("value") in option_names
                or option.text in option_names
            ):
                assert_true(step, option.is_selected())
            else:
                assert_true(step, not option.is_selected())
Exemplo n.º 15
0
def select_multi_items(step, select_name):
    with AssertContextManager(step):
        # Ensure only the options selected are actually selected
        option_names = step.multiline.split("\n")
        select_box = find_field(world.browser, "select", select_name)
        option_elems = select_box.find_elements_by_xpath("./option")
        for option in option_elems:
            if (
                option.get_attribute("id") in option_names
                or option.get_attribute("name") in option_names
                or option.get_attribute("value") in option_names
                or option.text in option_names
            ):
                option.select()
            else:
                if option.is_selected():
                    option.toggle()
Exemplo n.º 16
0
def fill_in_textfield(step, field_name, value):
    with AssertContextManager(step):
        text_field = find_field(world.browser, 'text', field_name) or \
            find_field(world.browser, 'textarea', field_name) or \
            find_field(world.browser, 'password', field_name) or \
            find_field(world.browser, 'datetime', field_name) or \
            find_field(world.browser, 'datetime-local', field_name) or \
            find_field(world.browser, 'date', field_name) or \
            find_field(world.browser, 'month', field_name) or \
            find_field(world.browser, 'time', field_name) or \
            find_field(world.browser, 'week', field_name) or \
            find_field(world.browser, 'number', field_name) or \
            find_field(world.browser, 'range', field_name) or \
            find_field(world.browser, 'email', field_name) or \
            find_field(world.browser, 'url', field_name) or \
            find_field(world.browser, 'search', field_name) or \
            find_field(world.browser, 'tel', field_name) or \
            find_field(world.browser, 'color', field_name)
        assert_false(step, text_field is False,'Can not find a field named "%s"' % field_name)
        text_field.clear()
        text_field.send_keys(value)
Exemplo n.º 17
0
def fill_in_textfield(step, field_name, value):
    with AssertContextManager(step):
        text_field = (
            find_field(world.browser, "text", field_name)
            or find_field(world.browser, "textarea", field_name)
            or find_field(world.browser, "password", field_name)
            or find_field(world.browser, "datetime", field_name)
            or find_field(world.browser, "datetime-local", field_name)
            or find_field(world.browser, "date", field_name)
            or find_field(world.browser, "month", field_name)
            or find_field(world.browser, "time", field_name)
            or find_field(world.browser, "week", field_name)
            or find_field(world.browser, "number", field_name)
            or find_field(world.browser, "range", field_name)
            or find_field(world.browser, "email", field_name)
            or find_field(world.browser, "url", field_name)
            or find_field(world.browser, "search", field_name)
            or find_field(world.browser, "tel", field_name)
            or find_field(world.browser, "color", field_name)
        )
        assert_false(step, text_field is False, 'Can not find a field named "%s"' % field_name)
        text_field.clear()
        text_field.send_keys(value)
Exemplo n.º 18
0
def assert_checked_checkbox(step, value):
    check_box = find_field(world.browser, "checkbox", value)
    assert_true(step, check_box.is_selected())
Exemplo n.º 19
0
    def test_find_field(self):
        from lettuce_webdriver.util import find_field

        assert find_field(world.browser, "text", "username")
        assert find_field(world.browser, "text", "Username:"******"text", "user")
Exemplo n.º 20
0
def choose_radio(step, value):
    box = find_field(world.browser, 'radio', value)
    box.select()
Exemplo n.º 21
0
 def test_find_field(self):
     from lettuce_webdriver.util import find_field
     assert find_field(world.browser, 'text', 'username')
     assert find_field(world.browser, 'text', 'Username:'******'text', 'user')
Exemplo n.º 22
0
def fill_in_textfield(step, field_name, value):
    with AssertContextManager(step):
        text_field = find_field(world.browser, 'text', field_name) or \
            find_field(world.browser, 'textarea', field_name) or \
            find_field(world.browser, 'password', field_name) or \
            find_field(world.browser, 'datetime', field_name) or \
            find_field(world.browser, 'datetime-local', field_name) or \
            find_field(world.browser, 'date', field_name) or \
            find_field(world.browser, 'month', field_name) or \
            find_field(world.browser, 'time', field_name) or \
            find_field(world.browser, 'week', field_name) or \
            find_field(world.browser, 'number', field_name) or \
            find_field(world.browser, 'range', field_name) or \
            find_field(world.browser, 'email', field_name) or \
            find_field(world.browser, 'url', field_name) or \
            find_field(world.browser, 'search', field_name) or \
            find_field(world.browser, 'tel', field_name) or \
            find_field(world.browser, 'color', field_name)
        assert_false(step, text_field is False,
                     'Can not find a field named "%s"' % field_name)
        text_field.clear()
        text_field.send_keys(value)
Exemplo n.º 23
0
def uncheck_checkbox(step, value):
    check_box = find_field(world.browser, 'checkbox', value)
    if check_box.is_selected():
        check_box.toggle()
Exemplo n.º 24
0
def assert_radio_selected(step, value):
    box = find_field(world.browser, "radio", value)
    assert_true(step, box.is_selected())
Exemplo n.º 25
0
def check_checkbox(step, value):
    check_box = find_field(world.browser, 'checkbox', value)
    check_box.select()
Exemplo n.º 26
0
def choose_radio(step, value):
    with AssertContextManager(step):
        box = find_field(world.browser, 'radio', value)
        box.click()
Exemplo n.º 27
0
def uncheck_checkbox(step, value):
    with AssertContextManager(step):
        check_box = find_field(world.browser, 'checkbox', value)
        if check_box.is_selected():
            check_box.click()
Exemplo n.º 28
0
def assert_not_checked_checkbox(step, value):
    check_box = find_field(world.browser, 'checkbox', value)
    assert_true(step, not check_box.is_selected())
Exemplo n.º 29
0
def uncheck_checkbox(step, value):
    with AssertContextManager(step):
        check_box = find_field(world.browser, 'checkbox', value)
        if check_box.is_selected():
            check_box.click()
Exemplo n.º 30
0
def choose_radio(step, value):
    with AssertContextManager(step):
        box = find_field(world.browser, "radio", value)
        box.select()
Exemplo n.º 31
0
def check_checkbox(step, value):
    check_box = find_field(world.browser, 'checkbox', value)
    check_box.select()
Exemplo n.º 32
0
 def test_find_field(self):
     from lettuce_webdriver.util import find_field
     assert find_field(world.browser, 'text', 'username')
     assert find_field(world.browser, 'text', 'Username:'******'text', 'user')
Exemplo n.º 33
0
def uncheck_checkbox(step, value):
    check_box = find_field(world.browser, 'checkbox', value)
    if check_box.is_selected():
        check_box.toggle()
Exemplo n.º 34
0
def check_checkbox(step, value):
    with AssertContextManager(step):
        check_box = find_field(world.browser, 'checkbox', value)
        check_box.click()
Exemplo n.º 35
0
def choose_radio(step, value):
    box = find_field(world.browser, 'radio', value)
    box.select()
Exemplo n.º 36
0
def assert_not_checked_checkbox(step, value):
    check_box = find_field(world.browser, 'checkbox', value)
    assert_true(step, not check_box.is_selected())
Exemplo n.º 37
0
def choose_radio(step, value):
    with AssertContextManager(step):
        box = find_field(world.browser, 'radio', value)
        box.click()
Exemplo n.º 38
0
def assert_radio_not_selected(step, value):
    box = find_field(world.browser, 'radio', value)
    assert_true(step, not box.is_selected())
Exemplo n.º 39
0
def assert_radio_not_selected(step, value):
    box = find_field(world.browser, 'radio', value)
    assert_true(step, not box.is_selected())