Permalink
Browse files

test to ensure no results are returned for a blank search.

  • Loading branch information...
1 parent 06527dd commit bc617588b5e14cb1b97ba5c958f7715504639f46 @glennhoward glennhoward committed Jul 27, 2012
Showing with 61 additions and 0 deletions.
  1. +11 −0 page.py
  2. +25 −0 pages/search_results.py
  3. +25 −0 tests/test_search_results.py
View
11 page.py
@@ -5,6 +5,7 @@
# file, You can obtain one at http://mozilla.org/MPL/2.0/.
from selenium.webdriver.support.ui import WebDriverWait
+from selenium.common.exceptions import NoSuchElementException
from unittestzero import Assert
@@ -29,3 +30,13 @@ def is_element_visible(self, locator):
return self.selenium.find_element(*locator).is_displayed()
except:
return False
+
+ def is_element_present(self, *locator):
+ self.selenium.implicitly_wait(0)
+ try:
+ self.selenium.find_element(*locator)
+ return True
+ except NoSuchElementException:
+ return False
+ finally:
+ self.selenium.implicitly_wait(self.testsetup.default_implicit_wait)
View
@@ -0,0 +1,25 @@
+#!/usr/bin/env python
+
+# This Source Code Form is subject to the terms of the Mozilla Public
+# License, v. 2.0. If a copy of the MPL was not distributed with this
+# file, You can obtain one at http://mozilla.org/MPL/2.0/.
+
+from selenium.webdriver.common.by import By
+
+from base import BasePage
+from page import Page
+
+
+class SearchResultsPage(BasePage):
+
+ _page_title = 'Search - MozillaWiki'
+
+ _search_results_area_locator = (By.CSS_SELECTOR, '.searchresults')
+ _search_button_locator = (By.CSS_SELECTOR, '#quick-search-btn')
+
+ def click_search_button(self):
+ self.selenium.find_element(*self._search_button_locator).click()
+
+ @property
+ def is_search_results_area_present(self):
+ return self.is_element_present(*self._search_results_area_locator)
@@ -0,0 +1,25 @@
+#!/usr/bin/env python
+
+# This Source Code Form is subject to the terms of the Mozilla Public
+# License, v. 2.0. If a copy of the MPL was not distributed with this
+# file, You can obtain one at http://mozilla.org/MPL/2.0/.
+
+import pytest
+from unittestzero import Assert
+
+from pages.home import HomePage
+from pages.search_results import SearchResultsPage
+from pages.log_in_or_create_account import LogInOrCreateAccountPage
+
+
+class TestSearchPage:
+
+ @pytest.mark.nondestructive
+ def test_no_results_returned_from_blank_search(self, mozwebqa):
+ home_pg = HomePage(mozwebqa)
+ home_pg.go_to_home_page()
+
+ search_results_pg = SearchResultsPage(mozwebqa)
+ search_results_pg.click_search_button()
+ Assert.true(search_results_pg.is_the_current_page)
+ Assert.false(search_results_pg.is_search_results_area_present,"Search Results area is present.")

0 comments on commit bc61758

Please sign in to comment.