From b749300d43871bb57a134b4fa5b4508ac8daa97a Mon Sep 17 00:00:00 2001 From: Will Daly Date: Mon, 7 Oct 2013 16:08:39 -0400 Subject: [PATCH] Use css_has_value() to fix failure in course-overview.feature --- .../contentstore/features/course-overview.py | 2 +- .../contentstore/features/grading.py | 2 +- common/djangoapps/terrain/ui_helpers.py | 21 +++++++------------ 3 files changed, 10 insertions(+), 15 deletions(-) diff --git a/cms/djangoapps/contentstore/features/course-overview.py b/cms/djangoapps/contentstore/features/course-overview.py index 289dbec308..57e9d13501 100644 --- a/cms/djangoapps/contentstore/features/course-overview.py +++ b/cms/djangoapps/contentstore/features/course-overview.py @@ -72,7 +72,7 @@ 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_equal(world.browser.find_by_css(span_locator).value, text) + assert_true(world.css_has_value(span_locator, text)) world.css_click(span_locator) diff --git a/cms/djangoapps/contentstore/features/grading.py b/cms/djangoapps/contentstore/features/grading.py index a12041b96d..24beefcd6a 100644 --- a/cms/djangoapps/contentstore/features/grading.py +++ b/cms/djangoapps/contentstore/features/grading.py @@ -170,7 +170,7 @@ def i_change_grace_period(_step, grace_period): # 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)) + assert_true(world.css_has_value(grace_period_css, "00:00")) # Set the new grace period ele.value = grace_period diff --git a/common/djangoapps/terrain/ui_helpers.py b/common/djangoapps/terrain/ui_helpers.py index abb2c6c5c9..5189bf82cb 100644 --- a/common/djangoapps/terrain/ui_helpers.py +++ b/common/djangoapps/terrain/ui_helpers.py @@ -194,8 +194,7 @@ def is_css_not_present(css_selector, wait_time=5): @world.absorb -def css_has_text(css_selector, text, index=0, - strip=False, allow_blank=True): +def css_has_text(css_selector, text, index=0, strip=False): """ Return a boolean indicating whether the element with `css_selector` has `text`. @@ -203,15 +202,12 @@ def css_has_text(css_selector, text, index=0, If `strip` is True, strip whitespace at beginning/end of both strings before comparing. - If `allow_blank` is False, wait for the element to have non-empty - text before making the assertion. This is useful for elements - that are populated by JavaScript after the page loads. - If there are multiple elements matching the css selector, use `index` to indicate which one. """ - - if not allow_blank: + # If we're expecting a non-empty string, give the page + # a chance to fill in text fields. + if text: world.wait_for(lambda _: world.css_text(css_selector, index=index)) actual_text = world.css_text(css_selector, index=index) @@ -224,18 +220,17 @@ def css_has_text(css_selector, text, index=0, @world.absorb -def css_has_value(css_selector, value, index=0, allow_blank=False): +def css_has_value(css_selector, value, index=0): """ Return a boolean indicating whether the element with `css_selector` has the specified `value`. - If `allow_blank` is False, wait for the element to have - a value that is a non-empty string. - If there are multiple elements matching the css selector, use `index` to indicate which one. """ - if not allow_blank: + # If we're expecting a non-empty string, give the page + # a chance to fill in values + if value: world.wait_for(lambda _: world.css_value(css_selector, index=index)) return world.css_value(css_selector, index=index) == value