def input_has_value(step, field_name, value): """ Check that the form input element has given value. """ with AssertContextManager(step): text_field = find_any_field(world.browser, DATE_FIELDS + TEXT_FIELDS, 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)
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)
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 is False, 'Can not find a field named "%s"' % field_name) text_field.clear() text_field.send_keys(value)
def element_not_focused(step, id): """ Check if the element is not focused """ elem = world.browser.find_element_by_xpath(str('id("{id}")'.format(id=id))) focused = world.browser.switch_to_active_element() assert_false(step, elem == focused)
def input_has_value(step, field_name, value): """ Check that the form input element has given value. """ with AssertContextManager(step): text_field = find_any_field(world.browser, DATE_FIELDS + TEXT_FIELDS, 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)
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)
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)
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)
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)
def fill_in_textfield_by_class(step, field_name, value): with AssertContextManager(step): text_field = find_field_by_class(world.browser, 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)
def reorder_column_by_offset(step, css, index, rightOrLeft, offsetx): with AssertContextManager(step): originalHeaderName = get_column_header_name(world.browser, css, index) reorder_column_with_offset(world.browser, css, index, rightOrLeft, offsetx) changedHeaderName = get_column_header_name(world.browser, css, index) assert_false(step, str(originalHeaderName) == str(changedHeaderName))
def check_element_by_selector(step, selector): elems = find_elements_by_jquery(world.browser, selector) assert_false(step, elems)
def element_not_contains(step, element_id, value): elem = world.browser.find_elements_by_xpath( str('id("{id}")[contains(text(), "{value}")]'.format(id=element_id, value=value))) assert_false(step, elem)
def no_element_with_xpath(step): driver = world.browser xpath = step.multiline assert_false(step, is_element_present(driver, By.XPATH, xpath))
def element_not_contains(step, element_id, value): elem = world.browser.find_elements_by_xpath( str('id("{id}")[contains(., "{value}")]'.format(id=element_id, value=value)) ) assert_false(step, elem)