diff --git a/common/djangoapps/terrain/steps.py b/common/djangoapps/terrain/steps.py index fdab514177..83a6123a2a 100644 --- a/common/djangoapps/terrain/steps.py +++ b/common/djangoapps/terrain/steps.py @@ -144,3 +144,8 @@ def i_am_an_edx_user(step): @step(u'User "([^"]*)" is an edX user$') def registered_edx_user(step, uname): world.create_user(uname) + + +@step(u'All dialogs should be closed$') +def dialogs_are_closed(step): + assert world.dialogs_closed() diff --git a/common/djangoapps/terrain/ui_helpers.py b/common/djangoapps/terrain/ui_helpers.py index 1a85904135..40b839ae24 100644 --- a/common/djangoapps/terrain/ui_helpers.py +++ b/common/djangoapps/terrain/ui_helpers.py @@ -1,7 +1,7 @@ #pylint: disable=C0111 #pylint: disable=W0621 -from lettuce import world, step +from lettuce import world import time from urllib import quote_plus from selenium.common.exceptions import WebDriverException @@ -104,6 +104,17 @@ def css_visible(css_selector): return world.browser.find_by_css(css_selector).visible +@world.absorb +def dialogs_closed(): + def are_dialogs_closed(driver): + ''' + Return True when no modal dialogs are visible + ''' + return not css_visible('.modal') + wait_for(are_dialogs_closed) + return not css_visible('.modal') + + @world.absorb def save_the_html(path='/tmp'): u = world.browser.url @@ -111,4 +122,4 @@ def save_the_html(path='/tmp'): filename = '%s.html' % quote_plus(u) f = open('%s/%s' % (path, filename), 'w') f.write(html) - f.close + f.close() diff --git a/lms/djangoapps/courseware/features/registration.feature b/lms/djangoapps/courseware/features/registration.feature index 5933f860bb..43b04a5ad0 100644 --- a/lms/djangoapps/courseware/features/registration.feature +++ b/lms/djangoapps/courseware/features/registration.feature @@ -15,4 +15,6 @@ Feature: Register for a course And I visit the dashboard When I click the link with the text "Unregister" And I press the "Unregister" button in the Unenroll dialog - Then I should see "Looks like you haven't registered for any courses yet." somewhere in the page + Then All dialogs should be closed + And I should be on the dashboard page + And I should see "Looks like you haven't registered for any courses yet." somewhere in the page