Skip to content
Snippets Groups Projects
Commit 8b0e7c57 authored by JonahStanley's avatar JonahStanley
Browse files

Made a new command css_has_class that will safely check the class and get around stale elements

parent d86502bd
No related merge requests found
......@@ -223,13 +223,7 @@ def shows_captions(step, show_captions):
# Prevent cookies from overriding course settings
world.browser.cookies.delete('hide_captions')
if show_captions == 'does not':
attempt = 0
while attempt < 5:
try:
assert world.css_find('.video')[0].has_class('closed')
except:
attempt += 1
assert_true(attempt < 5, "There was a stale reference exception in accessing the class of the video")
assert world.css_has_class('.video', 'closed')
else:
assert world.is_css_not_present('.video.closed')
......
......@@ -182,6 +182,19 @@ def css_html(css_selector, index=0, max_attempts=5):
return ''
@world.absorb
def css_has_class(css_selector, class_name, index=0, max_attempts=5):
attempt = 0
found = False
while attempt < max_attempts and not found:
try:
return world.css_find(css_selector)[index].has_class(class_name)
found = True
except:
attempt += 1
return False
@world.absorb
def css_visible(css_selector):
assert is_css_present(css_selector), "{} is not present".format(css_selector)
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment