Skip to content

Commit

Permalink
Fix navigation functional tests
Browse files Browse the repository at this point in the history
  • Loading branch information
alexgibson committed Sep 16, 2024
1 parent e642573 commit 8840a2a
Show file tree
Hide file tree
Showing 6 changed files with 68 additions and 94 deletions.
7 changes: 0 additions & 7 deletions tests/functional/firefox/family/test_family.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,6 @@
from pages.firefox.family.landing import FamilyPage


@pytest.mark.skip_if_firefox(reason="Nav download button is displayed only to non-Firefox users")
@pytest.mark.nondestructive
def test_firefox_nav_download_button_is_displayed(base_url, selenium):
page = FamilyPage(selenium, base_url).open()
assert page.is_firefox_nav_download_button_displayed


@pytest.mark.skip_if_not_firefox(reason="Nav CTA is only hidden for Firefox users")
@pytest.mark.nondestructive
def test_firefox_nav_cta_is_displayed(base_url, selenium):
Expand Down
47 changes: 25 additions & 22 deletions tests/functional/test_navigation.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,50 +10,53 @@
@pytest.mark.smoke
@pytest.mark.nondestructive
def test_navigation(base_url, selenium):
page = HomePage(selenium, base_url).open()
firefox_desktop_page = page.navigation.open_firefox_desktop_page()
assert firefox_desktop_page.seed_url in selenium.current_url
page = HomePage(selenium, base_url, locale="de").open()
page.navigation.open_firefox_menu()
assert page.navigation.is_firefox_menu_displayed

page.open()
developer_edition_page = page.navigation.open_developer_edition_page()
assert developer_edition_page.seed_url in selenium.current_url
page.navigation.open_products_menu()
assert page.navigation.is_products_menu_displayed
assert not page.navigation.is_firefox_menu_displayed

page.open()
manifesto_page = page.navigation.open_manifesto_page()
assert manifesto_page.seed_url in selenium.current_url
page.navigation.open_about_menu()
assert page.navigation.is_about_menu_displayed
assert not page.navigation.is_products_menu_displayed

page.navigation.open_innovation_menu()
assert page.navigation.is_innovation_menu_displayed
assert not page.navigation.is_about_menu_displayed


@pytest.mark.smoke
@pytest.mark.nondestructive
def test_mobile_navigation(base_url, selenium_mobile):
page = HomePage(selenium_mobile, base_url).open()
page = HomePage(selenium_mobile, base_url, locale="de").open()
page.navigation.show()
firefox_desktop_page = page.navigation.open_firefox_desktop_page()
assert firefox_desktop_page.seed_url in selenium_mobile.current_url
page.navigation.open_firefox_menu()
assert page.navigation.is_firefox_menu_displayed

page.open()
page.navigation.show()
developer_edition_page = page.navigation.open_developer_edition_page()
assert developer_edition_page.seed_url in selenium_mobile.current_url
page.navigation.open_products_menu()
assert page.navigation.is_products_menu_displayed

page.open()
page.navigation.show()
manifesto_page = page.navigation.open_manifesto_page()
assert manifesto_page.seed_url in selenium_mobile.current_url
page.navigation.open_about_menu()
assert page.navigation.is_about_menu_displayed

page.navigation.open_innovation_menu()
assert page.navigation.is_innovation_menu_displayed


@pytest.mark.smoke
@pytest.mark.nondestructive
@pytest.mark.skip_if_firefox(reason="Firefox download button is shown only to non-Firefox users.")
def test_navigation_download_firefox_button(base_url, selenium):
page = HomePage(selenium, base_url).open()
page = HomePage(selenium, base_url, locale="de").open()
assert not page.navigation.is_mozilla_vpn_button_displayed
assert page.navigation.is_firefox_download_button_displayed


