Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 16 additions & 2 deletions common/test/acceptance/pages/lms/tab_nav.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
"""

from bok_choy.page_object import PageObject
from bok_choy.promise import EmptyPromise, fulfill_after
from bok_choy.promise import Promise, EmptyPromise, fulfill_after, fulfill


class TabNavPage(PageObject):
Expand Down Expand Up @@ -49,8 +49,9 @@ def is_on_tab(self, tab_name):
def _tab_css(self, tab_name):
"""
Return the CSS to click for `tab_name`.
If no tabs exist for that name, return `None`.
"""
all_tabs = self.css_text('ol.course-tabs li a')
all_tabs = self._tab_names

try:
tab_index = all_tabs.index(tab_name)
Expand All @@ -59,6 +60,19 @@ def _tab_css(self, tab_name):
else:
return 'ol.course-tabs li:nth-of-type({0}) a'.format(tab_index + 1)

@property
def _tab_names(self):
"""
Return the list of available tab names. If no tab names
are available, wait for them to load. Raises a `BrokenPromiseError`
if the tab names fail to load.
"""
def _check_func():
tab_names = self.css_text('ol.course-tabs li a')
return (len(tab_names) > 0, tab_names)

return fulfill(Promise(_check_func, "Get all tab names"))

def _is_on_tab_promise(self, tab_name):
"""
Return a `Promise` that the user is on the tab `tab_name`.
Expand Down