This will remove imports from __future__ that are no longer needed. https://docs.python.org/3.5/library/2to3.html#2to3fixer-future
51 lines
1.4 KiB
Python
51 lines
1.4 KiB
Python
"""
|
|
Library Content XBlock Wrapper
|
|
"""
|
|
|
|
|
|
from bok_choy.page_object import PageObject
|
|
|
|
|
|
class LibraryContentXBlockWrapper(PageObject):
|
|
"""
|
|
A PageObject representing a wrapper around a LibraryContent block seen in the LMS
|
|
"""
|
|
url = None
|
|
BODY_SELECTOR = '.xblock-student_view div'
|
|
|
|
def __init__(self, browser, locator):
|
|
super(LibraryContentXBlockWrapper, self).__init__(browser)
|
|
self.locator = locator
|
|
|
|
def is_browser_on_page(self):
|
|
"""
|
|
Checks if page is opened
|
|
"""
|
|
return self.q(css='{}[data-id="{}"]'.format(self.BODY_SELECTOR, self.locator)).present
|
|
|
|
def _bounded_selector(self, selector):
|
|
"""
|
|
Return `selector`, but limited to this particular block's context
|
|
"""
|
|
return u'{}[data-id="{}"] {}'.format(
|
|
self.BODY_SELECTOR,
|
|
self.locator,
|
|
selector
|
|
)
|
|
|
|
@property
|
|
def children_contents(self):
|
|
"""
|
|
Gets contents of all child XBlocks as list of strings
|
|
"""
|
|
child_blocks = self.q(css=self._bounded_selector("div[data-id]"))
|
|
return frozenset(child.text for child in child_blocks)
|
|
|
|
@property
|
|
def children_headers(self):
|
|
"""
|
|
Gets headers of all child XBlocks as list of strings
|
|
"""
|
|
child_blocks_headers = self.q(css=self._bounded_selector("div[data-id] .problem-header"))
|
|
return frozenset(child.text for child in child_blocks_headers)
|