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."
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())
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())
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()
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))
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))
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()
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."
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())
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())
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)
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())
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."
def choose_radio(self, value): box = find_field(world.browser, 'radio', value) box.click()
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()
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", "ชื่อ:")
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', 'ชื่อ:')
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', 'ชื่อ:')
def uncheck_checkbox(self, value): check_box = find_field(world.browser, 'checkbox', value) if check_box.is_selected(): check_box.click()
def assert_radio_not_selected(self, value): box = find_field(world.browser, 'radio', value) assert_false(box.is_selected())
def assert_not_checked_checkbox(self, value): check_box = find_field(world.browser, 'checkbox', value) assert_false(check_box.is_selected())
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())
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()