Commit cb9da2cd by JonahStanley

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.
parent 3308bb4b
......@@ -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
......
......@@ -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')
......
......@@ -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)
......
......@@ -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
......@@ -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)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment