diff --git a/common/djangoapps/terrain/steps.py b/common/djangoapps/terrain/steps.py index d2be2eeea8..6643dfbf3c 100644 --- a/common/djangoapps/terrain/steps.py +++ b/common/djangoapps/terrain/steps.py @@ -129,9 +129,12 @@ def should_have_link_with_id_and_text(step, link_id, text): 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')) +@step(r'should( not)? see "(.*)" (?:somewhere|anywhere) (?:in|on) (?:the|this) page') +def should_see_in_the_page(step, doesnt_appear, text): + if doesnt_appear: + assert world.browser.is_text_not_present(text) + else: + assert_in(text, world.css_text('body')) @step('I am logged in$') diff --git a/common/djangoapps/terrain/ui_helpers.py b/common/djangoapps/terrain/ui_helpers.py index 79e9b0afdb..fcf189a537 100644 --- a/common/djangoapps/terrain/ui_helpers.py +++ b/common/djangoapps/terrain/ui_helpers.py @@ -42,11 +42,11 @@ def css_has_text(css_selector, text): @world.absorb -def css_find(css): +def css_find(css, wait_time=5): def is_visible(driver): return EC.visibility_of_element_located((By.CSS_SELECTOR, css,)) - world.browser.is_element_present_by_css(css, 5) + world.browser.is_element_present_by_css(css, wait_time=wait_time) wait_for(is_visible) return world.browser.find_by_css(css) @@ -56,6 +56,7 @@ def css_click(css_selector): """ Perform a click on a CSS selector, retrying if it initially fails """ + assert is_css_present(css_selector) try: world.browser.find_by_css(css_selector).click() @@ -81,6 +82,7 @@ def css_click_at(css, x=10, y=10): @world.absorb def css_fill(css_selector, text): + assert is_css_present(css_selector) world.browser.find_by_css(css_selector).first.fill(text) @@ -101,6 +103,7 @@ def css_text(css_selector): @world.absorb def css_visible(css_selector): + assert is_css_present(css_selector) return world.browser.find_by_css(css_selector).visible diff --git a/lms/djangoapps/courseware/features/problems.feature b/lms/djangoapps/courseware/features/problems.feature index 2a464922ee..ee80dea988 100644 --- a/lms/djangoapps/courseware/features/problems.feature +++ b/lms/djangoapps/courseware/features/problems.feature @@ -86,51 +86,32 @@ Feature: Answer problems | script | incorrect | - Scenario: I can answer a problem with one attempt correctly + Scenario: I can answer a problem with one attempt correctly and not reset Given I am viewing a "multiple choice" problem with "1" attempt - Then I should see "You have used 0 of 1 submissions" somewhere in the page - And The "Final Check" button does appear When I answer a "multiple choice" problem "correctly" - Then My "multiple choice" answer is marked "correct" - And The "multiple choice" problem displays a "correct" answer - And The "Reset" button does not appear + Then The "Reset" button does not appear - Scenario: I can answer a problem with one attempt incorrectly - Given I am viewing a "multiple choice" problem with "1" attempt - When I answer a "multiple choice" problem "incorrectly" - Then My "multiple choice" answer is marked "incorrect" - And The "multiple choice" problem displays a "incorrect" answer - And The "Reset" button does not appear - - Scenario: I can answer a problem with multiple attempts correctly + Scenario: I can answer a problem with multiple attempts correctly and still reset the problem Given I am viewing a "multiple choice" problem with "3" attempts Then I should see "You have used 0 of 3 submissions" somewhere in the page When I answer a "multiple choice" problem "correctly" - Then My "multiple choice" answer is marked "correct" - And The "multiple choice" problem displays a "correct" answer - And The "Reset" button does appear + Then The "Reset" button does appear - Scenario: I can answer a problem with multiple attempts correctly on final guess + Scenario: I can view how many attempts I have left on a problem Given I am viewing a "multiple choice" problem with "3" attempts Then I should see "You have used 0 of 3 submissions" somewhere in the page When I answer a "multiple choice" problem "incorrectly" - Then My "multiple choice" answer is marked "incorrect" - And The "multiple choice" problem displays a "incorrect" answer - When I reset the problem + And I reset the problem Then I should see "You have used 1 of 3 submissions" somewhere in the page When I answer a "multiple choice" problem "incorrectly" - Then My "multiple choice" answer is marked "incorrect" - And The "multiple choice" problem displays a "incorrect" answer - When I reset the problem + And I reset the problem Then I should see "You have used 2 of 3 submissions" somewhere in the page And The "Final Check" button does appear When I answer a "multiple choice" problem "correctly" - Then My "multiple choice" answer is marked "correct" - And The "multiple choice" problem displays a "correct" answer - And The "Reset" button does not appear + Then The "Reset" button does not appear Scenario: I can view and hide the answer if the problem has it: - Given I am viewing a "numerical" that shows the answer "always" + When I am viewing a "numerical" that shows the answer "always" Then The "Show Answer" button does appear When I press the "Show Answer" button Then The "Hide Answer" button does appear @@ -138,4 +119,4 @@ Feature: Answer problems And I should see "4.14159" somewhere in the page When I press the "Hide Answer" button Then The "Show Answer" button does appear - And I do not see "4.14159" anywhere on the page + And I should not see "4.14159" anywhere on the page diff --git a/lms/djangoapps/courseware/features/problems.py b/lms/djangoapps/courseware/features/problems.py index af301493ae..acc4f99e47 100644 --- a/lms/djangoapps/courseware/features/problems.py +++ b/lms/djangoapps/courseware/features/problems.py @@ -8,7 +8,7 @@ Steps for problem.feature lettuce tests from lettuce import world, step from lettuce.django import django_url from common import i_am_registered_for_the_course, TEST_SECTION_NAME -from problems_setup import * +from problems_setup import PROBLEM_DICT, answer_problem, problem_has_answer, add_problem_to_course @step(u'I am viewing a "([^"]*)" problem with "([^"]*)" attempt') @@ -116,21 +116,13 @@ def reset_problem(step): world.css_click('input.reset') -@step(u'The "([^"]*)" button does not appear') -def action_button_not_present(step, buttonname): +@step(u'The "([^"]*)" button does( not)? appear') +def action_button_present(step, buttonname, doesnt_appear): button_css = 'section.action input[value*="%s"]' % buttonname - assert not world.is_css_present(button_css) - - -@step(u'The "([^"]*)" button does appear') -def action_button_present(step, buttonname): - button_css = 'section.action input[value*="%s"]' % buttonname - assert world.is_css_present(button_css) - - -@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) + if doesnt_appear: + assert not world.is_css_present(button_css) + else: + assert world.is_css_present(button_css) @step(u'My "([^"]*)" answer is marked "([^"]*)"') diff --git a/lms/djangoapps/courseware/features/problems_setup.py b/lms/djangoapps/courseware/features/problems_setup.py index 0bc854de72..ce343bb853 100644 --- a/lms/djangoapps/courseware/features/problems_setup.py +++ b/lms/djangoapps/courseware/features/problems_setup.py @@ -1,3 +1,6 @@ +#pylint: disable=C0111 +#pylint: disable=W0621 + #EVERY PROBLEM TYPE MUST HAVE THE FOLLOWING: # -Section in Dictionary containing: # -factory diff --git a/lms/djangoapps/courseware/features/registration.py b/lms/djangoapps/courseware/features/registration.py index dd2fcb0825..50e68b95da 100644 --- a/lms/djangoapps/courseware/features/registration.py +++ b/lms/djangoapps/courseware/features/registration.py @@ -19,16 +19,13 @@ def i_register_for_the_course(step, course): assert world.is_css_present('section.container.dashboard') -@step(u'I should see the course numbered "([^"]*)" in my dashboard$') -def i_should_see_that_course_in_my_dashboard(step, course): +@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 - assert world.is_css_present(course_link_css) - - -@step(u'I should NOT see the course numbered "([^"]*)" in my dashboard$') -def i_should_not_see_that_course_in_my_dashboard(step, course): - course_link_css = 'section.my-courses a[href*="%s"]' % course - assert not world.is_css_present(course_link_css) + if doesnt_appear: + assert not world.is_css_present(course_link_css) + else: + assert world.is_css_present(course_link_css) @step(u'I unregister for the course numbered "([^"]*)"')