Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Attempt work around for race-y sort of condition in Selenium sizzle checkers. #3451

Merged
merged 1 commit into from
Jan 25, 2017
Merged
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
31 changes: 29 additions & 2 deletions test/galaxy_selenium/sizzle.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,21 @@ def ec(driver):
if not elements:
return False
element = elements[0]
if element.is_displayed() and element.is_enabled():
try:
clickable = element.is_displayed() and element.is_enabled()
except Exception as e:
# Handle the case where the element is detached between when it is
# discovered and when it is checked - it is likely changing quickly
# and the next pass will be the final state. If not, this should be
# wrapped in a wait anyway - so no problems there. For other
# non-custom selectors I believe this all happens on the Selenium
# server and so there is likely no need to handle this case - they
# are effectively atomic.
if _exception_indicates_stale_element(e):
return None

raise
if clickable:
return element
else:
return None
Expand All @@ -29,14 +43,27 @@ def ec(driver):
if not elements:
return False
element = elements[0]
if element.is_displayed():
try:
displayed = element.is_displayed()
except Exception as e:
# See note above insizzle_selector_clickable about this exception.
if _exception_indicates_stale_element(e):
return None

raise

if displayed:
return element
else:
return None

return ec


def _exception_indicates_stale_element(exception):
return "stale" in str(exception)


def find_element_by_sizzle(driver, sizzle_selector):
"""
Finds an element by sizzle selector.
Expand Down