Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Merge pull request #140 from retornam/locales

Adding tests for /firefox/all page
  • Loading branch information...
commit 83a2ec441d7d42fae769b01415b88884043ee574 2 parents daf88fe + 6a50e60
@bobsilverberg bobsilverberg authored
Showing with 68 additions and 0 deletions.
  1. +35 −0 pages/desktop/localization.py
  2. +33 −0 tests/test_localization.py
View
35 pages/desktop/localization.py
@@ -0,0 +1,35 @@
+from selenium.webdriver.common.by import By
+from pages.desktop.base import Base
+
+
+class Localization(Base):
+ _released_languages_locator = (By.CSS_SELECTOR, '#languages table.downloads')
+ _beta_languages_locator = (By.CSS_SELECTOR, '#beta_versions table.downloads')
+ _language_locator = (By.CSS_SELECTOR, 'tbody tr')
+ _windows_download_link = (By.CSS_SELECTOR, 'td a.download-windows')
+ _osx_download_link = (By.CSS_SELECTOR, 'td a.download-osx')
+ _linux_download_link = (By.CSS_SELECTOR, 'td a.download-linux')
+
+ def go_to_page(self):
+ self.open('/firefox/all.html')
+
+ def get_language_properties(self, table_locator):
+ languages = []
+ table = self.selenium.find_element(*table_locator)
+ for language in table.find_elements(*self._language_locator):
+ language_properties = {} #dictionary to hold language properties
+ language_properties['id'] = language.get_attribute('id')
+ language_properties['windows_url'] = language.find_element(*self._windows_download_link).get_attribute('href')
+ language_properties['osx_url'] = language.find_element(*self._osx_download_link).get_attribute('href')
+ language_properties['linux_url'] = language.find_element(*self._linux_download_link).get_attribute('href')
+ languages.append(language_properties)
+ return languages
+
+ @property
+ def get_released_languages(self):
+ return self.get_language_properties(self._released_languages_locator)
+
+ @property
+ def get_beta_languages(self):
+ return self.get_language_properties(self._beta_languages_locator)
+
View
33 tests/test_localization.py
@@ -0,0 +1,33 @@
+#!/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 pages.desktop.localization import Localization
+from unittestzero import Assert
+import requests
+import pytest
+
+
+class TestLocalizations:
+
+ @pytest.mark.nondestructive
+ def test_that_download_links_return_302(self, mozwebqa):
+ '''
+ Check that download links return a status 302.
+ '''
+ localizations_page = Localization(mozwebqa)
+ localizations_page.go_to_page()
+ languages = localizations_page.get_released_languages + localizations_page.get_beta_languages
+ bad_links = []
+ for language in languages:
+ for (url, os_name) in ((language['windows_url'], "Windows"),
+ (language['osx_url'], "OSX"),
+ (language['linux_url'], "Linux")):
+ response = requests.head(url, allow_redirects=False)
+ status = response.status_code
+ if status != 302:
+ bad_links.append("Lang '%s' %s link: status %s"
+ % (language['id'], os_name, status))
+ Assert.equal(0, len(bad_links),
+ 'Expected status code 302. ' + ", ".join(bad_links))
Please sign in to comment.
Something went wrong with that request. Please try again.