Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion cms/djangoapps/contentstore/features/course-overview.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)


Expand Down
2 changes: 1 addition & 1 deletion cms/djangoapps/contentstore/features/grading.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
21 changes: 8 additions & 13 deletions common/djangoapps/terrain/ui_helpers.py
Original file line number Diff line number Diff line change
Expand Up @@ -194,24 +194,20 @@ 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`.

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)
Expand All @@ -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
Expand Down