コード例 #1
0
def assert_multi_selected(test, select_name, option_names):
    # Ensure its not selected unless its one of our options
    option_names = [on.strip() for on
                    in option_names.split('\n') if on.strip()]
    select_box = find_field(test.browser, 'select', select_name)
    option_elems = select_box.find_elements_by_xpath(str('./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:
            test.assertTrue(option.is_selected())
        else:
            test.assertFalse(option.is_selected())
コード例 #2
0
def select_multi_items(test, select_name, option_names):
    # Ensure only the options selected are actually selected
    option_names = [on.strip() for on
                    in option_names.split('\n') if on.strip()]
    select_box = find_field(test.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)
コード例 #3
0
def assert_radio_not_selected(test, value):
    box = find_field(test.browser, 'radio', value)
    test.assertFalse(box.is_selected())
コード例 #4
0
def choose_radio(test, value):
    box = find_field(test.browser, 'radio', value)
    box.click()
コード例 #5
0
def assert_not_checked_checkbox(test, value):
    check_box = find_field(test.browser, 'checkbox', value)
    test.assertFalse(check_box.is_selected())
コード例 #6
0
def uncheck_checkbox(test, value):
    check_box = find_field(test.browser, 'checkbox', value)
    if check_box.is_selected():
        check_box.click()