Added test for searching on a QMO post tag #28

Merged
merged 4 commits into from Oct 30, 2012
View
2 pages/base.py
@@ -11,7 +11,7 @@
class BasePage(Page):
- _page_title_locator = (By.CSS_SELECTOR, "h1.page-title")
+ _page_title_locator = (By.CSS_SELECTOR, "h1.section-title")
@property
def is_logged_in(self):
View
9 pages/community.py
@@ -4,13 +4,22 @@
# 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
class CommunityPage(BasePage):
_page_title = u'Community | QMO \u2013 quality.mozilla.org'
+ _tag_locator = (By.CSS_SELECTOR, '#tag_cloud-3 a')
def go_to_community_page(self):
self.selenium.get(self.testsetup.base_url + '/community')
self.is_the_current_page
+
+ @property
@bobsilverberg
bobsilverberg Sep 18, 2012

I don't think this should be marked as a property, as it performs an action. I could be wrong about that so maybe someone else wants to comment on this.

@rbillings
rbillings Sep 18, 2012

Good call- I saw that earlier and meant to remove it but forgot!

+ def click_first_tag_link(self):
+ self.selenium.find_element(*self._tag_locator).click()
+ from pages.tag_results import TagResultsPage
+ return TagResultsPage(self.testsetup)
View
16 pages/tag_results.py
@@ -0,0 +1,16 @@
+#!/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
+
+
+class TagResultsPage(BasePage):
+
+ @property
+ def results(self):
+ return self.selenium.find_elements(By.CSS_SELECTOR, "#content-main > article")
@teodosia
teodosia Oct 16, 2012

We should assign a variable to the locator at the beginning of the class:
_results_locator = (By.CSS_SELECTOR, '#content-main > article')
and use the variable here:
return self.selenium.find_elements(*self._results_locator)

View
24 tests/test_tag_search.py
@@ -0,0 +1,24 @@
+#!/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.community import CommunityPage
+from pages.tag_results import TagResultsPage
@teodosia
teodosia Oct 16, 2012

We don't use this import in the test, so we can remove it.

+
+
+class TestTagSearchPage:
+
+ @pytest.mark.nondestructive
+ def test_search_tag(self, mozwebqa):
+ community_page = CommunityPage(mozwebqa)
+ community_page.go_to_community_page()
+
+ tag_results_page = community_page.click_first_tag_link
+
+ Assert.contains('Posts and pages tagged', tag_results_page.page_title)
+ Assert.greater(len(tag_results_page.results), 0)