Ejemplo n.º 1
0
def assert_not_checked_checkbox(self, value):
    """
    Assert the checkbox with label (recommended), name or id is not checked.
    """
    check_box = find_field(world.browser, 'checkbox', value)
    assert check_box, "Cannot find checkbox '{}'.".format(value)
    assert not check_box.is_selected(), "Check box should not be selected."
Ejemplo n.º 2
0
def assert_not_checked_checkbox(self, value):
    """
    Assert the checkbox with label (recommended), name or id is not checked.
    """
    check_box = find_field(world.browser, 'checkbox', value)
    assert check_box, "Cannot find checkbox '{}'.".format(value)
    assert_false(check_box.is_selected())
Ejemplo n.º 3
0
def assert_radio_not_selected(self, value):
    """
    Assert the radio button with the given label (recommended), name or id is
    not chosen.
    """
    box = find_field(world.browser, 'radio', value)
    assert_false(box.is_selected())
Ejemplo n.º 4
0
def choose_radio(self, value):
    """
    Click (and choose) the radio button with the given label (recommended),
    name or id.
    """
    box = find_field(world.browser, 'radio', value)
    box.click()
Ejemplo n.º 5
0
def select_multi_items(self, select_name):
    """
    Select multiple options from select with label (recommended), name, or
    id. Pass a multiline string of options. e.g.

    .. code-block:: gherkin

        When I select the following from "Contact Methods":
            \"\"\"
            Email
            Phone
            Fax
            \"\"\"
    """
    # Ensure only the options selected are actually selected
    option_names = self.multiline.split('\n')
    select_box = find_field(world.browser, 'select', select_name)
    assert select_box, "Cannot find a '{}' select.".format(select_name)

    select = Select(select_box)
    select.deselect_all()

    for option in option_names:
        try:
            select.select_by_value(option)
        except NoSuchElementException:
            try:
                select.select_by_visible_text(option)
            except NoSuchElementException:
                raise AssertionError(
                    "Cannot find option: '{}'.".format(option))
Ejemplo n.º 6
0
def select_multi_items(self, select_name):
    """
    Select multiple options from select with label (recommended), name, or
    id. Pass a multiline string of options. e.g.

    .. code-block:: gherkin

        When I select the following from "Contact Methods":
            \"\"\"
            Email
            Phone
            Fax
            \"\"\"
    """
    # Ensure only the options selected are actually selected
    option_names = self.multiline.split('\n')
    select_box = find_field(world.browser, 'select', select_name)
    assert select_box, "Cannot find a '{}' select.".format(select_name)

    select = Select(select_box)
    select.deselect_all()

    for option in option_names:
        try:
            select.select_by_value(option)
        except NoSuchElementException:
            try:
                select.select_by_visible_text(option)
            except NoSuchElementException:
                raise AssertionError("Cannot find option: '{}'.".format(option))
Ejemplo n.º 7
0
def choose_radio(self, value):
    """
    Click (and choose) the radio button with the given label (recommended),
    name or id.
    """
    box = find_field(world.browser, 'radio', value)
    assert box, "Cannot find a '{}' radio button.".format(value)
    box.click()
Ejemplo n.º 8
0
def assert_radio_not_selected(self, value):
    """
    Assert the radio button with the given label (recommended), name or id is
    not chosen.
    """
    radio = find_field(world.browser, 'radio', value)
    assert radio, "Cannot find a '{}' radio button.".format(value)
    assert not radio.is_selected(), "Radio button should not be selected."
Ejemplo n.º 9
0
def assert_radio_selected(self, value):
    """
    Assert the radio button with the given label (recommended), name or id is
    chosen.
    """
    box = find_field(world.browser, 'radio', value)
    assert box, "Cannot find a '{}' radio button.".format(value)
    assert_true(box.is_selected())
Ejemplo n.º 10
0
def assert_radio_not_selected(self, value):
    """
    Assert the radio button with the given label (recommended), name or id is
    not chosen.
    """
    radio = find_field(world.browser, 'radio', value)
    assert radio, "Cannot find a '{}' radio button.".format(value)
    assert not radio.is_selected(), "Radio button should not be selected."
Ejemplo n.º 11
0
def choose_radio(self, value):
    """
    Click (and choose) the radio button with the given label (recommended),
    name or id.
    """
    box = find_field(world.browser, 'radio', value)
    assert box, "Cannot find a '{}' radio button.".format(value)
    box.click()
Ejemplo n.º 12
0
def assert_multi_selected(self, select_name):
    # Ensure its not selected unless its one of our options
    option_names = self.multiline.split('\n')
    select_box = find_field(world.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:
            assert_true(option.is_selected())
        else:
            assert_false(option.is_selected())
Ejemplo n.º 13
0
def select_multi_items(self, select_name):
    # Ensure only the options selected are actually selected
    option_names = self.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)
