From 22cf0dfa979d8b0d6e098fd064b214d3f0cb02fa Mon Sep 17 00:00:00 2001 From: Diana Huang Date: Tue, 14 May 2013 17:16:24 -0400 Subject: [PATCH 1/5] Fix bug in lettuce tests where the unregister dialog wasn't getting closed fast enough. --- common/djangoapps/terrain/steps.py | 5 +++++ common/djangoapps/terrain/ui_helpers.py | 15 +++++++++++++-- .../courseware/features/registration.feature | 4 +++- 3 files changed, 21 insertions(+), 3 deletions(-) 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 From b6c0081064ad5fbaaae5f5c76eb273991b615254 Mon Sep 17 00:00:00 2001 From: Diana Huang Date: Thu, 16 May 2013 14:42:35 -0400 Subject: [PATCH 2/5] Look for the existence of the links, not for the actual urls --- common/djangoapps/terrain/steps.py | 7 ++++++ .../courseware/features/homepage.feature | 25 ++++++++----------- lms/templates/footer.html | 10 ++++---- 3 files changed, 22 insertions(+), 20 deletions(-) diff --git a/common/djangoapps/terrain/steps.py b/common/djangoapps/terrain/steps.py index 83a6123a2a..d2be2eeea8 100644 --- a/common/djangoapps/terrain/steps.py +++ b/common/djangoapps/terrain/steps.py @@ -122,6 +122,13 @@ def should_see_a_link_called(step, text): assert len(world.browser.find_link_by_text(text)) > 0 +@step(r'should see (?:the|a) link with the id "([^"]*)" called "([^"]*)"$') +def should_have_link_with_id_and_text(step, link_id, text): + link = world.browser.find_by_id(link_id) + assert len(link) > 0 + assert_equals(link.text, text) + + @step(r'should see "(.*)" (?:somewhere|anywhere) in (?:the|this) page') def should_see_in_the_page(step, text): assert_in(text, world.css_text('body')) diff --git a/lms/djangoapps/courseware/features/homepage.feature b/lms/djangoapps/courseware/features/homepage.feature index c0c1c32f02..2c354acd49 100644 --- a/lms/djangoapps/courseware/features/homepage.feature +++ b/lms/djangoapps/courseware/features/homepage.feature @@ -5,29 +5,24 @@ Feature: Homepage for web users Scenario: User can see the "Login" button Given I visit the homepage - Then I should see a link called "Log In" + Then I should see a link called "Log in" - Scenario: User can see the "Sign up" button + Scenario: User can see the "Register Now" button Given I visit the homepage - Then I should see a link called "Sign Up" + Then I should see a link called "Register Now" Scenario Outline: User can see main parts of the page Given I visit the homepage - Then I should see a link called "" - When I click the link with the text "" - Then I should see that the path is "" + Then I should see a link with the id "" called "" Examples: - | Link | Path | - | Find Courses | /courses | - | About | /about | - | Jobs | /jobs | - | Contact | /contact | + | id | Link | + | about | About | + | jobs | Jobs | + | faq | FAQ | + | contact | Contact| + | press | Press | - Scenario: User can visit the blog - Given I visit the homepage - When I click the link with the text "Blog" - Then I should see that the url is "http://blog.edx.org/" # TODO: test according to domain or policy Scenario: User can see the partner institutions diff --git a/lms/templates/footer.html b/lms/templates/footer.html index 3fa956c704..daad0a2457 100644 --- a/lms/templates/footer.html +++ b/lms/templates/footer.html @@ -8,27 +8,27 @@