Commit 2c0c8dfb by JonahStanley

Fixed structure of css_text and css_value

parent c53aac45
...@@ -184,31 +184,35 @@ def click_link(partial_text, index=0, max_attempts=5): ...@@ -184,31 +184,35 @@ def click_link(partial_text, index=0, max_attempts=5):
@world.absorb @world.absorb
def css_text(css_selector, index=0): def css_text(css_selector, index=0, max_attempts=5):
# Wait for the css selector to appear # Wait for the css selector to appear
if world.is_css_present(css_selector): if world.is_css_present(css_selector):
try: attempt = 0
return world.browser.find_by_css(css_selector)[index].text while attempt < max_attempts:
except StaleElementReferenceException: try:
# The DOM was still redrawing. Wait a second and try again. return world.browser.find_by_css(css_selector)[index].text
world.wait(1) break
return world.browser.find_by_css(css_selector)[index].text except:
attempt += 1
assert_true(attempt < max_attempts, 'Could not access {}'.format(css_selector))
else: else:
return "" return ""
@world.absorb @world.absorb
def css_value(css_selector, index=0): def css_value(css_selector, index=0, max_attempts=5):
# Wait for the css selector to appear # Wait for the css selector to appear
if world.is_css_present(css_selector): if world.is_css_present(css_selector):
try: attempt = 0
return world.browser.find_by_css(css_selector)[index].value while attempt < max_attempts:
except StaleElementReferenceException: try:
# The DOM was still redrawing. Wait a second and try again. return world.browser.find_by_css(css_selector)[index].value
world.wait(1) break
return world.browser.find_by_css(css_selector)[index].value except:
attempt += 1
assert_true(attempt < max_attempts, 'Could not access {}'.format(css_selector))
else: else:
return "" return ""
......
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