Permalink
Browse files

Added test for search with data into test_search_results

  • Loading branch information...
1 parent cf5fc80 commit 715202145557488cd4dbe700a6773be996684f6a Rebecca Billings committed Sep 7, 2012
Showing with 28 additions and 1 deletion.
  1. +9 −0 pages/regions/header.py
  2. +6 −1 pages/search_results.py
  3. +13 −0 tests/test_search_results.py
View
@@ -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')
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)
View
@@ -12,11 +12,16 @@
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
@@ -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()
+
+ search_results_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.true(search_results_page.get_url_current_page().endswith('/?s='))

0 comments on commit 7152021

Please sign in to comment.