Skip to content
This repository has been archived by the owner on Aug 20, 2018. It is now read-only.

Commit

Permalink
Browse files Browse the repository at this point in the history
Merge pull request #25 from rbillings/searchresults
Added test for search with data into test_search_results
  • Loading branch information
stephendonner committed Sep 15, 2012
2 parents cf5fc80 + 0c2ca69 commit 9f73c63
Show file tree
Hide file tree
Showing 3 changed files with 32 additions and 1 deletion.
9 changes: 9 additions & 0 deletions pages/regions/header.py
Expand Up @@ -15,6 +15,7 @@ class HeaderRegion(Page):
_media_link_locator = (By.CSS_SELECTOR, '#nav-main li:nth-child(5) a') _media_link_locator = (By.CSS_SELECTOR, '#nav-main li:nth-child(5) a')
_docs_link_locator = (By.CSS_SELECTOR, '#nav-main li:nth-child(6) a') _docs_link_locator = (By.CSS_SELECTOR, '#nav-main li:nth-child(6) a')
_search_button_locator = (By.CSS_SELECTOR, '#search button') _search_button_locator = (By.CSS_SELECTOR, '#search button')
_search_field_locator = (By.CSS_SELECTOR, '#search input#s')


def click_community_link(self): def click_community_link(self):
self.selenium.find_element(*self._community_link_locator).click() self.selenium.find_element(*self._community_link_locator).click()
Expand All @@ -40,3 +41,11 @@ def click_search_button(self):
self.selenium.find_element(*self._search_button_locator).click() self.selenium.find_element(*self._search_button_locator).click()
from pages.search_results import SearchResultsPage from pages.search_results import SearchResultsPage
return SearchResultsPage(self.testsetup) return SearchResultsPage(self.testsetup)

def click_search_field(self):
self.selenium.find_element(*self._search_field_locator).click()
from pages.search_results import SearchResultsPage
return SearchResultsPage(self.testsetup)

def type_in_search_field(self, text):
self.selenium.find_element(*self._search_field_locator).send_keys(text)
11 changes: 10 additions & 1 deletion pages/search_results.py
Expand Up @@ -12,11 +12,20 @@
class SearchResultsPage(BasePage): class SearchResultsPage(BasePage):


_page_title = u'Search results' _page_title = u'Search results'
_search_text_locator = (By.ID, 'content-main')


def go_to_docs_page(self): def search_results_page(self):
self.selenium.get(self.testsetup.base_url + '/?s') self.selenium.get(self.testsetup.base_url + '/?s')
self.is_the_current_page self.is_the_current_page


@property @property
def is_page_title_correct(self): def is_page_title_correct(self):
return self.selenium.get_title() == self._page_title return self.selenium.get_title() == self._page_title

@property
def search_text(self):
return self.selenium.find_element(*self._search_text_locator).text

@property
def results(self):
return self.selenium.find_elements(By.CSS_SELECTOR, "#content-main > article")
13 changes: 13 additions & 0 deletions tests/test_search_results.py
Expand Up @@ -8,6 +8,7 @@
from unittestzero import Assert from unittestzero import Assert


from pages.home import HomePage from pages.home import HomePage
from pages.search_results import SearchResultsPage




class TestSearchPage: class TestSearchPage:
Expand All @@ -20,3 +21,15 @@ def test_no_results_returned_from_blank_search(self, mozwebqa):
home_page.header_region.click_search_button() home_page.header_region.click_search_button()
Assert.true(home_page.is_the_current_page) Assert.true(home_page.is_the_current_page)
Assert.true(home_page.get_url_current_page().endswith('/?s=')) Assert.true(home_page.get_url_current_page().endswith('/?s='))

@pytest.mark.nondestructive
def test_search_results_returned(self,mozwebqa):
home_page = HomePage(mozwebqa)
home_page.go_to_home_page()

home_page.header_region.type_in_search_field('job board')
search_results_page = home_page.header_region.click_search_button()

expected_text= "Search results"
Assert.contains(expected_text, search_results_page._page_title)
Assert.greater(len(search_results_page.results), 0)

0 comments on commit 9f73c63

Please sign in to comment.