Skip to content
This repository has been archived by the owner on Aug 20, 2018. It is now read-only.

Commit

Permalink
Merge pull request mozilla#152 from stupchiy/github-151
Browse files Browse the repository at this point in the history
github issue 151 - update test_search.py
  • Loading branch information
bobsilverberg committed Nov 18, 2013
2 parents 1d6c6e2 + 9c01489 commit c90f81e
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 25 deletions.
6 changes: 3 additions & 3 deletions pages/desktop/feedback.py
Expand Up @@ -16,12 +16,12 @@ class FeedbackPage(BasePage):
_page_title = 'Welcome :: Firefox Input'

_warning_heading_locator = (By.CSS_SELECTOR, '#message-warning h3')
_search_box = (By.ID, 'id_q')
_search_box = (By.NAME, 'q')
_chart_locator = (By.ID, 'feedback-chart')
_total_message_count_locator = (By.CSS_SELECTOR, '#big-count p')
_total_message_count_heading_locator = (By.CSS_SELECTOR, '#big-count h3')
_messages_column_heading_locator = (By.CSS_SELECTOR, '#messages h2')
_messages_locator = (By.CSS_SELECTOR, '#messages.block ul li.message')
_messages_locator = (By.CSS_SELECTOR, '.opinion')

def go_to_feedback_page(self):
self.selenium.get(self.base_url + '/')
Expand Down Expand Up @@ -84,7 +84,7 @@ def message_column_heading(self):

@property
def total_message_count(self):
return int(self.selenium.find_element(*self._total_message_count_locator).text.replace(',',''))
return int(self.selenium.find_element(*self._total_message_count_locator).text.replace(',', ''))

@property
def total_message_count_heading(self):
Expand Down
34 changes: 18 additions & 16 deletions pages/desktop/regions/product_filter.py
Expand Up @@ -14,41 +14,43 @@ class ProductFilter(Page):

class ComboFilter(Page):

_product_dropdown_locator = (By.ID, 'product')
_version_dropdown_locator = (By.ID, 'version')
_product_checkbox_locator = (By.CSS_SELECTOR, ".bars[name='product'] input")
_version_checkbox_locator = (By.CSS_SELECTOR, ".bars[name='version'] input")

@property
def products(self):
"""Returns a list of available products."""
select = Select(self.selenium.find_element(*self._product_dropdown_locator))
return [option.get_attribute('value') for option in select.options]
select = self.selenium.find_elements(*self._product_checkbox_locator)
return [element.get_attribute('name') for element in select]

@property
def selected_product(self):
"""Returns the currently selected product."""
return Select(self.selenium.find_element(*self._product_dropdown_locator)).first_selected_option.get_attribute('value')
return self.selenium.find_element(*self._product_checkbox_locator).get_attribute('value')

def select_product(self, product):
"""Selects a product."""
if not product == self.selected_product:
Select(self.selenium.find_element(*self._product_dropdown_locator)).select_by_value(product)
product = product.lower().replace(' ', '-')
select = self.selenium.find_element(self._product_checkbox_locator[0],
self._product_checkbox_locator[1] + "[name='%s']" % product)
if not select.is_selected():
select.click()

@property
def versions(self):
"""Returns a list of available versions."""
select = Select(self.selenium.find_element(*self._version_dropdown_locator))
return [option.get_attribute('value') for option in select.options]
select = self.selenium.find_elements(*self._version_checkbox_locator)
return [element.get_attribute('value') for element in select]

@property
def selected_version(self):
"""Returns the currently selected product version."""
return Select(self.selenium.find_element(*self._version_dropdown_locator)).first_selected_option.get_attribute('value')
return self.selenium.find_element(self._version_checkbox_locator[0],
self._version_checkbox_locator[1]).get_attribute('value')

def select_version(self, version):
"""Selects a product version."""
select = Select(self.selenium.find_element(*self._version_dropdown_locator))

if type(version) == int:
select.select_by_index(version)
else:
select.select_by_value(version)
select = self.selenium.find_element(self._version_checkbox_locator[0],
self._version_checkbox_locator[1] + "[value ='%s']" % version)
if not select.is_selected():
select.click()
7 changes: 1 addition & 6 deletions tests/desktop/test_search.py
Expand Up @@ -27,12 +27,7 @@ def test_that_we_can_search_feedback_with_unicode(self, mozwebqa):
feedback_pg = FeedbackPage(mozwebqa)

feedback_pg.go_to_feedback_page()
# Select the Firefox version that is 1 less than the newest to ensure the unicode
# search returns at least 1 result.
feedback_pg.product_filter.select_product('firefox')
feedback_pg.product_filter.select_version('--')

feedback_pg.search_for(u"rapidit\xe9")
feedback_pg.search_for(u"p\xe1gina")
Assert.greater(len(feedback_pg.messages), 0)

@pytest.mark.nondestructive
Expand Down

0 comments on commit c90f81e

Please sign in to comment.