Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
P
problem-builder
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
OpenEdx
problem-builder
Commits
351705cb
Commit
351705cb
authored
Mar 02, 2016
by
Braden MacDonald
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Build without scroll_to, fix Workbench header interference.
parent
9fd5e039
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
13 additions
and
77 deletions
+13
-77
problem_builder/tests/integration/base_test.py
+13
-18
problem_builder/tests/integration/test_answer.py
+0
-2
problem_builder/tests/integration/test_assessment.py
+0
-24
problem_builder/tests/integration/test_mentoring.py
+0
-17
problem_builder/tests/integration/test_questionnaire.py
+0
-16
No files found.
problem_builder/tests/integration/base_test.py
View file @
351705cb
...
@@ -63,24 +63,7 @@ class PopupCheckMixin(object):
...
@@ -63,24 +63,7 @@ class PopupCheckMixin(object):
self
.
assertFalse
(
item_feedback_popup
.
is_displayed
())
self
.
assertFalse
(
item_feedback_popup
.
is_displayed
())
class
ScrollToMixin
(
object
):
class
ProblemBuilderBaseTest
(
SeleniumXBlockTest
,
PopupCheckMixin
):
def
scroll_to
(
self
,
component
,
offset
=
100
):
"""
Scrolls browser viewport so component is visible. In rare cases you might
need to provide an offset, which will change position by some amount
of pixels.
:return:
"""
self
.
browser
.
execute_script
(
"return window.scrollTo(0, arguments[0]);"
,
component
.
location
[
'y'
]
+
offset
)
self
.
browser
.
execute_script
(
"return window.scrollTo(0, arguments[0]);"
,
component
.
location
[
'y'
]
-
offset
)
class
ProblemBuilderBaseTest
(
SeleniumXBlockTest
,
PopupCheckMixin
,
ScrollToMixin
):
"""
"""
The new base class for integration tests.
The new base class for integration tests.
Scenarios can be loaded and edited on the fly.
Scenarios can be loaded and edited on the fly.
...
@@ -97,6 +80,12 @@ class ProblemBuilderBaseTest(SeleniumXBlockTest, PopupCheckMixin, ScrollToMixin)
...
@@ -97,6 +80,12 @@ class ProblemBuilderBaseTest(SeleniumXBlockTest, PopupCheckMixin, ScrollToMixin)
if
load_immediately
:
if
load_immediately
:
return
self
.
go_to_view
(
"student_view"
)
return
self
.
go_to_view
(
"student_view"
)
def
go_to_view
(
self
,
view_name
):
""" Eliminate errors that come from the Workbench banner overlapping elements """
element
=
super
(
ProblemBuilderBaseTest
,
self
)
.
go_to_view
(
view_name
)
self
.
browser
.
execute_script
(
'document.querySelectorAll("header.banner")[0].style.display="none";'
)
return
element
def
click_submit
(
self
,
mentoring
):
def
click_submit
(
self
,
mentoring
):
""" Click the submit button and wait for the response """
""" Click the submit button and wait for the response """
submit
=
mentoring
.
find_element_by_css_selector
(
'.submit input.input-main'
)
submit
=
mentoring
.
find_element_by_css_selector
(
'.submit input.input-main'
)
...
@@ -119,6 +108,12 @@ class MentoringBaseTest(SeleniumBaseTest, PopupCheckMixin):
...
@@ -119,6 +108,12 @@ class MentoringBaseTest(SeleniumBaseTest, PopupCheckMixin):
__asides_patch
=
None
__asides_patch
=
None
def
go_to_page
(
self
,
page_title
,
**
kwargs
):
""" Eliminate errors that come from the Workbench banner overlapping elements """
element
=
super
(
MentoringBaseTest
,
self
)
.
go_to_page
(
page_title
,
**
kwargs
)
self
.
browser
.
execute_script
(
'document.querySelectorAll("header.banner")[0].style.display="none";'
)
return
element
@classmethod
@classmethod
def
setUpClass
(
cls
):
def
setUpClass
(
cls
):
super
(
MentoringBaseTest
,
cls
)
.
setUpClass
()
super
(
MentoringBaseTest
,
cls
)
.
setUpClass
()
...
...
problem_builder/tests/integration/test_answer.py
View file @
351705cb
...
@@ -40,8 +40,6 @@ class AnswerBlockTest(MentoringBaseTest):
...
@@ -40,8 +40,6 @@ class AnswerBlockTest(MentoringBaseTest):
# Another answer with the same name
# Another answer with the same name
mentoring
=
self
.
go_to_page
(
'Answer Edit 1'
)
mentoring
=
self
.
go_to_page
(
'Answer Edit 1'
)
header1
=
self
.
browser
.
find_element_by_css_selector
(
'h1'
)
self
.
assertEqual
(
header1
.
text
,
'XBlock: Answer Edit 1'
)
# Check <html> child
# Check <html> child
p
=
mentoring
.
find_element_by_css_selector
(
'p'
)
p
=
mentoring
.
find_element_by_css_selector
(
'p'
)
...
...
problem_builder/tests/integration/test_assessment.py
View file @
351705cb
...
@@ -23,28 +23,6 @@ from .base_test import CORRECT, INCORRECT, PARTIAL, MentoringAssessmentBaseTest,
...
@@ -23,28 +23,6 @@ from .base_test import CORRECT, INCORRECT, PARTIAL, MentoringAssessmentBaseTest,
@ddt
@ddt
class
MentoringAssessmentTest
(
MentoringAssessmentBaseTest
):
class
MentoringAssessmentTest
(
MentoringAssessmentBaseTest
):
def
_selenium_bug_workaround_scroll_to
(
self
,
mentoring
,
question
):
"""Workaround for selenium bug:
Some version of Selenium has a bug that prevents scrolling
to radiobuttons before being clicked. The click not taking
place, when it's outside the view.
Since the bug does not affect other content, asking Selenium
to click on the legend first, will properly scroll it.
It also have it's fair share of issues with the workbench header.
For this reason we click on the bottom-most element, scrolling to it.
Then, click on the title of the question (also scrolling to it)
hopefully, this gives us enough room for the full step with the
control buttons to fit.
"""
controls
=
mentoring
.
find_element_by_css_selector
(
"div.submit"
)
title
=
question
.
find_element_by_css_selector
(
"h3.question-title"
)
controls
.
click
()
title
.
click
()
def
assert_persistent_elements_present
(
self
,
mentoring
):
def
assert_persistent_elements_present
(
self
,
mentoring
):
self
.
assertIn
(
"A Simple Assessment"
,
mentoring
.
text
)
self
.
assertIn
(
"A Simple Assessment"
,
mentoring
.
text
)
self
.
assertIn
(
"This paragraph is shared between all questions."
,
mentoring
.
text
)
self
.
assertIn
(
"This paragraph is shared between all questions."
,
mentoring
.
text
)
...
@@ -55,7 +33,6 @@ class MentoringAssessmentTest(MentoringAssessmentBaseTest):
...
@@ -55,7 +33,6 @@ class MentoringAssessmentTest(MentoringAssessmentBaseTest):
def
freeform_answer
(
self
,
number
,
mentoring
,
controls
,
text_input
,
result
,
saved_value
=
""
,
last
=
False
):
def
freeform_answer
(
self
,
number
,
mentoring
,
controls
,
text_input
,
result
,
saved_value
=
""
,
last
=
False
):
question
=
self
.
expect_question_visible
(
number
,
mentoring
)
question
=
self
.
expect_question_visible
(
number
,
mentoring
)
self
.
assert_persistent_elements_present
(
mentoring
)
self
.
assert_persistent_elements_present
(
mentoring
)
self
.
_selenium_bug_workaround_scroll_to
(
mentoring
,
question
)
answer
=
mentoring
.
find_element_by_css_selector
(
"textarea.answer.editable"
)
answer
=
mentoring
.
find_element_by_css_selector
(
"textarea.answer.editable"
)
...
@@ -114,7 +91,6 @@ class MentoringAssessmentTest(MentoringAssessmentBaseTest):
...
@@ -114,7 +91,6 @@ class MentoringAssessmentTest(MentoringAssessmentBaseTest):
def
rating_question
(
self
,
number
,
mentoring
,
controls
,
choice_name
,
result
,
last
=
False
):
def
rating_question
(
self
,
number
,
mentoring
,
controls
,
choice_name
,
result
,
last
=
False
):
question
=
self
.
expect_question_visible
(
number
,
mentoring
)
question
=
self
.
expect_question_visible
(
number
,
mentoring
)
self
.
assert_persistent_elements_present
(
mentoring
)
self
.
assert_persistent_elements_present
(
mentoring
)
self
.
_selenium_bug_workaround_scroll_to
(
mentoring
,
question
)
self
.
assertIn
(
"How much do you rate this MCQ?"
,
mentoring
.
text
)
self
.
assertIn
(
"How much do you rate this MCQ?"
,
mentoring
.
text
)
self
.
assert_disabled
(
controls
.
submit
)
self
.
assert_disabled
(
controls
.
submit
)
...
...
problem_builder/tests/integration/test_mentoring.py
View file @
351705cb
...
@@ -137,16 +137,12 @@ class ProblemBuilderQuestionnaireBlockTest(ProblemBuilderBaseTest):
...
@@ -137,16 +137,12 @@ class ProblemBuilderQuestionnaireBlockTest(ProblemBuilderBaseTest):
self
.
assertFalse
(
choice_input
.
is_selected
())
self
.
assertFalse
(
choice_input
.
is_selected
())
def
_standard_filling
(
self
,
answer
,
mcq
,
mrq
,
rating
):
def
_standard_filling
(
self
,
answer
,
mcq
,
mrq
,
rating
):
self
.
scroll_to
(
answer
)
answer
.
send_keys
(
'This is the answer'
)
answer
.
send_keys
(
'This is the answer'
)
self
.
scroll_to
(
mcq
)
self
.
click_choice
(
mcq
,
"Yes"
)
self
.
click_choice
(
mcq
,
"Yes"
)
# 1st, 3rd and 4th options, first three are correct, i.e. two mistakes: 2nd and 4th
# 1st, 3rd and 4th options, first three are correct, i.e. two mistakes: 2nd and 4th
self
.
scroll_to
(
mrq
,
300
)
self
.
click_choice
(
mrq
,
"Its elegance"
)
self
.
click_choice
(
mrq
,
"Its elegance"
)
self
.
click_choice
(
mrq
,
"Its gracefulness"
)
self
.
click_choice
(
mrq
,
"Its gracefulness"
)
self
.
click_choice
(
mrq
,
"Its bugs"
)
self
.
click_choice
(
mrq
,
"Its bugs"
)
self
.
scroll_to
(
rating
)
self
.
click_choice
(
rating
,
"4"
)
self
.
click_choice
(
rating
,
"4"
)
# mcq and rating can't be reset easily, but it's not required; listing them here to keep method signature similar
# mcq and rating can't be reset easily, but it's not required; listing them here to keep method signature similar
...
@@ -157,11 +153,8 @@ class ProblemBuilderQuestionnaireBlockTest(ProblemBuilderBaseTest):
...
@@ -157,11 +153,8 @@ class ProblemBuilderQuestionnaireBlockTest(ProblemBuilderBaseTest):
checkbox
.
click
()
checkbox
.
click
()
def
_standard_checks
(
self
,
answer
,
mcq
,
mrq
,
rating
,
messages
):
def
_standard_checks
(
self
,
answer
,
mcq
,
mrq
,
rating
,
messages
):
self
.
scroll_to
(
answer
)
self
.
assertEqual
(
answer
.
get_attribute
(
'value'
),
'This is the answer'
)
self
.
assertEqual
(
answer
.
get_attribute
(
'value'
),
'This is the answer'
)
self
.
scroll_to
(
mcq
)
self
.
_assert_feedback_showed
(
mcq
,
0
,
"Great!"
,
click_choice_result
=
True
)
self
.
_assert_feedback_showed
(
mcq
,
0
,
"Great!"
,
click_choice_result
=
True
)
self
.
scroll_to
(
mrq
,
300
)
self
.
_assert_feedback_showed
(
self
.
_assert_feedback_showed
(
mrq
,
0
,
"This is something everyone has to like about this MRQ"
,
mrq
,
0
,
"This is something everyone has to like about this MRQ"
,
click_choice_result
=
True
click_choice_result
=
True
...
@@ -172,23 +165,18 @@ class ProblemBuilderQuestionnaireBlockTest(ProblemBuilderBaseTest):
...
@@ -172,23 +165,18 @@ class ProblemBuilderQuestionnaireBlockTest(ProblemBuilderBaseTest):
)
)
self
.
_assert_feedback_showed
(
mrq
,
2
,
"This MRQ is indeed very graceful"
,
click_choice_result
=
True
)
self
.
_assert_feedback_showed
(
mrq
,
2
,
"This MRQ is indeed very graceful"
,
click_choice_result
=
True
)
self
.
_assert_feedback_showed
(
mrq
,
3
,
"Nah, there aren't any!"
,
click_choice_result
=
True
,
success
=
False
)
self
.
_assert_feedback_showed
(
mrq
,
3
,
"Nah, there aren't any!"
,
click_choice_result
=
True
,
success
=
False
)
self
.
scroll_to
(
rating
)
self
.
_assert_feedback_showed
(
rating
,
3
,
"I love good grades."
,
click_choice_result
=
True
)
self
.
_assert_feedback_showed
(
rating
,
3
,
"I love good grades."
,
click_choice_result
=
True
)
self
.
assertTrue
(
messages
.
is_displayed
())
self
.
assertTrue
(
messages
.
is_displayed
())
self
.
scroll_to
(
messages
)
self
.
assertEqual
(
messages
.
text
,
"FEEDBACK
\n
Not done yet"
)
self
.
assertEqual
(
messages
.
text
,
"FEEDBACK
\n
Not done yet"
)
def
_feedback_customized_checks
(
self
,
answer
,
mcq
,
mrq
,
rating
,
messages
):
def
_feedback_customized_checks
(
self
,
answer
,
mcq
,
mrq
,
rating
,
messages
):
# Long answer: Previous answer and feedback visible
# Long answer: Previous answer and feedback visible
self
.
scroll_to
(
answer
)
self
.
assertEqual
(
answer
.
get_attribute
(
'value'
),
'This is the answer'
)
self
.
assertEqual
(
answer
.
get_attribute
(
'value'
),
'This is the answer'
)
# MCQ: Previous answer and feedback hidden
# MCQ: Previous answer and feedback hidden
self
.
scroll_to
(
mcq
)
for
i
in
range
(
3
):
for
i
in
range
(
3
):
self
.
_assert_feedback_hidden
(
mcq
,
i
)
self
.
_assert_feedback_hidden
(
mcq
,
i
)
self
.
_assert_not_checked
(
mcq
,
i
)
self
.
_assert_not_checked
(
mcq
,
i
)
# MRQ: Previous answer and feedback visible
# MRQ: Previous answer and feedback visible
self
.
scroll_to
(
mrq
,
300
)
self
.
_assert_feedback_showed
(
self
.
_assert_feedback_showed
(
mrq
,
0
,
"This is something everyone has to like about this MRQ"
,
mrq
,
0
,
"This is something everyone has to like about this MRQ"
,
click_choice_result
=
True
click_choice_result
=
True
...
@@ -200,13 +188,11 @@ class ProblemBuilderQuestionnaireBlockTest(ProblemBuilderBaseTest):
...
@@ -200,13 +188,11 @@ class ProblemBuilderQuestionnaireBlockTest(ProblemBuilderBaseTest):
self
.
_assert_feedback_showed
(
mrq
,
2
,
"This MRQ is indeed very graceful"
,
click_choice_result
=
True
)
self
.
_assert_feedback_showed
(
mrq
,
2
,
"This MRQ is indeed very graceful"
,
click_choice_result
=
True
)
self
.
_assert_feedback_showed
(
mrq
,
3
,
"Nah, there aren't any!"
,
click_choice_result
=
True
,
success
=
False
)
self
.
_assert_feedback_showed
(
mrq
,
3
,
"Nah, there aren't any!"
,
click_choice_result
=
True
,
success
=
False
)
# Rating: Previous answer and feedback hidden
# Rating: Previous answer and feedback hidden
self
.
scroll_to
(
rating
)
for
i
in
range
(
5
):
for
i
in
range
(
5
):
self
.
_assert_feedback_hidden
(
rating
,
i
)
self
.
_assert_feedback_hidden
(
rating
,
i
)
self
.
_assert_not_checked
(
rating
,
i
)
self
.
_assert_not_checked
(
rating
,
i
)
# Messages
# Messages
self
.
assertTrue
(
messages
.
is_displayed
())
self
.
assertTrue
(
messages
.
is_displayed
())
self
.
scroll_to
(
messages
)
self
.
assertEqual
(
messages
.
text
,
"FEEDBACK
\n
Not done yet"
)
self
.
assertEqual
(
messages
.
text
,
"FEEDBACK
\n
Not done yet"
)
def
reload_student_view
(
self
):
def
reload_student_view
(
self
):
...
@@ -285,11 +271,8 @@ class ProblemBuilderQuestionnaireBlockTest(ProblemBuilderBaseTest):
...
@@ -285,11 +271,8 @@ class ProblemBuilderQuestionnaireBlockTest(ProblemBuilderBaseTest):
self
.
assertFalse
(
submit
.
is_enabled
())
self
.
assertFalse
(
submit
.
is_enabled
())
# ... until student answers MCQs again
# ... until student answers MCQs again
self
.
scroll_to
(
mcq
)
self
.
click_choice
(
mcq
,
"Maybe not"
)
self
.
click_choice
(
mcq
,
"Maybe not"
)
self
.
scroll_to
(
rating
)
self
.
click_choice
(
rating
,
"2"
)
self
.
click_choice
(
rating
,
"2"
)
self
.
scroll_to
(
submit
)
self
.
assertTrue
(
submit
.
is_enabled
())
self
.
assertTrue
(
submit
.
is_enabled
())
def
test_given_perfect_score_in_past_loads_current_result
(
self
):
def
test_given_perfect_score_in_past_loads_current_result
(
self
):
...
...
problem_builder/tests/integration/test_questionnaire.py
View file @
351705cb
...
@@ -32,19 +32,6 @@ from .base_test import MentoringBaseTest
...
@@ -32,19 +32,6 @@ from .base_test import MentoringBaseTest
@ddt.ddt
@ddt.ddt
class
QuestionnaireBlockTest
(
MentoringBaseTest
):
class
QuestionnaireBlockTest
(
MentoringBaseTest
):
def
_selenium_bug_workaround_scroll_to
(
self
,
mcq_legend
):
"""Workaround for selenium bug:
Some version of Selenium has a bug that prevents scrolling
to radiobuttons before being clicked. The click not taking
place, when it's outside the view.
Since the bug does not affect other content, asking Selenium
to click on the legend first, will properly scroll it.
"""
mcq_legend
.
click
()
def
_get_choice_label_text
(
self
,
choice
):
def
_get_choice_label_text
(
self
,
choice
):
return
choice
.
find_element_by_css_selector
(
'label'
)
.
text
return
choice
.
find_element_by_css_selector
(
'label'
)
.
text
...
@@ -104,7 +91,6 @@ class QuestionnaireBlockTest(MentoringBaseTest):
...
@@ -104,7 +91,6 @@ class QuestionnaireBlockTest(MentoringBaseTest):
mcq1_answer
,
mcq2_answer
,
item_feedback1
,
item_feedback2
,
mcq1_answer
,
mcq2_answer
,
item_feedback1
,
item_feedback2
,
feedback1_selector
=
".choice-tips .tip p"
,
feedback1_selector
=
".choice-tips .tip p"
,
feedback2_selector
=
".choice-tips .tip p"
):
feedback2_selector
=
".choice-tips .tip p"
):
self
.
_selenium_bug_workaround_scroll_to
(
mcq1
)
mcq1_choices_input
[
mcq1_answer
]
.
click
()
mcq1_choices_input
[
mcq1_answer
]
.
click
()
mcq2_choices_input
[
mcq2_answer
]
.
click
()
mcq2_choices_input
[
mcq2_answer
]
.
click
()
...
@@ -125,7 +111,6 @@ class QuestionnaireBlockTest(MentoringBaseTest):
...
@@ -125,7 +111,6 @@ class QuestionnaireBlockTest(MentoringBaseTest):
self
.
assertFalse
(
submit
.
is_enabled
())
self
.
assertFalse
(
submit
.
is_enabled
())
# Submit button stays disabled when there are unfinished mcqs
# Submit button stays disabled when there are unfinished mcqs
self
.
_selenium_bug_workaround_scroll_to
(
mcq1
)
mcq1_choices_input
[
1
]
.
click
()
mcq1_choices_input
[
1
]
.
click
()
self
.
assertFalse
(
submit
.
is_enabled
())
self
.
assertFalse
(
submit
.
is_enabled
())
...
@@ -244,7 +229,6 @@ class QuestionnaireBlockTest(MentoringBaseTest):
...
@@ -244,7 +229,6 @@ class QuestionnaireBlockTest(MentoringBaseTest):
self
.
assertFalse
(
submit
.
is_enabled
())
self
.
assertFalse
(
submit
.
is_enabled
())
inputs
=
choices_list
.
find_elements_by_css_selector
(
'.choice-selector input'
)
inputs
=
choices_list
.
find_elements_by_css_selector
(
'.choice-selector input'
)
self
.
_selenium_bug_workaround_scroll_to
(
choices_list
)
inputs
[
0
]
.
click
()
inputs
[
0
]
.
click
()
inputs
[
1
]
.
click
()
inputs
[
1
]
.
click
()
inputs
[
2
]
.
click
()
inputs
[
2
]
.
click
()
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment