Skip to content

Commit

Permalink
Selenium - catch popups fading out as transitions to retry various ac…
Browse files Browse the repository at this point in the history
…tions on.

Previously we only detected transitions for retrying actions based on stale element exceptions, this expands that to include popups that may be fading out for instance.

I think this is what is happening with the transiently failing test here https://jenkins.galaxyproject.org/job/selenium/528/artifact/528-test-errors/test_save_as2017092203291506065342/stacktrace.txt. The exception indicates that a click was not clickable because a modal element that was fading out - though it had been previously clickable. I think this should fix that.
  • Loading branch information
jmchilton committed Sep 22, 2017
1 parent 9e6e340 commit 3ffdfc6
Show file tree
Hide file tree
Showing 2 changed files with 37 additions and 3 deletions.
12 changes: 12 additions & 0 deletions test/galaxy_selenium/has_driver.py
Expand Up @@ -140,5 +140,17 @@ def prepend_timeout_message(self, timeout_exception, message):
)


def execption_indicates_not_clickable(exception):
return "not clickable" in str(exception)


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


__all__ = (
"execption_indicates_not_clickable",
"exception_indicates_stale_element",
"HasDriver",
"TimeoutException",
)
28 changes: 25 additions & 3 deletions test/galaxy_selenium/navigates_galaxy.py
Expand Up @@ -15,7 +15,12 @@
import yaml

from .data import NAVIGATION_DATA
from .has_driver import exception_indicates_stale_element, HasDriver, TimeoutException
from .has_driver import (
execption_indicates_not_clickable,
exception_indicates_stale_element,
HasDriver,
TimeoutException,
)
from . import sizzle

# Test case data
Expand All @@ -28,7 +33,24 @@ def handle_step(self, step, step_index):
pass


def retry_call_during_transitions(f, attempts=5, sleep=.1, exception_check=exception_indicates_stale_element):
def excepion_seems_to_indicate_transition(e):
"""True if exception seems to indicate the page state is transitioning.
Galaxy features many different transition effects that change the page state over time.
These transitions make it slightly more difficult to test Galaxy because atomic input
actions take an indeterminate amount of time to be reflected on the screen. This method
takes a Selenium assertion and tries to infer if such a transition could be the root
cause of the exception. The methods that follow use it to allow retrying actions during
transitions.
Currently the two kinds of exceptions that we say may indicate a transition are
StaleElement exceptions (a DOM element grabbed at one step is no longer available)
and "not clickable" exceptions (so perhaps a popup modal is blocking a click).
"""
return exception_indicates_stale_element(e) or execption_indicates_not_clickable(e)


def retry_call_during_transitions(f, attempts=5, sleep=.1, exception_check=excepion_seems_to_indicate_transition):
previous_attempts = 0
while True:
try:
Expand All @@ -44,7 +66,7 @@ def retry_call_during_transitions(f, attempts=5, sleep=.1, exception_check=excep
previous_attempts += 1


def retry_during_transitions(f, attempts=5, sleep=.1, exception_check=exception_indicates_stale_element):
def retry_during_transitions(f, attempts=5, sleep=.1, exception_check=excepion_seems_to_indicate_transition):

@wraps(f)
def _retry(*args, **kwds):
Expand Down

0 comments on commit 3ffdfc6

Please sign in to comment.