Skip to content
Snippets Groups Projects
Commit 0858dfde authored by Jay Zoldak's avatar Jay Zoldak
Browse files

Merge pull request #1141 from edx/zoldak/fix-problem-test

Wrap logic for selecting options in acceptance tests
parents 2379e7c3 8e6c0ea9
No related merge requests found
......@@ -189,6 +189,19 @@ def css_click_at(css_selector, index=0, x_coord=10, y_coord=10, timeout=5):
element.action_chains.perform()
@world.absorb
def select_option(name, value, index=0, wait_time=30):
'''
A method to select an option
This method will return True if the selection worked.
'''
select_css = "select[name='{}']".format(name)
option_css = "option[value='{}']".format(value)
css_selector = "{} {}".format(select_css, option_css)
return css_click(css_selector=css_selector, index=index, wait_time=wait_time)
@world.absorb
def id_click(elem_id):
"""
......
......@@ -166,9 +166,7 @@ def answer_problem(problem_type, correctness):
if problem_type == "drop down":
select_name = "input_i4x-edx-model_course-problem-drop_down_2_1"
option_text = 'Option 2' if correctness == 'correct' else 'Option 3'
# First wait for the element to be there on the page
world.wait_for_visible("select#{}".format(select_name))
world.browser.select(select_name, option_text)
world.select_option(select_name, option_text)
elif problem_type == "multiple choice":
if correctness == 'correct':
......@@ -244,7 +242,7 @@ def problem_has_answer(problem_type, answer_class):
if answer_class == 'blank':
assert world.is_css_not_present('option[selected="true"]')
else:
actual = world.browser.find_by_css('option[selected="true"]').value
actual = world.css_value('option[selected="true"]')
expected = 'Option 2' if answer_class == 'correct' else 'Option 3'
assert actual == expected
......@@ -305,10 +303,6 @@ def problem_has_answer(problem_type, answer_class):
pass
##############################
# HELPER METHODS
##############################
def add_problem_to_course(course, problem_type, extraMeta=None):
'''
Add a problem to the course we have created using factories.
......
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