course_page.py 1.13 KB
Newer Older
1 2 3 4 5
"""
Base class for pages in courseware.
"""

from bok_choy.page_object import PageObject
6 7
from common.test.acceptance.pages.lms import BASE_URL
from common.test.acceptance.pages.lms.tab_nav import TabNavPage
8 9 10 11 12 13 14 15 16


class CoursePage(PageObject):
    """
    Abstract base class for page objects within a course.
    """

    # Overridden by subclasses to provide the relative path within the course
    # Paths should not include the leading forward slash.
17
    url_path = ""
18 19 20 21 22 23 24 25 26 27 28 29 30 31

    def __init__(self, browser, course_id):
        """
        Course ID is currently of the form "edx/999/2013_Spring"
        but this format could change.
        """
        super(CoursePage, self).__init__(browser)
        self.course_id = course_id

    @property
    def url(self):
        """
        Construct a URL to the page within the course.
        """
32
        return BASE_URL + "/courses/" + self.course_id + "/" + self.url_path
33 34 35 36 37 38 39 40

    def has_tab(self, tab_name):
        """
        Returns true if the current page is showing a tab with the given name.
        :return:
        """
        tab_nav = TabNavPage(self.browser)
        return tab_name in tab_nav.tab_names