def verify_date_or_time(css, date_or_time): """ Verifies date or time field. """ # We need to wait for JavaScript to fill in the field, so we use # css_has_value(), which first checks that the field is not blank assert_true(world.css_has_value(css, date_or_time))
def the_grace_period_is(_step, grace_period): grace_period_css = '#course-grading-graceperiod' # The default value is 00:00 # so we need to wait for it to change world.wait_for( lambda _: world.css_has_value(grace_period_css, grace_period))
def the_grace_period_is(_step, grace_period): grace_period_css = '#course-grading-graceperiod' # The default value is 00:00 # so we need to wait for it to change world.wait_for( lambda _: world.css_has_value(grace_period_css, grace_period) )
def set_value_transcripts_field(_step, value, field_name): XPATH = '//label[text()="{name}"]'.format(name=field_name) SELECTOR = "#" + world.browser.find_by_xpath(XPATH)[0]["for"] element = world.css_find(SELECTOR).first if element["type"] == "text": SCRIPT = '$("{selector}").val("{value}").change()'.format(selector=SELECTOR, value=value) world.browser.execute_script(SCRIPT) assert world.css_has_value(SELECTOR, value) else: assert False, "Incorrect element type." world.wait_for_ajax_complete()
def set_value_transcripts_field(_step, value, field_name): XPATH = '//label[text()="{name}"]'.format(name=field_name) SELECTOR = '#' + world.browser.find_by_xpath(XPATH)[0]['for'] element = world.css_find(SELECTOR).first if element['type'] == 'text': SCRIPT = '$("{selector}").val("{value}").change()'.format( selector=SELECTOR, value=value) world.browser.execute_script(SCRIPT) assert world.css_has_value(SELECTOR, value) else: assert False, 'Incorrect element type.' world.wait_for_ajax_complete()
def i_change_grace_period(_step, grace_period): grace_period_css = '#course-grading-graceperiod' ele = world.css_find(grace_period_css).first # Sometimes it takes a moment for the JavaScript # to populate the field. If we don't wait for # this to happen, then we can end up with # an invalid value (e.g. "00:0048:00") # which prevents us from saving. assert_true(world.css_has_value(grace_period_css, "00:00", allow_blank=False)) # Set the new grace period ele.value = grace_period
def i_change_grace_period(_step, grace_period): grace_period_css = '#course-grading-graceperiod' ele = world.css_find(grace_period_css).first # Sometimes it takes a moment for the JavaScript # to populate the field. If we don't wait for # this to happen, then we can end up with # an invalid value (e.g. "00:0048:00") # which prevents us from saving. assert_true(world.css_has_value(grace_period_css, "00:00")) # Set the new grace period ele.value = grace_period
def set_value_transcripts_field(_step, value, field_name): tab = world.css_find('#settings-tab').first; XPATH = './/label[text()="{name}"]'.format(name=field_name) SELECTOR = '#' + tab.find_by_xpath(XPATH)[0]['for'] element = world.css_find(SELECTOR).first if element['type'] == 'text': SCRIPT = '$("{selector}").val("{value}").change()'.format( selector=SELECTOR, value=value ) world.browser.execute_script(SCRIPT) assert world.css_has_value(SELECTOR, value) else: assert False, 'Incorrect element type.'; world.wait_for_ajax_complete()
def i_see_the_span_with_text(step, text): span_locator = '.toggle-button-sections span' assert_true(world.css_has_value(span_locator, text)) assert_true(world.css_visible(span_locator))
def i_click_the_text_span(step, text): span_locator = '.toggle-button-sections span' assert_true(world.browser.is_element_present_by_css(span_locator)) # first make sure that the expand/collapse text is the one you expected assert_true(world.css_has_value(span_locator, text)) world.css_click(span_locator)