Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions AUTHORS
Original file line number Diff line number Diff line change
Expand Up @@ -72,4 +72,5 @@ Giulio Gratta <giulio@giuliogratta.com>
David Baumgold <david@davidbaumgold.com>
Jason Bau <jbau@stanford.edu>
Frances Botsford <frances@edx.org>
Jonah Stanley <Jonah_Stanley@brown.edu>
Slater Victoroff <slater.r.victoroff@gmail.com>
6 changes: 0 additions & 6 deletions cms/djangoapps/contentstore/features/courses.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,12 +47,6 @@ def i_see_the_course_in_my_courses(step):
assert world.css_has_text(course_css, 'Robot Super Course')


@step('the course is loaded$')
def course_is_loaded(step):
class_css = 'a.class-name'
assert world.css_has_text(course_css, 'Robot Super Cousre')


@step('I am on the "([^"]*)" tab$')
def i_am_on_tab(step, tab_name):
header_css = 'div.inner-wrapper h1'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ def all_sections_are_expanded(step):


@step(u'all sections are collapsed$')
def all_sections_are_expanded(step):
def all_sections_are_collapsed(step):
subsection_locator = 'div.subsection-list'
subsections = world.css_find(subsection_locator)
for s in subsections:
Expand Down
9 changes: 6 additions & 3 deletions common/djangoapps/terrain/steps.py
Original file line number Diff line number Diff line change
Expand Up @@ -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, wait_time=5)
else:
assert world.browser.is_text_present(text, wait_time=5)


@step('I am logged in$')
Expand Down
16 changes: 12 additions & 4 deletions common/djangoapps/terrain/ui_helpers.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -42,11 +47,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)

Expand All @@ -56,6 +61,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()

Expand Down Expand Up @@ -89,6 +95,7 @@ def id_click(elem_id):

@world.absorb
def css_fill(css_selector, text):
assert is_css_present(css_selector)
world.browser.find_by_css(css_selector).first.fill(text)


Expand All @@ -114,6 +121,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


Expand Down
6 changes: 0 additions & 6 deletions lms/djangoapps/courseware/features/courseware_common.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,19 +12,13 @@ def i_click_on_view_courseware(step):
@step('I click on the "([^"]*)" tab$')
def i_click_on_the_tab(step, tab_text):
world.click_link(tab_text)
world.save_the_html()


@step('I visit the courseware URL$')
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')
Expand Down
5 changes: 1 addition & 4 deletions lms/djangoapps/courseware/features/high-level-tabs.feature
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,7 @@ Scenario: I can navigate to all high - level tabs in a course
And The course "6.002x" has extra tab "Custom Tab"
And I am logged in
And I click on View Courseware
When I click on the "<TabName>" tab
Then the page title should contain "<PageTitle>"

Examples:
When I click on the tabs then the page title should contain the following titles:
| TabName | PageTitle |
| Courseware | 6.002x Courseware |
| Course Info | 6.002x Course Info |
Expand Down
11 changes: 11 additions & 0 deletions lms/djangoapps/courseware/features/high-level-tabs.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
from lettuce import world, step
from nose.tools import assert_equals


@step(u'I click on the tabs then the page title should contain the following titles:')
def i_click_on_the_tab_and_check(step):
for tab_title in step.hashes:
tab_text = tab_title['TabName']
title = tab_title['PageTitle']
world.click_link(tab_text)
assert(title in world.browser.title)
8 changes: 2 additions & 6 deletions lms/djangoapps/courseware/features/homepage.feature
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,7 @@ Feature: Homepage for web users

Scenario Outline: User can see main parts of the page
Given I visit the homepage
Then I should see a link with the id "<id>" called "<Link>"

Examples:
Then I should see the following links and ids
| id | Link |
| about | About |
| jobs | Jobs |
Expand All @@ -27,9 +25,7 @@ Feature: Homepage for web users
# TODO: test according to domain or policy
Scenario: User can see the partner institutions
Given I visit the homepage
Then I should see "<Partner>" in the Partners section

Examples:
Then I should see the following Partners in the Partners section
| Partner |
| MITx |
| HarvardX |
Expand Down
19 changes: 15 additions & 4 deletions lms/djangoapps/courseware/features/homepage.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,22 @@
#pylint: disable=W0621

from lettuce import world, step
from nose.tools import assert_in
from nose.tools import assert_in, assert_equals


@step('I should see "([^"]*)" in the Partners section$')
def i_should_see_partner(step, partner):
@step(u'I should see the following Partners in the Partners section')
def i_should_see_partner(step):
partners = world.browser.find_by_css(".partner .name span")
names = set(span.text for span in partners)
assert_in(partner, names)
for partner in step.hashes:
assert_in(partner['Partner'], names)


@step(u'I should see the following links and ids')
def should_see_a_link_called(step):
for link_id_pair in step.hashes:
link_id = link_id_pair['id']
text = link_id_pair['Link']
link = world.browser.find_by_id(link_id)
assert len(link) > 0
assert_equals(link.text, text)
35 changes: 35 additions & 0 deletions lms/djangoapps/courseware/features/problems.feature
Original file line number Diff line number Diff line change
Expand Up @@ -84,3 +84,38 @@ Feature: Answer problems
| formula | incorrect |
| script | correct |
| script | incorrect |


Scenario: I can answer a problem with one attempt correctly and not reset
Given I am viewing a "multiple choice" problem with "1" attempt
When I answer a "multiple choice" problem "correctly"
Then The "Reset" button does not appear

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
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These scenarios should be rewritten to follow the Given-When-Then convention. It seems like what you are trying to test here should be broken out so that a test will fail discreetly if the functionality is broken.
Let's get this PR merged in first, then refactor.

When I answer a "multiple choice" problem "correctly"
Then The "Reset" button does appear

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"
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"
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 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 press the "Show Answer" button
Then The "Hide Answer" button does appear
And The "Show Answer" button does not appear
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 should not see "4.14159" anywhere on the page
Loading