Permalink
Browse files

Merge pull request #25 from rbillings/searchresults

Added test for search with data into test_search_results
  • Loading branch information...
2 parents cf5fc80 + 0c2ca69 commit 9f73c6382da234b6988f969e82438cf06a59cda1 @stephendonner stephendonner committed Sep 15, 2012
Showing with 32 additions and 1 deletion.
  1. +9 −0 pages/regions/header.py
  2. +10 −1 pages/search_results.py
  3. +13 −0 tests/test_search_results.py
@@ -15,6 +15,7 @@ class HeaderRegion(Page):
_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')
_search_button_locator = (By.CSS_SELECTOR, '#search button')
+ _search_field_locator = (By.CSS_SELECTOR, '#search input#s')
def click_community_link(self):
self.selenium.find_element(*self._community_link_locator).click()
@@ -40,3 +41,11 @@ def click_search_button(self):
self.selenium.find_element(*self._search_button_locator).click()
from pages.search_results import SearchResultsPage
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)
@@ -12,11 +12,20 @@
class SearchResultsPage(BasePage):
_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.is_the_current_page
@property
def is_page_title_correct(self):
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")
@@ -8,6 +8,7 @@
from unittestzero import Assert
from pages.home import HomePage
+from pages.search_results import SearchResultsPage
class TestSearchPage:
@@ -20,3 +21,15 @@ def test_no_results_returned_from_blank_search(self, mozwebqa):
home_page.header_region.click_search_button()
Assert.true(home_page.is_the_current_page)
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.