Commit 8b0e7c57 by JonahStanley

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

parent d86502bd
...@@ -223,13 +223,7 @@ def shows_captions(step, show_captions): ...@@ -223,13 +223,7 @@ def shows_captions(step, show_captions):
# Prevent cookies from overriding course settings # Prevent cookies from overriding course settings
world.browser.cookies.delete('hide_captions') world.browser.cookies.delete('hide_captions')
if show_captions == 'does not': if show_captions == 'does not':
attempt = 0 assert world.css_has_class('.video', 'closed')
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")
else: else:
assert world.is_css_not_present('.video.closed') assert world.is_css_not_present('.video.closed')
......
...@@ -183,6 +183,19 @@ def css_html(css_selector, index=0, max_attempts=5): ...@@ -183,6 +183,19 @@ def css_html(css_selector, index=0, max_attempts=5):
@world.absorb @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): def css_visible(css_selector):
assert is_css_present(css_selector), "{} is not present".format(css_selector) assert is_css_present(css_selector), "{} is not present".format(css_selector)
return world.browser.find_by_css(css_selector).visible return world.browser.find_by_css(css_selector).visible
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment