Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Merge pull request #52 from bebef1987/test_sort

test for bug 738469
  • Loading branch information...
commit 540a18eb5a7ab6f94af4ee47011796e82160cd4e 2 parents a26a149 + ba5c963
Zac zacc authored
29 pages/regions/paginator.py
View
@@ -0,0 +1,29 @@
+#!/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 page import Page
+from selenium.webdriver.support.ui import WebDriverWait
+
+
+class Paginator(Page):
+
+ _next_locator = (By.CSS_SELECTOR, 'ul.UI_Pagination > li.next > a')
+ _results_loading_locator = (By.CSS_SELECTOR, '#SearchResults.loading')
+
+ @property
+ def is_next_visible(self):
+ return self.is_element_visible(*self._next_locator)
+
+ def next(self):
+ self.selenium.find_element(*self._next_locator).click()
+ self._wait_for_search_ajax()
+ from pages.search_page import SearchPage
+ return SearchPage(self.testsetup)
+
+ def _wait_for_search_ajax(self):
+ WebDriverWait(self.selenium, 10).until(lambda s: not self.is_element_present(*self._results_loading_locator))
38 pages/search_page.py
View
@@ -9,6 +9,7 @@
from selenium.webdriver.common.action_chains import ActionChains
from selenium.webdriver.common.by import By
from selenium.webdriver.support.ui import WebDriverWait
+from selenium.webdriver.support.select import Select
class SearchPage(FlightDeckBasePage):
@@ -29,6 +30,10 @@ class SearchPage(FlightDeckBasePage):
_results_message_locator = (By.CSS_SELECTOR, "#SearchResults > p")
_results_loading_locator = (By.CSS_SELECTOR, '#SearchResults.loading')
+ _see_all_results_addon_locator = (By.CSS_SELECTOR, "#SearchResults > p.see-more > a[href*='type=a']")
+
+ _sort_filter_locator = (By.ID, 'SortSelect')
+
def addon(self, lookup):
return self.Addon(self.testsetup, lookup)
@@ -38,6 +43,16 @@ def library(self, lookup):
def _item_locator_by_name(self, name):
return (By.LINK_TEXT, name)
+ def sort_addons_by(self, sort_method):
+ sort_selector = Select(self.selenium.find_element(*self._sort_filter_locator))
+ sort_selector.select_by_visible_text(sort_method)
+ self._wait_for_search_ajax()
+
+ @property
+ def current_sort_method(self):
+ sort_selector = Select(self.selenium.find_element(*self._sort_filter_locator))
+ return sort_selector.first_selected_option.text
+
def type_search_term(self, text):
self.selenium.find_element(*self._search_field_locator).send_keys(text)
@@ -48,6 +63,10 @@ def click_search(self):
self.selenium.find_element(*self._search_button_locator).click()
self._wait_for_search_ajax()
+ def click_see_all_addons(self):
+ self.selenium.find_element(*self._see_all_results_addon_locator).click()
+ self._wait_for_search_ajax()
+
def click_filter_addons_link(self):
self.selenium.find_element(*self._filter_by_addons_locator).click()
self._wait_for_search_ajax()
@@ -113,6 +132,11 @@ def move_activity_slider(self, notches):
def _wait_for_search_ajax(self):
WebDriverWait(self.selenium, 10).until(lambda s: not self.is_element_present(*self._results_loading_locator))
+ @property
+ def paginator(self):
+ from pages.regions.paginator import Paginator
+ return Paginator(self.testsetup)
+
class SearchResultsRegion(Page):
def __init__(self, testsetup, lookup):
@@ -124,6 +148,15 @@ def __init__(self, testsetup, lookup):
_name_locator = (By.CSS_SELECTOR, "h3 > a")
_author_link_locator = (By.CSS_SELECTOR, "ul.search_meta li:nth-child(1) > a")
+ _activity_locator = (By.CSS_SELECTOR, 'ul.search_meta > li.activity')
+
+ _activity_rating = {'inactive': 0,
+ 'stale': 1,
+ 'low': 2,
+ 'moderate': 3,
+ 'high': 4,
+ 'rockin\'': 5
+ }
@property
def root_element(self):
@@ -150,6 +183,11 @@ def click(self):
from pages.editor_page import LibraryEditorPage
return LibraryEditorPage(self.testsetup)
+ @property
+ def activity_rating(self):
+ activity = self.root_element.find_element(*self._activity_locator).text.strip()
+ return self._activity_rating[activity]
+
def click_author(self):
self.root_element.find_element(*self._author_link_locator).click()
24 tests/test_search.py
View
@@ -262,3 +262,27 @@ def test_activity_slider_filters_results(self, mozwebqa):
Assert.true(initial_addon_count > searchpage_obj.addons_count_label)
Assert.true(initial_library_count > searchpage_obj.library_count_label)
+
+ @pytest.mark.nondestructive
+ @pytest.mark.xfail(reason="Bug 738469 - Default sort order says 'Activity', but doesn't actually match 'Activity' search-sort order/results")
+ def test_default_search_order_is_by_activity(self, mozwebqa):
+ homepage_obj = HomePage(mozwebqa)
+
+ homepage_obj.go_to_home_page()
+ searchpage_obj = homepage_obj.header.click_search()
+
+ searchpage_obj.type_search_term('addon')
+ searchpage_obj.click_search()
+
+ searchpage_obj.click_see_all_addons()
+
+ Assert.equal('Activity', searchpage_obj.current_sort_method)
+
+ addons_activity_property_list = []
+ while searchpage_obj.paginator.is_next_visible:
+ for lookup in range(1, searchpage_obj.addons_element_count() + 1):
+ addons_activity_property_list.append(
+ searchpage_obj.addon(lookup).activity_rating)
+
+ Assert.is_sorted_descending(addons_activity_property_list, 'The addons are not sorted by Activity')
+ searchpage_obj.paginator.next()
Please sign in to comment.
Something went wrong with that request. Please try again.