Ejemplo n.º 14
0
def assert_multi_selected(self, select_name):
    # Ensure its not selected unless its one of our options
    option_names = self.multiline.split('\n')
    select_box = find_field(world.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:
            assert_true(option.is_selected())
        else:
            assert_false(option.is_selected())
Ejemplo n.º 15
0
def select_multi_items(self, select_name):
    # Ensure only the options selected are actually selected
    option_names = self.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)
Ejemplo n.º 16
0
def assert_multi_selected(self, select_name):
    select_box = find_field(world.browser, 'select', select_name)
    assert select_box, "Cannot find a '{}' select.".format(select_name)

    option_names = self.multiline.split('\n')
    option_elems = select_box.find_elements_by_xpath(str('./option'))

    # Check only the options that are specified are selected
    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_false(option.is_selected())
Ejemplo n.º 17
0
def assert_multi_selected(self, select_name):
    select_box = find_field(world.browser, 'select', select_name)
    assert select_box, "Cannot find a '{}' select.".format(select_name)

    option_names = self.multiline.split('\n')
    option_elems = select_box.find_elements_by_xpath(str('./option'))

    # Check only the options that are specified are selected
    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 option.is_selected(), "Option should be selected."
        else:
            assert not option.is_selected(), \
                "Option should not be selected."
Ejemplo n.º 18
0
def choose_radio(self, value):
    box = find_field(world.browser, 'radio', value)
    box.click()
Ejemplo n.º 19
0
def uncheck_checkbox(self, value):
    """Uncheck the checkbox with label (recommended), name or id."""
    check_box = find_field(world.browser, 'checkbox', value)
    assert check_box, "Cannot find checkbox '{}'.".format(value)
    if check_box.is_selected():
        check_box.click()
Ejemplo n.º 20
0
def uncheck_checkbox(self, value):
    """Uncheck the checkbox with label (recommended), name or id."""
    check_box = find_field(world.browser, 'checkbox', value)
    assert check_box, "Cannot find checkbox '{}'.".format(value)
    if check_box.is_selected():
        check_box.click()
Ejemplo n.º 21
0
 def test_find_field(self):
     assert find_field(world.browser, "text", "username")
     assert find_field(world.browser, "text", "Username:"******"text", "user")
     assert find_field(world.browser, "text", "ชื่อ:")
Ejemplo n.º 22
0
 def test_find_field(self):
     from aloe_webdriver.util import find_field
     assert find_field(world.browser, 'text', 'username')
     assert find_field(world.browser, 'text', 'Username:'******'text', 'user')
     assert find_field(world.browser, 'text', 'ชื่อ:')
Ejemplo n.º 23
0
 def test_find_field(self):
     assert find_field(world.browser, 'text', 'username')
     assert find_field(world.browser, 'text', 'Username:'******'text', 'user')
     assert find_field(world.browser, 'text', 'ชื่อ:')
Ejemplo n.º 24
0
def uncheck_checkbox(self, value):
    check_box = find_field(world.browser, 'checkbox', value)
    if check_box.is_selected():
        check_box.click()
Ejemplo n.º 25
0
def assert_radio_not_selected(self, value):
    box = find_field(world.browser, 'radio', value)
    assert_false(box.is_selected())
Ejemplo n.º 26
0
def choose_radio(self, value):
    box = find_field(world.browser, 'radio', value)
    box.click()
Ejemplo n.º 27
0
def assert_not_checked_checkbox(self, value):
    check_box = find_field(world.browser, 'checkbox', value)
    assert_false(check_box.is_selected())
Ejemplo n.º 28
0
def assert_checked_checkbox(self, value):
    """Assert the checkbox with label (recommended), name or id is checked."""
    check_box = find_field(world.browser, 'checkbox', value)
    assert_true(check_box.is_selected())
Ejemplo n.º 29
0
def assert_not_checked_checkbox(self, value):
    check_box = find_field(world.browser, 'checkbox', value)
    assert_false(check_box.is_selected())
Ejemplo n.º 30
0
def assert_radio_not_selected(self, value):
    box = find_field(world.browser, 'radio', value)
    assert_false(box.is_selected())
Ejemplo n.º 31
0
def uncheck_checkbox(self, value):
    check_box = find_field(world.browser, 'checkbox', value)
    if check_box.is_selected():
        check_box.click()
Ejemplo n.º 32
0
 def test_find_field(self):
     assert find_field(world.browser, 'text', 'username')
     assert find_field(world.browser, 'text', 'Username:'******'text', 'user')
     assert find_field(world.browser, 'text', 'ชื่อ:')
Ejemplo n.º 33
0
def uncheck_checkbox(self, value):
    """Uncheck the checkbox with label (recommended), name or id."""
    check_box = find_field(world.browser, 'checkbox', value)
    if check_box.is_selected():
        check_box.click()