@pytest.mark.nondestructive
@pytest.mark.skip_if_not_firefox(reason="Mozilla VPN button is shown only to Firefox users.")
def test_navigation_mozilla_vpn_button(base_url, selenium):
page = HomePage(selenium, base_url).open()
page = HomePage(selenium, base_url, locale="de").open()
assert not page.navigation.is_firefox_download_button_displayed
assert page.navigation.is_mozilla_vpn_button_displayed
82 changes: 42 additions & 40 deletions tests/pages/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,13 +48,14 @@ class Navigation(BaseRegion):
_root_locator = (By.CLASS_NAME, "c-navigation")
_toggle_locator = (By.CLASS_NAME, "c-navigation-menu-button")
_menu_locator = (By.CLASS_NAME, "c-navigation-items")
_firefox_menu_locator = (By.CSS_SELECTOR, '.c-menu-title[aria-controls="c-menu-panel-firefox"]')
_products_menu_locator = (By.CSS_SELECTOR, '.c-menu-title[aria-controls="c-menu-panel-products"]')
_about_menu_locator = (By.CSS_SELECTOR, '.c-menu-title[aria-controls="c-menu-panel-about"]')
_innovation_menu_locator = (By.CSS_SELECTOR, '.c-menu-title[aria-controls="c-menu-panel-innovation"]')
_firefox_desktop_page_locator = (By.CSS_SELECTOR, '.c-menu-item-link[data-link-text="Firefox Desktop Browser"]')
_developer_edition_page_locator = (By.CSS_SELECTOR, '.c-menu-item-link[data-link-text="Firefox Developer Edition"]')
_manifesto_page_locator = (By.CSS_SELECTOR, '.c-menu-item-link[data-link-text="Mozilla Manifesto"]')
_firefox_menu_link_locator = (By.CSS_SELECTOR, '.c-menu-title[aria-controls="c-menu-panel-firefox"]')
_firefox_menu_locator = (By.ID, "c-menu-panel-firefox")
_products_menu_link_locator = (By.CSS_SELECTOR, '.c-menu-title[aria-controls="c-menu-panel-products"]')
_products_menu_locator = (By.ID, "c-menu-panel-products")
_about_menu_link_locator = (By.CSS_SELECTOR, '.c-menu-title[aria-controls="c-menu-panel-about"]')
_about_menu_locator = (By.ID, "c-menu-panel-about")
_innovation_menu_link_locator = (By.CSS_SELECTOR, '.c-menu-title[aria-controls="c-menu-panel-innovation"]')
_innovation_menu_locator = (By.ID, "c-menu-panel-innovation")
_firefox_download_button_locator = (By.CSS_SELECTOR, "#protocol-nav-download-firefox > .download-link")
_mozilla_vpn_button_locator = (By.CSS_SELECTOR, '.c-navigation-vpn-cta-container > [data-cta-text="Get Mozilla VPN"]')

Expand All @@ -78,36 +79,37 @@ def is_displayed(self):
return self.find_element(*self._menu_locator).is_displayed() and "is-active" in toggle.get_attribute("class")

def open_navigation_menu(self, locator):
firefox_menu = self.find_element(*locator)
firefox_menu.click()
self.wait.until(lambda s: firefox_menu.is_displayed)

def open_firefox_desktop_page(self):
self.open_navigation_menu(self._firefox_menu_locator)
link = self.find_element(*self._firefox_desktop_page_locator)
href = link.get_attribute("href")
self.page.set_attribute(link, att_name="href", att_value=href + "?automation=true")
link.click()
from .firefox.new.download import DownloadPage

return DownloadPage(self.selenium, self.page.base_url).wait_for_page_to_load()

def open_developer_edition_page(self):
self.open_navigation_menu(self._innovation_menu_locator)
link = self.find_element(*self._developer_edition_page_locator)
href = link.get_attribute("href")
self.page.set_attribute(link, att_name="href", att_value=href + "?automation=true")
link.click()
from .firefox.developer import DeveloperPage

return DeveloperPage(self.selenium, self.page.base_url).wait_for_page_to_load()

def open_manifesto_page(self):
self.open_navigation_menu(self._about_menu_locator)
link = self.find_element(*self._manifesto_page_locator)
href = link.get_attribute("href")
self.page.set_attribute(link, att_name="href", att_value=href + "?automation=true")
link.click()
from .manifesto import ManifestoPage

return ManifestoPage(self.selenium, self.page.base_url).wait_for_page_to_load()
menu = self.find_element(*locator)
menu.click()

@property
def is_firefox_menu_displayed(self):
return self.is_element_displayed(*self._firefox_menu_locator)

@property
def is_products_menu_displayed(self):
return self.is_element_displayed(*self._products_menu_locator)

@property
def is_about_menu_displayed(self):
return self.is_element_displayed(*self._about_menu_locator)

@property
def is_innovation_menu_displayed(self):
return self.is_element_displayed(*self._innovation_menu_locator)

def open_firefox_menu(self):
self.open_navigation_menu(self._firefox_menu_link_locator)
self.wait.until(lambda s: self.is_firefox_menu_displayed)

def open_products_menu(self):
self.open_navigation_menu(self._products_menu_link_locator)
self.wait.until(lambda s: self.is_products_menu_displayed)

def open_about_menu(self):
self.open_navigation_menu(self._about_menu_link_locator)
self.wait.until(lambda s: self.is_about_menu_displayed)

