Commit f0ec2660 by Robert Raposa Committed by Brian Jacobel

Fix bokchoy.

parent 14a737ec
...@@ -40,6 +40,11 @@ class CourseOutlinePage(PageObject): ...@@ -40,6 +40,11 @@ class CourseOutlinePage(PageObject):
url = None url = None
SECTION_SELECTOR = '.outline-item.section:nth-of-type({0})'
SECTION_TITLES_SELECTOR = '.section-name span'
SUBSECTION_SELECTOR = SECTION_SELECTOR + ' .subsection:nth-of-type({1}) .outline-item'
SUBSECTION_TITLES_SELECTOR = SECTION_SELECTOR + ' .subsection a span:first-child'
def __init__(self, browser, parent_page): def __init__(self, browser, parent_page):
super(CourseOutlinePage, self).__init__(browser) super(CourseOutlinePage, self).__init__(browser)
self.parent_page = parent_page self.parent_page = parent_page
...@@ -105,9 +110,7 @@ class CourseOutlinePage(PageObject): ...@@ -105,9 +110,7 @@ class CourseOutlinePage(PageObject):
return return
# Convert list indices (start at zero) to CSS indices (start at 1) # Convert list indices (start at zero) to CSS indices (start at 1)
subsection_css = ( subsection_css = self.SUBSECTION_SELECTOR.format(section_index + 1, subsection_index + 1)
".outline-item.section:nth-of-type({0}) .subsection:nth-of-type({1}) .outline-item"
).format(section_index + 1, subsection_index + 1)
# Click the subsection and ensure that the page finishes reloading # Click the subsection and ensure that the page finishes reloading
self.q(css=subsection_css).first.click() self.q(css=subsection_css).first.click()
...@@ -123,25 +126,15 @@ class CourseOutlinePage(PageObject): ...@@ -123,25 +126,15 @@ class CourseOutlinePage(PageObject):
""" """
Return a list of all section titles on the page. Return a list of all section titles on the page.
""" """
section_css = '.section-name span' return self.q(css=self.SECTION_TITLES_SELECTOR).map(lambda el: el.text.strip()).results
return self.q(css=section_css).map(lambda el: el.text.strip()).results
def _subsection_titles(self, section_index): def _subsection_titles(self, section_index):
""" """
Return a list of all subsection titles on the page Return a list of all subsection titles on the page
for the section at index `section_index` (starts at 1). for the section at index `section_index` (starts at 1).
""" """
# Retrieve the subsection title for the section subsection_css = self.SUBSECTION_TITLES_SELECTOR.format(section_index)
# Add one to the list index to get the CSS index, which starts at one return self.q(css=subsection_css).map(
subsection_css = (
# TODO: TNL-6387: Will need to switch to this selector for subsections
# ".outline-item.section:nth-of-type({0}) .subsection span:nth-of-type(1)"
".outline-item.section:nth-of-type({0}) .subsection a"
).format(section_index)
return self.q(
css=subsection_css
).map(
lambda el: el.get_attribute('innerHTML').strip() lambda el: el.get_attribute('innerHTML').strip()
).results ).results
......
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