Commit c53aac45 by JonahStanley

CMS acceptance tests now should not get stale element exception errors

parent f1dd81a6
...@@ -99,7 +99,7 @@ def assert_policy_entries(expected_keys, expected_values): ...@@ -99,7 +99,7 @@ def assert_policy_entries(expected_keys, expected_values):
def get_index_of(expected_key): def get_index_of(expected_key):
for counter in range(len(world.css_find(KEY_CSS))): for counter in range(len(world.css_find(KEY_CSS))):
# Sometimes get stale reference if I hold on to the array of elements # Sometimes get stale reference if I hold on to the array of elements
key = world.css_find(KEY_CSS)[counter].value key = world.css_value(KEY_CSS, index=counter)
if key == expected_key: if key == expected_key:
return counter return counter
...@@ -108,7 +108,7 @@ def get_index_of(expected_key): ...@@ -108,7 +108,7 @@ def get_index_of(expected_key):
def get_display_name_value(): def get_display_name_value():
index = get_index_of(DISPLAY_NAME_KEY) index = get_index_of(DISPLAY_NAME_KEY)
return world.css_find(VALUE_CSS)[index].value return world.css_value(VALUE_CSS, index=index)
def change_display_name_value(step, new_value): def change_display_name_value(step, new_value):
......
...@@ -61,7 +61,7 @@ def i_select_a_link_to_the_course_outline(step): ...@@ -61,7 +61,7 @@ def i_select_a_link_to_the_course_outline(step):
@step('I am brought to the course outline page$') @step('I am brought to the course outline page$')
def i_am_brought_to_course_outline(step): def i_am_brought_to_course_outline(step):
assert_in('Course Outline', world.css_find('.outline .page-header')[0].text) assert_in('Course Outline', world.css_text('.outline .page-header'))
assert_equal(1, len(world.browser.windows)) assert_equal(1, len(world.browser.windows))
......
...@@ -144,10 +144,16 @@ def log_into_studio( ...@@ -144,10 +144,16 @@ def log_into_studio(
world.is_css_present(signin_css) world.is_css_present(signin_css)
world.css_click(signin_css) world.css_click(signin_css)
attempt = 0
while attempt < 5:
try:
login_form = world.browser.find_by_css('form#login_form') login_form = world.browser.find_by_css('form#login_form')
login_form.find_by_name('email').fill(email) login_form.find_by_name('email').fill(email)
login_form.find_by_name('password').fill(password) login_form.find_by_name('password').fill(password)
login_form.find_by_name('submit').click() login_form.find_by_name('submit').click()
break
except:
attempt += 1
assert_true(world.is_css_present('.new-course-button')) assert_true(world.is_css_present('.new-course-button'))
......
...@@ -162,7 +162,7 @@ def verify_date_or_time(css, date_or_time): ...@@ -162,7 +162,7 @@ def verify_date_or_time(css, date_or_time):
""" """
Verifies date or time field. Verifies date or time field.
""" """
assert_equal(date_or_time, world.css_find(css).first.value) assert_equal(date_or_time, world.css_value(css))
def i_see_the_set_dates(): def i_see_the_set_dates():
......
...@@ -47,7 +47,7 @@ def other_user_login(_step, name): ...@@ -47,7 +47,7 @@ def other_user_login(_step, name):
@step(u's?he does( not)? see the course on (his|her) page') @step(u's?he does( not)? see the course on (his|her) page')
def see_course(_step, doesnt_see_course, gender): def see_course(_step, doesnt_see_course, gender):
class_css = 'span.class-name' class_css = 'span.class-name'
all_courses = world.css_find(class_css) all_courses = world.css_find(class_css, wait_time=1)
all_names = [item.html for item in all_courses] all_names = [item.html for item in all_courses]
if doesnt_see_course: if doesnt_see_course:
assert not _COURSE_NAME in all_names assert not _COURSE_NAME in all_names
......
...@@ -24,7 +24,7 @@ def add_update(_step, text): ...@@ -24,7 +24,7 @@ def add_update(_step, text):
@step(u'I should( not)? see the update "([^"]*)"$') @step(u'I should( not)? see the update "([^"]*)"$')
def check_update(_step, doesnt_see_update, text): def check_update(_step, doesnt_see_update, text):
update_css = 'div.update-contents' update_css = 'div.update-contents'
update = world.css_find(update_css) update = world.css_find(update_css, wait_time=1)
if doesnt_see_update: if doesnt_see_update:
assert len(update) == 0 or not text in update.html assert len(update) == 0 or not text in update.html
else: else:
......
...@@ -90,8 +90,8 @@ def add_assignment_type(step, new_name): ...@@ -90,8 +90,8 @@ def add_assignment_type(step, new_name):
add_button_css = '.add-grading-data' add_button_css = '.add-grading-data'
world.css_click(add_button_css) world.css_click(add_button_css)
name_id = '#course-grading-assignment-name' name_id = '#course-grading-assignment-name'
f = world.css_find(name_id)[4] new_assignment = world.css_find(name_id)[-1]
f._element.send_keys(new_name) new_assignment._element.send_keys(new_name)
@step(u'I have populated the course') @step(u'I have populated the course')
...@@ -118,8 +118,8 @@ def i_see_the_assignment_type(_step, name): ...@@ -118,8 +118,8 @@ def i_see_the_assignment_type(_step, name):
def get_type_index(name): def get_type_index(name):
name_id = '#course-grading-assignment-name' name_id = '#course-grading-assignment-name'
f = world.css_find(name_id) all_types = world.css_find(name_id)
for i in range(len(f)): for index in range(len(all_types)):
if f[i].value == name: if world.css_value(name_id, index=index) == name:
return i return index
return -1 return -1
...@@ -169,7 +169,7 @@ def edit_latex_source(step): ...@@ -169,7 +169,7 @@ def edit_latex_source(step):
@step('my change to the High Level Source is persisted') @step('my change to the High Level Source is persisted')
def high_level_source_persisted(step): def high_level_source_persisted(step):
def verify_text(driver): def verify_text(driver):
return world.css_find('.problem').text == 'hi' return world.css_text('.problem') == 'hi'
world.wait_for(verify_text) world.wait_for(verify_text)
...@@ -177,7 +177,7 @@ def high_level_source_persisted(step): ...@@ -177,7 +177,7 @@ def high_level_source_persisted(step):
@step('I view the High Level Source I see my changes') @step('I view the High Level Source I see my changes')
def high_level_source_in_editor(step): def high_level_source_in_editor(step):
open_high_level_source() open_high_level_source()
assert_equal('hi', world.css_find('.source-edit-box').value) assert_equal('hi', world.css_value('.source-edit-box'))
def verify_high_level_source_links(step, visible): def verify_high_level_source_links(step, visible):
......
...@@ -70,7 +70,7 @@ def i_click_to_edit_section_name(_step): ...@@ -70,7 +70,7 @@ def i_click_to_edit_section_name(_step):
def i_see_complete_section_name_with_quote_in_editor(_step): def i_see_complete_section_name_with_quote_in_editor(_step):
css = '.section-name-edit input[type=text]' css = '.section-name-edit input[type=text]'
assert world.is_css_present(css) assert world.is_css_present(css)
assert_equal(world.browser.find_by_css(css).value, 'Section with "Quote"') assert_equal(world.css_value(css), 'Section with "Quote"')
@step('the section does not exist$') @step('the section does not exist$')
...@@ -85,7 +85,7 @@ def i_see_a_release_date_for_my_section(_step): ...@@ -85,7 +85,7 @@ def i_see_a_release_date_for_my_section(_step):
css = 'span.published-status' css = 'span.published-status'
assert world.is_css_present(css) assert world.is_css_present(css)
status_text = world.browser.find_by_css(css).text status_text = world.css_text(css)
# e.g. 11/06/2012 at 16:25 # e.g. 11/06/2012 at 16:25
msg = 'Will Release:' msg = 'Will Release:'
......
...@@ -7,12 +7,18 @@ from common import * ...@@ -7,12 +7,18 @@ from common import *
@step('I fill in the registration form$') @step('I fill in the registration form$')
def i_fill_in_the_registration_form(step): def i_fill_in_the_registration_form(step):
attempt = 0
while attempt < 5:
try:
register_form = world.browser.find_by_css('form#register_form') register_form = world.browser.find_by_css('form#register_form')
register_form.find_by_name('email').fill('robot+studio@edx.org') register_form.find_by_name('email').fill('robot+studio@edx.org')
register_form.find_by_name('password').fill('test') register_form.find_by_name('password').fill('test')
register_form.find_by_name('username').fill('robot-studio') register_form.find_by_name('username').fill('robot-studio')
register_form.find_by_name('name').fill('Robot Studio') register_form.find_by_name('name').fill('Robot Studio')
register_form.find_by_name('terms_of_service').check() register_form.find_by_name('terms_of_service').check()
break
except:
attempt += 1
@step('I press the Create My Account button on the registration form$') @step('I press the Create My Account button on the registration form$')
......
...@@ -92,7 +92,7 @@ def i_expand_a_section(step): ...@@ -92,7 +92,7 @@ def i_expand_a_section(step):
def i_see_the_span_with_text(step, text): def i_see_the_span_with_text(step, text):
span_locator = '.toggle-button-sections span' span_locator = '.toggle-button-sections span'
assert_true(world.is_css_present(span_locator)) assert_true(world.is_css_present(span_locator))
assert_equal(world.css_find(span_locator).value, text) assert_equal(world.css_value(span_locator), text)
assert_true(world.css_visible(span_locator)) assert_true(world.css_visible(span_locator))
...@@ -108,13 +108,13 @@ def i_do_not_see_the_span_with_text(step, text): ...@@ -108,13 +108,13 @@ def i_do_not_see_the_span_with_text(step, text):
def all_sections_are_expanded(step): def all_sections_are_expanded(step):
subsection_locator = 'div.subsection-list' subsection_locator = 'div.subsection-list'
subsections = world.css_find(subsection_locator) subsections = world.css_find(subsection_locator)
for s in subsections: for index in range(len(subsections)):
assert_true(s.visible) assert_true(world.css_visible(subsection_locator, index=index))
@step(u'all sections are collapsed$') @step(u'all sections are collapsed$')
def all_sections_are_collapsed(step): def all_sections_are_collapsed(step):
subsection_locator = 'div.subsection-list' subsection_locator = 'div.subsection-list'
subsections = world.css_find(subsection_locator) subsections = world.css_find(subsection_locator)
for s in subsections: for index in range(len(subsections)):
assert_false(s.visible) assert_false(world.css_visible(subsection_locator, index=index))
...@@ -50,7 +50,7 @@ def i_click_to_edit_subsection_name(step): ...@@ -50,7 +50,7 @@ def i_click_to_edit_subsection_name(step):
def i_see_complete_subsection_name_with_quote_in_editor(step): def i_see_complete_subsection_name_with_quote_in_editor(step):
css = '.subsection-display-name-input' css = '.subsection-display-name-input'
assert world.is_css_present(css) assert world.is_css_present(css)
assert_equal(world.css_find(css).value, 'Subsection With "Quote"') assert_equal(world.css_value(css), 'Subsection With "Quote"')
@step('I have set a release date and due date in different years$') @step('I have set a release date and due date in different years$')
...@@ -69,7 +69,7 @@ def i_mark_it_as_homework(step): ...@@ -69,7 +69,7 @@ def i_mark_it_as_homework(step):
@step('I see it marked as Homework$') @step('I see it marked as Homework$')
def i_see_it_marked__as_homework(step): def i_see_it_marked__as_homework(step):
assert_equal(world.css_find(".status-label").value, 'Homework') assert_equal(world.css_value(".status-label"), 'Homework')
############ ASSERTIONS ################### ############ ASSERTIONS ###################
......
...@@ -8,7 +8,7 @@ from lettuce import world, step ...@@ -8,7 +8,7 @@ from lettuce import world, step
@step('when I view the video it does not have autoplay enabled') @step('when I view the video it does not have autoplay enabled')
def does_not_autoplay(_step): def does_not_autoplay(_step):
assert world.css_find('.video')[0]['data-autoplay'] == 'False' assert world.css_find('.video')[0]['data-autoplay'] == 'False'
assert world.css_find('.video_control')[0].has_class('play') assert world.css_has_class('.video_control', 'play')
@step('creating a video takes a single click') @step('creating a video takes a single click')
......
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