From 586d798069b3f309461e9a772aa7eeccb86509e6 Mon Sep 17 00:00:00 2001 From: Jesse Zoldak Date: Fri, 9 Jan 2015 13:52:46 -0500 Subject: [PATCH] Fix flakiness on annotation selenium test --- .../test/acceptance/pages/lms/annotation_component.py | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/common/test/acceptance/pages/lms/annotation_component.py b/common/test/acceptance/pages/lms/annotation_component.py index a1e31fc520..ec8ef3906c 100644 --- a/common/test/acceptance/pages/lms/annotation_component.py +++ b/common/test/acceptance/pages/lms/annotation_component.py @@ -65,8 +65,16 @@ class AnnotationComponentPage(PageObject): Submit correct answer for active problem. """ self.q(css=self.active_problem_selector('.comment')).fill('Test Response') - self.q(css=self.active_problem_selector('.tag[data-id="{}"]'.format(self.active_problem))).click() + + answer_css = self.active_problem_selector('.tag[data-id="{}"]'.format(self.active_problem)) + # Selenium will first move the element into view then click on it. + self.q(css=answer_css).click() + # Wait for the click to take effect, which is after the class is applied. + self.wait_for(lambda: 'selected' in self.q(css=answer_css).attrs('class')[0], description='answer selected') + # Click the "Check" button. self.q(css=self.active_problem_selector('.check')).click() + # This will trigger a POST to problem_check so wait until the response is returned. + self.wait_for_ajax() def check_feedback(self): """