def open_innovation_menu(self):
self.open_navigation_menu(self._innovation_menu_link_locator)
self.wait.until(lambda s: self.is_innovation_menu_displayed)
6 changes: 0 additions & 6 deletions tests/pages/firefox/family/landing.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,6 @@ class FamilyPage(BasePage):

_firefox_nav_cta_locator = (By.CSS_SELECTOR, ".c-navigation-shoulder")

_firefox_nav_download_button_locator = (By.CSS_SELECTOR, "[data-cta-position='nav']")

_firefox_desktop_download_button_locator = (By.CSS_SELECTOR, "[data-cta-position='download section']")

_firefox_make_default_button_locator = (By.CSS_SELECTOR, "[data-cta-text='Set Firefox as your default browser']")
Expand All @@ -26,10 +24,6 @@ class FamilyPage(BasePage):
def is_firefox_nav_cta_displayed(self):
return self.is_element_displayed(*self._firefox_nav_cta_locator)

@property
def is_firefox_nav_download_button_displayed(self):
return self.is_element_displayed(*self._firefox_nav_download_button_locator)

@property
def is_firefox_desktop_download_button_displayed(self):
return self.is_element_displayed(*self._firefox_desktop_download_button_locator)
Expand Down
2 changes: 1 addition & 1 deletion tests/playwright/specs/navigation.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

const { test, expect } = require('@playwright/test');
const openPage = require('../scripts/open-page');
const url = '/en-US/';
const url = '/de/';

test.describe(
`${url} navigation (desktop)`,
Expand Down
18 changes: 0 additions & 18 deletions tests/playwright/specs/products/vpn/vpn-landing.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,6 @@ test.describe(
});

test(`Country code: ${country}`, async ({ page }) => {
const getVpnNavButton = page.getByTestId(
'get-mozilla-vpn-nav-button'
);
const getVpnHeroButton = page.getByTestId(
'get-mozilla-vpn-hero-button'
);
Expand All @@ -46,10 +43,6 @@ test.describe(
const getVpnFooterButton = page.getByTestId(
'get-mozilla-vpn-footer-button'
);

const waitlistNavButton = page.getByTestId(
'join-waitlist-nav-button'
);
const waitlistHeroButton = page.getByTestId(
'join-waitlist-hero-button'
);
Expand All @@ -67,7 +60,6 @@ test.describe(
);

// Assert Get Mozilla VPN buttons are displayed.
await expect(getVpnNavButton).toBeVisible();
await expect(getVpnHeroButton).toBeVisible();
await expect(getVpnTwelveMonthButton).toBeVisible();
await expect(getVpnMonthlyButton).toBeVisible();
Expand All @@ -78,7 +70,6 @@ test.describe(
// Assert Join Waitlist buttons are not displayed.
await expect(waitlistHeroButton).not.toBeVisible();
await expect(waitlistNotAvailableButton).not.toBeVisible();
await expect(waitlistNavButton).not.toBeVisible();
await expect(waitlistSecondaryButton).not.toBeVisible();
await expect(waitlistTertiaryButton).not.toBeVisible();
await expect(waitlistFooterButton).not.toBeVisible();
Expand All @@ -93,9 +84,6 @@ test.describe(
});

test(`Country code: ${country}`, async ({ page }) => {
const getVpnNavButton = page.getByTestId(
'get-mozilla-vpn-nav-button'
);
const getVpnHeroButton = page.getByTestId(
'get-mozilla-vpn-hero-button'
);
Expand All @@ -114,10 +102,6 @@ test.describe(
const getVpnFooterButton = page.getByTestId(
'get-mozilla-vpn-footer-button'
);

const waitlistNavButton = page.getByTestId(
'join-waitlist-nav-button'
);
const waitlistHeroButton = page.getByTestId(
'join-waitlist-hero-button'
);
Expand All @@ -135,15 +119,13 @@ test.describe(
);

// Assert Join Waitlist buttons are displayed.
await expect(waitlistNavButton).toBeVisible();
await expect(waitlistHeroButton).toBeVisible();
await expect(waitlistNotAvailableButton).toBeVisible();
await expect(waitlistSecondaryButton).toBeVisible();
await expect(waitlistTertiaryButton).toBeVisible();
await expect(waitlistFooterButton).toBeVisible();

// Assert Get Mozilla VPN buttons are not displayed.
await expect(getVpnNavButton).not.toBeVisible();
await expect(getVpnHeroButton).not.toBeVisible();
await expect(getVpnTwelveMonthButton).not.toBeVisible();
await expect(getVpnMonthlyButton).not.toBeVisible();
Expand Down

0 comments on commit 8840a2a

Please sign in to comment.