From 621e96ea0a95ea4b1aae1c682c9a6502c266dc4b Mon Sep 17 00:00:00 2001 From: Stephanie Hobson Date: Wed, 17 Jul 2024 10:17:10 -0700 Subject: [PATCH] tests and fixes --- .../templates/firefox/all/product.html | 4 +- bedrock/firefox/views.py | 1 + tests/functional/firefox/test_all.py | 334 +++++++++++++++--- tests/pages/firefox/all.py | 110 +++--- 4 files changed, 339 insertions(+), 110 deletions(-) diff --git a/bedrock/firefox/templates/firefox/all/product.html b/bedrock/firefox/templates/firefox/all/product.html index 6924e4832e7..66c7fddf039 100644 --- a/bedrock/firefox/templates/firefox/all/product.html +++ b/bedrock/firefox/templates/firefox/all/product.html @@ -24,7 +24,7 @@

{% if not product %}

Desktop

-
    +
    • Firefox (Recommended)
    • {% for p in products %} {% if p.slug.startswith('desktop') and not p.slug.endswith('release') %} @@ -35,7 +35,7 @@

      Mobile

      -
        +
        • Firefox (Recommended)
        • {% for p in products %} {% if p.slug.startswith('android') and not p.slug.endswith('release')%} diff --git a/bedrock/firefox/views.py b/bedrock/firefox/views.py index 93fe36878e5..af8a22ee110 100644 --- a/bedrock/firefox/views.py +++ b/bedrock/firefox/views.py @@ -252,6 +252,7 @@ class MobileRelease: "osx": "macOS", "linux64": "Linux 64-bit", "linux": "Linux 32-bit", + "linux64-aarch64": "Linux ARM64/AArch64", } product = product_slug and product_map.get(product_slug) or None diff --git a/tests/functional/firefox/test_all.py b/tests/functional/firefox/test_all.py index 81c9622dcac..e48a09d6e73 100644 --- a/tests/functional/firefox/test_all.py +++ b/tests/functional/firefox/test_all.py @@ -6,89 +6,335 @@ from pages.firefox.all import FirefoxAllPage +# product lists + + +@pytest.mark.smoke +@pytest.mark.nondestructive +def test_desktop_product_list(base_url, selenium): + page = FirefoxAllPage(selenium, base_url, slug="").open() + list_length = page.desktop_product_list_length + assert list_length == 5 + + +@pytest.mark.smoke +@pytest.mark.nondestructive +def test_mobile_product_list(base_url, selenium): + page = FirefoxAllPage(selenium, base_url, slug="").open() + list_length = page.mobile_product_list_length + assert list_length == 4 + + +RELEASE_PLATFORM_COUNT = [("desktop-release", 9), ("desktop-esr", 8), ("desktop-beta", 9), ("desktop-developer", 8), ("desktop-nightly", 8)] + +# platform lists + + +@pytest.mark.smoke +@pytest.mark.nondestructive +@pytest.mark.parametrize("slug, count", RELEASE_PLATFORM_COUNT) +def test_desktop_platform_list(slug, count, base_url, selenium): + slug = f"{slug}/" + page = FirefoxAllPage(selenium, base_url, slug=slug).open() + list_length = page.platform_list_length + assert list_length == count + + +WIN_OS_LANG_PAIRS = [ + # all platforms in english + ("win64", "en-US"), + ("win64-msi", "en-US"), + ("win64-aarch64", "en-US"), + ("win", "en-US"), + ("win-msi", "en-US"), + # all platforms in some other languages + ("win64", "de"), + ("win64-msi", "fr"), + ("win64-aarch64", "hi-IN"), + ("win", "ja"), + ("win-msi", "es-ES"), +] + +MAC_OS_LANG_PAIRS = [ + # all platforms in english + ("osx", "en-US"), + # all platforms in some other languages + ("osx", "de"), + ("osx", "fr"), + ("osx", "hi-IN"), +] + +LINUX_OS_LANG_PAIRS = [ + # all platforms in english + ("linux64", "en-US"), + ("linux", "en-US"), + # all platforms in some other languages + ("linux64", "de"), + ("linux", "fr"), + ("linux64", "hi-IN"), + ("linux", "ja"), +] + +LINUX_OS_LANG_PAIRS_NIGHTLY = [ + # all platforms in english + ("linux64", "en-US"), + ("linux", "en-US"), + ("linux64-aarch64", "en-US"), + # all platforms in some other languages + ("linux64", "de"), + ("linux", "fr"), + ("linux64", "hi-IN"), + ("linux", "ja"), + ("linux64-aarch64", "es-ES"), + ("linux64-aarch64", "pt-BR"), +] + +# desktop release + + +@pytest.mark.smoke +@pytest.mark.nondestructive +@pytest.mark.parametrize("os, lang", WIN_OS_LANG_PAIRS) +def test_firefox_win_release(os, lang, base_url, selenium): + slug = f"desktop-release/{os}/{lang}/" + page = FirefoxAllPage(selenium, base_url, slug=slug).open() + assert page.is_desktop_download_button_displayed + assert "product=firefox-latest-ssl" and f"os={os}" and f"lang={lang}" in page.desktop_download_link + + +@pytest.mark.smoke +@pytest.mark.nondestructive +def test_firefox_microsoft_store_release(base_url, selenium): + slug = "desktop-release/win-store/" + page = FirefoxAllPage(selenium, base_url, slug=slug).open() + assert page.is_ms_store_download_button_displayed + assert "https://apps.microsoft.com/detail/9nzvdkpmr9rd" in page.microsoft_store_link + + +@pytest.mark.smoke +@pytest.mark.nondestructive +@pytest.mark.parametrize("os, lang", MAC_OS_LANG_PAIRS) +def test_firefox_macos_release(os, lang, base_url, selenium): + slug = f"desktop-release/{os}/{lang}/" + page = FirefoxAllPage(selenium, base_url, slug=slug).open() + assert page.is_desktop_download_button_displayed + assert "product=firefox-latest-ssl" and "os={os}" and "lang=en-US" in page.desktop_download_link + + +@pytest.mark.smoke +@pytest.mark.nondestructive +@pytest.mark.parametrize("os, lang", LINUX_OS_LANG_PAIRS) +def test_firefox_linux_release(os, lang, base_url, selenium): + slug = f"desktop-release/{os}/{lang}/" + page = FirefoxAllPage(selenium, base_url, slug=slug).open() + assert page.is_desktop_download_button_displayed + assert "product=firefox-latest-ssl" and "os={os}" and "lang=en-US" in page.desktop_download_link + assert page.is_linux_atp_link_displayed + assert "https://support.mozilla.org/kb/install-firefox-linux" in page.linux_atp_link + + +# desktop beta - check by platform + + +@pytest.mark.smoke +@pytest.mark.nondestructive +@pytest.mark.parametrize("os, lang", WIN_OS_LANG_PAIRS) +def test_firefox_win_beta(os, lang, base_url, selenium): + slug = f"desktop-beta/{os}/{lang}/" + page = FirefoxAllPage(selenium, base_url, slug=slug).open() + assert page.is_desktop_download_button_displayed + assert "product=firefox-beta-latest" and f"os={os}" and f"lang={lang}" in page.desktop_download_link + + +@pytest.mark.smoke +@pytest.mark.nondestructive +def test_firefox_microsoft_store_beta(base_url, selenium): + slug = "desktop-beta/win-store/" + page = FirefoxAllPage(selenium, base_url, slug=slug).open() + assert page.is_ms_store_download_button_displayed + assert "https://apps.microsoft.com/detail/9nzw26frndln" in page.microsoft_store_link + @pytest.mark.smoke @pytest.mark.nondestructive -def test_firefox_release(base_url, selenium): - page = FirefoxAllPage(selenium, base_url).open() - product = page.select_product("Firefox") - product.select_platform("Windows 64-bit") - product.select_language("English (US)") +@pytest.mark.parametrize("os, lang", MAC_OS_LANG_PAIRS) +def test_firefox_macos_beta(os, lang, base_url, selenium): + slug = f"desktop-beta/{os}/{lang}/" + page = FirefoxAllPage(selenium, base_url, slug=slug).open() assert page.is_desktop_download_button_displayed - assert "product=firefox-latest-ssl" and "os=win64" and "lang=en-US" in page.desktop_download_link + assert "product=firefox-beta-latest" and f"os={os}" and f"lang={lang}" in page.desktop_download_link @pytest.mark.smoke @pytest.mark.nondestructive -def test_firefox_beta(base_url, selenium): - page = FirefoxAllPage(selenium, base_url).open() - product = page.select_product("Firefox Beta") - product.select_platform("macOS") - product.select_language("German — Deutsch") +@pytest.mark.parametrize("os, lang", LINUX_OS_LANG_PAIRS) +def test_firefox_linux_beta(os, lang, base_url, selenium): + slug = f"desktop-beta/{os}/{lang}/" + page = FirefoxAllPage(selenium, base_url, slug=slug).open() assert page.is_desktop_download_button_displayed - assert "product=firefox-beta-latest-ssl" and "os=osx" and "lang=de" in page.desktop_download_link + assert "product=firefox-beta-latest" and f"os={os}" and f"lang={lang}" in page.desktop_download_link + assert page.is_linux_atp_link_displayed + assert "https://support.mozilla.org/kb/install-firefox-linux" in page.linux_atp_link + + +# desktop developer - check by platform @pytest.mark.smoke @pytest.mark.nondestructive -def test_firefox_developer(base_url, selenium): - page = FirefoxAllPage(selenium, base_url).open() - product = page.select_product("Firefox Developer Edition") - product.select_platform("Linux 64-bit") - product.select_language("English (US)") +@pytest.mark.parametrize("os, lang", WIN_OS_LANG_PAIRS) +def test_firefox_win_developer(os, lang, base_url, selenium): + slug = f"desktop-developer/{os}/{lang}/" + page = FirefoxAllPage(selenium, base_url, slug=slug).open() assert page.is_desktop_download_button_displayed - assert "product=firefox-devedition-latest-ssl" and "os=linux64" and "lang=en-US" in page.desktop_download_link + assert "product=firefox-devedition-latest" and f"os={os}" and f"lang={lang}" in page.desktop_download_link @pytest.mark.smoke @pytest.mark.nondestructive -def test_firefox_nightly(base_url, selenium): - page = FirefoxAllPage(selenium, base_url).open() - product = page.select_product("Firefox Nightly") - product.select_platform("Windows 32-bit") - product.select_language("German — Deutsch") +@pytest.mark.parametrize("os, lang", MAC_OS_LANG_PAIRS) +def test_firefox_macos_developer(os, lang, base_url, selenium): + slug = f"desktop-developer/{os}/{lang}/" + page = FirefoxAllPage(selenium, base_url, slug=slug).open() assert page.is_desktop_download_button_displayed - assert "product=firefox-nightly-latest-ssl" and "os=win" and "lang=de" in page.desktop_download_link + assert "product=firefox-devedition-latest" and f"os={os}" and f"lang={lang}" in page.desktop_download_link @pytest.mark.smoke @pytest.mark.nondestructive -def test_firefox_esr(base_url, selenium): - page = FirefoxAllPage(selenium, base_url).open() - product = page.select_product("Firefox Extended Support Release") - product.select_platform("Linux 32-bit") - product.select_language("English (US)") +@pytest.mark.parametrize("os, lang", LINUX_OS_LANG_PAIRS) +def test_firefox_linux_developer(os, lang, base_url, selenium): + slug = f"desktop-developer/{os}/{lang}/" + page = FirefoxAllPage(selenium, base_url, slug=slug).open() assert page.is_desktop_download_button_displayed - assert "product=firefox-esr-latest-ssl" and "os=linux" and "lang=en-US" in page.desktop_download_link + assert "product=firefox-devedition-latest" and f"os={os}" and f"lang={lang}" in page.desktop_download_link + assert page.is_linux_atp_link_displayed + assert "https://support.mozilla.org/kb/install-firefox-linux" in page.linux_atp_link + + +# desktop nightly - check by platform @pytest.mark.smoke @pytest.mark.nondestructive -def test_firefox_android(base_url, selenium): - page = FirefoxAllPage(selenium, base_url).open() - page.select_product("Firefox Android") +@pytest.mark.parametrize("os, lang", WIN_OS_LANG_PAIRS) +def test_firefox_win_nightly(os, lang, base_url, selenium): + slug = f"desktop-nightly/{os}/{lang}/" + page = FirefoxAllPage(selenium, base_url, slug=slug).open() + assert page.is_desktop_download_button_displayed + assert "product=firefox-nightly-latest" and f"os={os}" and f"lang={lang}" in page.desktop_download_link + + +@pytest.mark.smoke +@pytest.mark.nondestructive +@pytest.mark.parametrize("os, lang", MAC_OS_LANG_PAIRS) +def test_firefox_macos_nightly(os, lang, base_url, selenium): + slug = f"desktop-nightly/{os}/{lang}/" + page = FirefoxAllPage(selenium, base_url, slug=slug).open() + assert page.is_desktop_download_button_displayed + assert "product=firefox-nightly-latest" and f"os={os}" and f"lang={lang}" in page.desktop_download_link + + +@pytest.mark.smoke +@pytest.mark.nondestructive +@pytest.mark.parametrize("os, lang", LINUX_OS_LANG_PAIRS_NIGHTLY) +def test_firefox_linux_nightly(os, lang, base_url, selenium): + slug = f"desktop-nightly/{os}/{lang}/" + page = FirefoxAllPage(selenium, base_url, slug=slug).open() + assert page.is_desktop_download_button_displayed + assert "product=firefox-nightly-latest" and f"os={os}" and f"lang={lang}" in page.desktop_download_link + assert page.is_linux_atp_link_displayed + assert "https://support.mozilla.org/kb/install-firefox-linux" in page.linux_atp_link + + +# desktop esr - check by platform + + +@pytest.mark.smoke +@pytest.mark.nondestructive +@pytest.mark.parametrize("os, lang", WIN_OS_LANG_PAIRS) +def test_firefox_win_esr(os, lang, base_url, selenium): + slug = f"desktop-esr/{os}/{lang}/" + page = FirefoxAllPage(selenium, base_url, slug=slug).open() + assert page.is_desktop_download_button_displayed + assert "product=firefox-esr-latest-ssl" and f"os={os}" and f"lang={lang}" in page.desktop_download_link + + +@pytest.mark.smoke +@pytest.mark.nondestructive +@pytest.mark.parametrize("os, lang", MAC_OS_LANG_PAIRS) +def test_firefox_macos_esr(os, lang, base_url, selenium): + slug = f"desktop-esr/{os}/{lang}/" + page = FirefoxAllPage(selenium, base_url, slug=slug).open() + assert page.is_desktop_download_button_displayed + assert "product=firefox-esr-latest-ssl" and f"os={os}" and f"lang={lang}" in page.desktop_download_link + + +@pytest.mark.smoke +@pytest.mark.nondestructive +@pytest.mark.parametrize("os, lang", LINUX_OS_LANG_PAIRS) +def test_firefox_linux_esr(os, lang, base_url, selenium): + slug = f"desktop-esr/{os}/{lang}/" + page = FirefoxAllPage(selenium, base_url, slug=slug).open() + assert page.is_desktop_download_button_displayed + assert "product=firefox-esr-latest-ssl" and f"os={os}" and f"lang={lang}" in page.desktop_download_link + assert page.is_linux_atp_link_displayed + assert "https://support.mozilla.org/kb/install-firefox-linux" in page.linux_atp_link + + +# mobile release - check by platform + + +@pytest.mark.smoke +@pytest.mark.nondestructive +def test_firefox_mobile_release(base_url, selenium): + slug = "mobile-release/" + page = FirefoxAllPage(selenium, base_url, slug=slug).open() assert page.is_android_download_button_displayed + assert page.is_ios_download_button_displayed @pytest.mark.smoke @pytest.mark.nondestructive -def test_firefox_android_beta(base_url, selenium): - page = FirefoxAllPage(selenium, base_url).open() - page.select_product("Firefox Android Beta") - assert page.is_android_beta_download_button_displayed +def test_firefox_android_release(base_url, selenium): + slug = "android-release/" + page = FirefoxAllPage(selenium, base_url, slug=slug).open() + assert page.is_android_download_button_displayed @pytest.mark.smoke @pytest.mark.nondestructive -def test_firefox_android_nightly(base_url, selenium): - page = FirefoxAllPage(selenium, base_url).open() - page.select_product("Firefox Android Nightly") - assert page.is_android_nightly_download_button_displayed +def test_firefox_ios_release(base_url, selenium): + slug = "ios-release/" + page = FirefoxAllPage(selenium, base_url, slug=slug).open() + assert page.is_ios_download_button_displayed + + +# mobile beta - check by platform @pytest.mark.smoke @pytest.mark.nondestructive -def test_firefox_ios(base_url, selenium): - page = FirefoxAllPage(selenium, base_url).open() - page.select_product("Firefox iOS") +def test_firefox_android_beta(base_url, selenium): + slug = "android-beta/" + page = FirefoxAllPage(selenium, base_url, slug=slug).open() + assert page.is_android_download_button_displayed + + +@pytest.mark.smoke +@pytest.mark.nondestructive +def test_firefox_ios_beta(base_url, selenium): + slug = "ios-beta/" + page = FirefoxAllPage(selenium, base_url, slug=slug).open() assert page.is_ios_download_button_displayed + + +# mobile nightly - check by platform + + +@pytest.mark.smoke +@pytest.mark.nondestructive +def test_firefox_android_nightly(base_url, selenium): + slug = "android-nightly/" + page = FirefoxAllPage(selenium, base_url, slug=slug).open() + assert page.is_android_download_button_displayed diff --git a/tests/pages/firefox/all.py b/tests/pages/firefox/all.py index 52a6d1e66df..61f667bb9a1 100644 --- a/tests/pages/firefox/all.py +++ b/tests/pages/firefox/all.py @@ -3,102 +3,84 @@ # file, You can obtain one at https://mozilla.org/MPL/2.0/. from selenium.webdriver.common.by import By -from selenium.webdriver.support.select import Select -from pages.base import BasePage, BaseRegion +from pages.base import BasePage class FirefoxAllPage(BasePage): - _URL_TEMPLATE = "/{locale}/firefox/all/" + _URL_TEMPLATE = "/{locale}/firefox/all/{slug}" - _product_locator = (By.ID, "select-product") - _product_options_locator = (By.CLASS_NAME, "c-selection-options") + _desktop_list_items_locator = (By.CSS_SELECTOR, ".qa-desktop-list li") + _mobile_list_items_locator = (By.CSS_SELECTOR, ".qa-mobile-list li") + _platform_list_items_locator = (By.CSS_SELECTOR, ".c-platform-list li") _desktop_download_button_locator = (By.ID, "download-button-primary") - _android_download_button_locator = (By.ID, "download-android-primary") - _android_beta_download_button_locator = (By.ID, "download-android-beta-primary") - _android_nightly_download_button_locator = (By.ID, "download-android-nightly-primary") - _ios_download_button_locator = (By.ID, "download-ios-primary") - _download_info_platform_locator = (By.ID, "download-info-platform") - _download_info_language_locator = (By.ID, "download-info-language") + _android_download_button_locator = (By.ID, "playStoreLink") + _ios_download_button_locator = (By.ID, "appStoreLink") + _ms_store_download_button_locator = (By.ID, "msStoreLink") + _linux_atp_link_locator = (By.CSS_SELECTOR, ".c-linux-debian a") - @property - def _options(self): - return [ProductOptions(self, root=el) for el in self.find_elements(*self._product_options_locator)] + # product @property - def product(self): - select = self.find_element(*self._product_locator) - return select.get_attribute("value") + def desktop_product_list_length(self): + list = self.find_elements(*self._desktop_list_items_locator) + return len(list) @property - def platform_info(self): - platform = self.find_element(*self._download_info_platform_locator) - return platform.text + def mobile_product_list_length(self): + list = self.find_elements(*self._mobile_list_items_locator) + return len(list) - @property - def language_info(self): - language = self.find_element(*self._download_info_language_locator) - return language.text + # platform @property - def desktop_download_link(self): - link = self.find_element(*self._desktop_download_button_locator) - return link.get_attribute("href") + def platform_list_length(self): + list = self.find_elements(*self._platform_list_items_locator) + return len(list) + + # language + + # downloads @property def is_desktop_download_button_displayed(self): return self.is_element_displayed(*self._desktop_download_button_locator) - def select_product(self, value): - el = self.find_element(*self._product_locator) - Select(el).select_by_visible_text(value) - selected = self.product - option = [o for o in self._options if selected == o.root.get_attribute("data-product")] - assert len(option) == 1 - self.wait.until(lambda s: option[0].is_displayed) - return option[0] + @property + def desktop_download_link(self): + link = self.find_element(*self._desktop_download_button_locator) + return link.get_attribute("href") @property def is_android_download_button_displayed(self): return self.is_element_displayed(*self._android_download_button_locator) - @property - def is_android_beta_download_button_displayed(self): - return self.is_element_displayed(*self._android_beta_download_button_locator) - - @property - def is_android_nightly_download_button_displayed(self): - return self.is_element_displayed(*self._android_nightly_download_button_locator) - @property def is_ios_download_button_displayed(self): return self.is_element_displayed(*self._ios_download_button_locator) + @property + def microsoft_store_link(self): + link = self.find_element(*self._ms_store_download_button_locator) + return link.get_attribute("href") -class ProductOptions(BaseRegion): - _platform_locator = (By.CSS_SELECTOR, ".c-selection-platform select") - _language_locator = (By.CSS_SELECTOR, ".c-selection-language select") + @property + def is_ms_store_download_button_displayed(self): + return self.is_element_displayed(*self._ms_store_download_button_locator) @property - def is_displayed(self): - return self.root.is_displayed() + def linux_atp_link(self): + link = self.find_element(*self._linux_atp_link_locator) + return link.get_attribute("href") @property - def platform(self): - select = self.find_element(*self._platform_locator) - return select.get_attribute("value") + def is_linux_atp_link_displayed(self): + return self.is_element_displayed(*self._linux_atp_link_locator) - def select_platform(self, value): - el = self.find_element(*self._platform_locator) - Select(el).select_by_visible_text(value) - self.wait.until(lambda s: self.page.platform_info == value) + # check the back buttons are working - @property - def language(self): - select = self.find_element(*self._language_locator) - return select.get_attribute("value") - - def select_language(self, value): - el = self.find_element(*self._language_locator) - Select(el).select_by_visible_text(value) - self.wait.until(lambda s: self.page.language_info == value) + # check there are the right number of links in each list on the home and platform pages + + # step through the stages to download? + + # open the help modals?