Commit 92d4726b by Will Daly

Merge pull request #2639 from edx/will/bok-choy-test-robustness

Will/bok choy test robustness
parents 4c21270f defbd874
...@@ -4,7 +4,7 @@ Unit page in Studio ...@@ -4,7 +4,7 @@ Unit page in Studio
from bok_choy.page_object import PageObject from bok_choy.page_object import PageObject
from bok_choy.query import SubQuery from bok_choy.query import SubQuery
from bok_choy.promise import EmptyPromise, fulfill from bok_choy.promise import Promise, EmptyPromise, fulfill
from . import BASE_URL from . import BASE_URL
...@@ -27,12 +27,17 @@ class UnitPage(PageObject): ...@@ -27,12 +27,17 @@ class UnitPage(PageObject):
return self.is_css_present('body.view-unit') return self.is_css_present('body.view-unit')
def component(self, title): def component(self, title):
return Component( return Component(self.browser, self._locator(title))
self.browser,
self.q(css=Component.BODY_SELECTOR).filter( def _locator(self, title):
def _check_func():
locators = self.q(css=Component.BODY_SELECTOR).filter(
SubQuery(css=Component.NAME_SELECTOR).filter(text=title) SubQuery(css=Component.NAME_SELECTOR).filter(text=title)
)[0]['data-locator'] ).map(lambda el: el['data-locator']).results
)
return (len(locators) > 0, locators[0])
return fulfill(Promise(_check_func, "Found data locator for component"))
class Component(PageObject): class Component(PageObject):
......
...@@ -69,6 +69,23 @@ class RegistrationTest(UniqueCourseTest): ...@@ -69,6 +69,23 @@ class RegistrationTest(UniqueCourseTest):
course_names = dashboard.available_courses course_names = dashboard.available_courses
self.assertIn(self.course_info['display_name'], course_names) self.assertIn(self.course_info['display_name'], course_names)
def assert_course_available(self, course_id):
# Occassionally this does not show up immediately,
# so we wait and try reloading the page
def _check_course_available():
available = self.find_courses_page.course_id_list
if course_id in available:
return True
else:
self.find_courses_page.visit()
return False
return fulfill(EmptyPromise(
_check_course_available,
"Found course {course_id} in the list of available courses".format(course_id=course_id),
try_limit=3, try_interval=2
))
class LanguageTest(UniqueCourseTest): class LanguageTest(UniqueCourseTest):
""" """
......
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