dashboard_search.py 1.13 KB
Newer Older
1 2 3 4 5
"""
Dashboard search
"""

from bok_choy.page_object import PageObject
6

7
from common.test.acceptance.pages.lms import BASE_URL
8 9 10 11 12 13 14 15 16 17 18 19 20


class DashboardSearchPage(PageObject):
    """
    Dashboard page featuring a search form
    """

    search_bar_selector = '#dashboard-search-bar'
    url = "{base}/dashboard".format(base=BASE_URL)

    @property
    def search_results(self):
        """ search results list showing """
21
        return self.q(css='.search-results')
22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41

    def is_browser_on_page(self):
        """ did we find the search bar in the UI """
        return self.q(css=self.search_bar_selector).present

    def enter_search_term(self, text):
        """ enter the search term into the box """
        self.q(css=self.search_bar_selector + ' input[type="text"]').fill(text)

    def search(self):
        """ execute the search """
        self.q(css=self.search_bar_selector + ' [type="submit"]').click()
        self.wait_for_element_visibility('.search-info', 'Search results are shown')

    def search_for_term(self, text):
        """
        Search and return results
        """
        self.enter_search_term(text)
        self.search()