From cb9da2cd03a516d4d9fc6c2972c798ec5254d224 Mon Sep 17 00:00:00 2001 From: JonahStanley Date: Fri, 31 May 2013 15:16:45 -0400 Subject: [PATCH] Potentially fixed all flakey tests New function was added: is_css_not_present This function works like is_css_present in that it will wait and can take in an optional argument to wait longer. This should be used everywhere INSTEAD of not is_css_present as in the latter case, you are telling selenium to wait for the thing you don't want to be there to either be there or time out. --- common/djangoapps/terrain/ui_helpers.py | 9 +++++++-- lms/djangoapps/courseware/features/courseware_common.py | 5 ----- lms/djangoapps/courseware/features/problems.py | 2 +- lms/djangoapps/courseware/features/registration.feature | 2 +- lms/djangoapps/courseware/features/registration.py | 8 +++++++- 5 files changed, 16 insertions(+), 10 deletions(-) diff --git a/common/djangoapps/terrain/ui_helpers.py b/common/djangoapps/terrain/ui_helpers.py index fcf189a537..221a80c66c 100644 --- a/common/djangoapps/terrain/ui_helpers.py +++ b/common/djangoapps/terrain/ui_helpers.py @@ -32,8 +32,13 @@ def url_equals(url): @world.absorb -def is_css_present(css_selector): - return world.browser.is_element_present_by_css(css_selector, wait_time=4) +def is_css_present(css_selector, wait_time=5): + return world.browser.is_element_present_by_css(css_selector, wait_time=wait_time) + + +@world.absorb +def is_css_not_present(css_selector, wait_time=5): + return world.browser.is_element_not_present_by_css(css_selector, wait_time=wait_time) @world.absorb diff --git a/lms/djangoapps/courseware/features/courseware_common.py b/lms/djangoapps/courseware/features/courseware_common.py index ec63da2d82..aff49d2f9d 100644 --- a/lms/djangoapps/courseware/features/courseware_common.py +++ b/lms/djangoapps/courseware/features/courseware_common.py @@ -19,11 +19,6 @@ def i_visit_the_course_info_url(step): world.visit('/courses/MITx/6.002x/2012_Fall/courseware') -@step(u'I do not see "([^"]*)" anywhere on the page') -def i_do_not_see_text_anywhere_on_the_page(step, text): - assert world.browser.is_text_not_present(text) - - @step(u'I am on the dashboard page$') def i_am_on_the_dashboard_page(step): assert world.is_css_present('section.courses') diff --git a/lms/djangoapps/courseware/features/problems.py b/lms/djangoapps/courseware/features/problems.py index acc4f99e47..7cd9f157cd 100644 --- a/lms/djangoapps/courseware/features/problems.py +++ b/lms/djangoapps/courseware/features/problems.py @@ -120,7 +120,7 @@ def reset_problem(step): def action_button_present(step, buttonname, doesnt_appear): button_css = 'section.action input[value*="%s"]' % buttonname if doesnt_appear: - assert not world.is_css_present(button_css) + assert world.is_css_not_present(button_css) else: assert world.is_css_present(button_css) diff --git a/lms/djangoapps/courseware/features/registration.feature b/lms/djangoapps/courseware/features/registration.feature index 6c850a0b43..b8115b52c5 100644 --- a/lms/djangoapps/courseware/features/registration.feature +++ b/lms/djangoapps/courseware/features/registration.feature @@ -16,5 +16,5 @@ Feature: Register for a course Then I should see the course numbered "6.002x" in my dashboard When I unregister for the course numbered "6.002x" Then 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 + And I should see an empty dashboard message And I should NOT see the course numbered "6.002x" in my dashboard diff --git a/lms/djangoapps/courseware/features/registration.py b/lms/djangoapps/courseware/features/registration.py index 50e68b95da..24b8f52271 100644 --- a/lms/djangoapps/courseware/features/registration.py +++ b/lms/djangoapps/courseware/features/registration.py @@ -19,11 +19,17 @@ def i_register_for_the_course(step, course): assert world.is_css_present('section.container.dashboard') +@step(u'I should see an empty dashboard message') +def i_should_see_empty_dashboard(step): + empty_dash_css = 'section.empty-dashboard-message' + assert world.is_css_present(empty_dash_css) + + @step(u'I should( NOT)? see the course numbered "([^"]*)" in my dashboard$') def i_should_see_that_course_in_my_dashboard(step, doesnt_appear, course): course_link_css = 'section.my-courses a[href*="%s"]' % course if doesnt_appear: - assert not world.is_css_present(course_link_css) + assert world.is_css_not_present(course_link_css) else: assert world.is_css_present(course_link_css)