Skip to content

Commit

Permalink
Merge pull request #3834 from alexgibson/functional-test-firefox-all
Browse files Browse the repository at this point in the history
Add functional tests for firefox/all page
  • Loading branch information
alexgibson committed Feb 18, 2016
2 parents 4a2ef1a + 29b0391 commit 6eb2aa3
Show file tree
Hide file tree
Showing 2 changed files with 69 additions and 0 deletions.
27 changes: 27 additions & 0 deletions tests/functional/firefox/test_all.py
@@ -0,0 +1,27 @@
# 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 pages.firefox.all import FirefoxAllPage


@pytest.mark.smoke
@pytest.mark.nondestructive
def test_search_language(base_url, selenium):
page = FirefoxAllPage(base_url, selenium).open()
language = 'english'
page.search_for(language)
for build in page.displayed_builds:
assert language in build.language.lower()


@pytest.mark.nondestructive
def test_newsletter_default_values(base_url, selenium):
page = FirefoxAllPage(base_url, selenium).open()
page.newsletter.expand_form()
assert '' == page.newsletter.email
assert 'United States' == page.newsletter.country
assert not page.newsletter.privacy_policy_accepted
assert page.newsletter.is_privacy_policy_link_displayed
42 changes: 42 additions & 0 deletions tests/pages/firefox/all.py
@@ -0,0 +1,42 @@
# 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 pages.firefox.base import FirefoxBasePage, FirefoxBasePageRegion


class FirefoxAllPage(FirefoxBasePage):

_url = '{base_url}/{locale}/firefox/all'

_search_input_locator = (By.ID, 'language-search-q')
_submit_button_locator = (By.CSS_SELECTOR, '#language-search button')
_build_rows_locator = (By.CSS_SELECTOR, '#builds table > tbody > tr')

@property
def _builds(self):
return [Build(self, root=el) for el in
self.find_elements(self._build_rows_locator)]

@property
def displayed_builds(self):
return [b for b in self._builds if b.is_displayed]

def search_for(self, value):
self.find_element(self._search_input_locator).send_keys(value)
self.find_element(self._submit_button_locator).click()
expected_builds = [b for b in self._builds if value in b.language.lower()]
self.wait.until(lambda s: len(expected_builds) == len(self.displayed_builds))


class Build(FirefoxBasePageRegion):

@property
def language(self):
return self._root.get_attribute('data-search')

@property
def is_displayed(self):
return self._root.is_displayed()

0 comments on commit 6eb2aa3

Please sign in to comment.