From 40abc990d74458f982958278b69efaf8df30cf6e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ott=C3=B3?= Date: Mon, 15 Sep 2025 16:02:47 -0500 Subject: [PATCH 1/3] osweb qa tests to complete existing rex tests --- playwright/e2e/osweb/test_osweb_homepage.py | 18 +++++++++ .../e2e/osweb/test_subjects_books_pages.py | 39 +++++++++++++++++++ playwright/e2e/osweb/test_subjects_footer.py | 31 +++++++++++++++ .../e2e/osweb/test_subjects_homepage.py | 37 ++++++++++++++++++ .../test_subjects_philanthropic_support.py | 34 ++++++++++++++++ playwright/e2e/ui/pages/home.py | 32 +++++++++++++++ 6 files changed, 191 insertions(+) create mode 100644 playwright/e2e/osweb/test_osweb_homepage.py create mode 100644 playwright/e2e/osweb/test_subjects_books_pages.py create mode 100644 playwright/e2e/osweb/test_subjects_footer.py create mode 100644 playwright/e2e/osweb/test_subjects_homepage.py create mode 100644 playwright/e2e/osweb/test_subjects_philanthropic_support.py diff --git a/playwright/e2e/osweb/test_osweb_homepage.py b/playwright/e2e/osweb/test_osweb_homepage.py new file mode 100644 index 0000000000..0d93d26038 --- /dev/null +++ b/playwright/e2e/osweb/test_osweb_homepage.py @@ -0,0 +1,18 @@ +import pytest +import asyncio + +from e2e.ui.pages.home import HomeRex + + +@pytest.mark.asyncio +async def test_osweb_homepage_loads(chrome_page, base_url): + + # GIVEN: Playwright, chromium and the rex_base_url + + # WHEN: The Home page is fully loaded + await chrome_page.goto(base_url) + home = HomeRex(chrome_page) + + # THEN: Openstax logo and osweb homepage sections are is visible + assert await home.main_menu_and_openstax_logo_is_visible() + assert await home.osweb_homepage_content_sections() diff --git a/playwright/e2e/osweb/test_subjects_books_pages.py b/playwright/e2e/osweb/test_subjects_books_pages.py new file mode 100644 index 0000000000..6a99898b8d --- /dev/null +++ b/playwright/e2e/osweb/test_subjects_books_pages.py @@ -0,0 +1,39 @@ +import pytest +import asyncio + +from e2e.ui.pages.home import HomeRex + + +@pytest.mark.asyncio +async def test_subjects_books_pages_load(chrome_page, base_url): + # GIVEN: Playwright, chromium and the rex_base_url + + # WHEN: The Home page is fully loaded + await chrome_page.goto(base_url) + home = HomeRex(chrome_page) + + await home.click_subjects_page_menu() + + # THEN: Subjects list shows and subjects pages load + scount = await home.subjects_list.count() + + for i in range(scount): + item = home.subjects_list.nth(i) + hrefs = await item.get_attribute("href") + slink = f"{base_url}{hrefs}" + + slink_resp = await chrome_page.goto(slink) + + assert slink_resp.status == 200 + + try: + assert await home.subjects_intro() + + except AssertionError: + continue + + else: + mhrefs = hrefs.replace("/subjects/", "") + mod_hrefs = mhrefs.replace("-", " ") + + assert await home.subjects_title() in mod_hrefs diff --git a/playwright/e2e/osweb/test_subjects_footer.py b/playwright/e2e/osweb/test_subjects_footer.py new file mode 100644 index 0000000000..c70029410e --- /dev/null +++ b/playwright/e2e/osweb/test_subjects_footer.py @@ -0,0 +1,31 @@ +import pytest +import asyncio + +from e2e.ui.pages.home import HomeRex + + +@pytest.mark.asyncio +async def test_subjects_footer(chrome_page, base_url): + + # GIVEN: Playwright, chromium and the rex_base_url + + # WHEN: The Home page is fully loaded + await chrome_page.goto(base_url) + home = HomeRex(chrome_page) + + await home.click_subjects_page_menu() + + await home.click_subjects_homepage_link() + + # THEN: Footer section loads + assert home.footer_section + + assert home.footer_section_help_is_visible + assert home.footer_section_openstax_is_visible + assert home.footer_section_policies_is_visible + + assert home.footer_section_bottom_is_visible + + assert "Rice University" and "license" in await home.footer_section_bottom_is_visible.inner_text() + + assert "https://creativecommons.org" in await home.footer_section_license_link diff --git a/playwright/e2e/osweb/test_subjects_homepage.py b/playwright/e2e/osweb/test_subjects_homepage.py new file mode 100644 index 0000000000..676d87e868 --- /dev/null +++ b/playwright/e2e/osweb/test_subjects_homepage.py @@ -0,0 +1,37 @@ +import pytest +import asyncio + +from e2e.ui.pages.home import HomeRex + + +@pytest.mark.asyncio +async def test_subjects_homepage(chrome_page, base_url): + + # GIVEN: Playwright, chromium and the rex_base_url + + # WHEN: The Home page is fully loaded + await chrome_page.goto(base_url) + home = HomeRex(chrome_page) + + assert home.subjects_page_menu + + await home.click_subjects_page_menu() + + await home.click_subjects_homepage_link() + + subjects_list = ["Business", "College Success", "Computer Science", "Humanities", "Math", "Nursing", + "Science", "Social Sciences"] + + # THEN: Book subjects homepage opens + assert "English, Spanish, and Polish" in await home.language_selector_section.inner_text() + + for subject in subjects_list: + assert subject in await home.subjects_listing_section.inner_text() + + about = await home.about_openstax_section.inner_text() + assert "about openstax textbooks" in about.lower() + + await home.click_learn_about_openstax_link() + + assert f"{base_url}/about" == chrome_page.url + assert "Who we are" and "What we do" and "Where we're going" in await home.about_page.inner_text() diff --git a/playwright/e2e/osweb/test_subjects_philanthropic_support.py b/playwright/e2e/osweb/test_subjects_philanthropic_support.py new file mode 100644 index 0000000000..fd90a5bc8a --- /dev/null +++ b/playwright/e2e/osweb/test_subjects_philanthropic_support.py @@ -0,0 +1,34 @@ +import pytest +import asyncio + +from e2e.ui.pages.home import HomeRex + + +@pytest.mark.asyncio +async def test_subjects_philanthropic_support(chrome_page, base_url): + + # GIVEN: Playwright, chromium and the rex_base_url + + # WHEN: The Home page is fully loaded + await chrome_page.goto(base_url) + home = HomeRex(chrome_page) + + await home.click_subjects_page_menu() + + await home.click_subjects_homepage_link() + + assert home.philanthropic_support_section + + # THEN: Philanthropic support section opens + await home.click_our_impact_link() + + assert f"{base_url}/impact" == chrome_page.url + + assert home.give_today_link_is_visible + + async with chrome_page.expect_popup() as popup_info: + await home.click_give_today_link() + + new_tab = await popup_info.value + + assert "riceconnect.rice.edu/donation/support-openstax-" in new_tab.url diff --git a/playwright/e2e/ui/pages/home.py b/playwright/e2e/ui/pages/home.py index a74f96cf8d..31daaeec71 100644 --- a/playwright/e2e/ui/pages/home.py +++ b/playwright/e2e/ui/pages/home.py @@ -16,6 +16,22 @@ def __init__(self, page): async def click_openstax_logo(self): await self.page.get_by_test_id("navbar").get_by_role("img").click() + @pytest.mark.asyncio + async def main_menu_and_openstax_logo_is_visible(self): + return await self.page.locator("div.menus.desktop > nav.nav").is_visible() + + @pytest.mark.asyncio + async def osweb_homepage_content_is_visible(self): + return await self.page.locator("main > section:nth-child(5)").is_visible() + + @property + def osweb_homepage_sections(self): + return self.page.locator("main") + + @pytest.mark.asyncio + async def osweb_homepage_content_sections(self): + return await self.page.locator(f"main > section:nth-child(5)").is_visible() + # Subjects homepage @property @@ -118,6 +134,22 @@ async def click_instructor_resources_tab(self): async def click_student_resources_tab(self): await self.page.locator("id=Student resources-tab").click() + @pytest.mark.asyncio + async def click_subjects_science_link(self): + await self.subjects_science_link.click() + + @property + def subjects_list(self): + return self.page.locator("#ddId-Subjects > a") + + @pytest.mark.asyncio + async def subjects_intro(self): + return await self.page.locator("section.subject-intro").is_visible() + + @pytest.mark.asyncio + async def subjects_title(self): + return (await self.page.locator("section.subject-intro > div > h1").inner_text()).lower() + # Highlights and Notes @property From 3c93c39dd98312286c59e61fdd30b8dc90898a3d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ott=C3=B3?= Date: Tue, 16 Sep 2025 11:15:30 -0500 Subject: [PATCH 2/3] amendments as per review --- playwright/e2e/osweb/test_subjects_footer.py | 3 ++- playwright/e2e/osweb/test_subjects_homepage.py | 3 ++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/playwright/e2e/osweb/test_subjects_footer.py b/playwright/e2e/osweb/test_subjects_footer.py index c70029410e..7b47e2c55e 100644 --- a/playwright/e2e/osweb/test_subjects_footer.py +++ b/playwright/e2e/osweb/test_subjects_footer.py @@ -26,6 +26,7 @@ async def test_subjects_footer(chrome_page, base_url): assert home.footer_section_bottom_is_visible - assert "Rice University" and "license" in await home.footer_section_bottom_is_visible.inner_text() + assert ("Rice University" in await home.footer_section_bottom_is_visible.inner_text() + and "license" in await home.footer_section_bottom_is_visible.inner_text()) assert "https://creativecommons.org" in await home.footer_section_license_link diff --git a/playwright/e2e/osweb/test_subjects_homepage.py b/playwright/e2e/osweb/test_subjects_homepage.py index 676d87e868..ac13a13431 100644 --- a/playwright/e2e/osweb/test_subjects_homepage.py +++ b/playwright/e2e/osweb/test_subjects_homepage.py @@ -34,4 +34,5 @@ async def test_subjects_homepage(chrome_page, base_url): await home.click_learn_about_openstax_link() assert f"{base_url}/about" == chrome_page.url - assert "Who we are" and "What we do" and "Where we're going" in await home.about_page.inner_text() + assert ("Who we are" in await home.about_page.inner_text() and "What we do" in await home.about_page.inner_text() + and "Where we're going" in await home.about_page.inner_text()) From 3fc1425d053889c880b53fd863d3a7c6afe5d012 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ott=C3=B3?= Date: Mon, 22 Sep 2025 10:56:47 -0500 Subject: [PATCH 3/3] page object changes as per review --- playwright/e2e/osweb/test_subjects_footer.py | 16 +++--- .../e2e/osweb/test_subjects_homepage.py | 2 +- .../test_subjects_philanthropic_support.py | 4 +- playwright/e2e/ui/pages/home.py | 53 ++++++++++--------- 4 files changed, 39 insertions(+), 36 deletions(-) diff --git a/playwright/e2e/osweb/test_subjects_footer.py b/playwright/e2e/osweb/test_subjects_footer.py index 7b47e2c55e..7ba0683eae 100644 --- a/playwright/e2e/osweb/test_subjects_footer.py +++ b/playwright/e2e/osweb/test_subjects_footer.py @@ -18,15 +18,15 @@ async def test_subjects_footer(chrome_page, base_url): await home.click_subjects_homepage_link() # THEN: Footer section loads - assert home.footer_section + assert await home.footer_section() - assert home.footer_section_help_is_visible - assert home.footer_section_openstax_is_visible - assert home.footer_section_policies_is_visible + assert await home.footer_section_help_is_visible() + assert await home.footer_section_openstax_is_visible() + assert await home.footer_section_policies_is_visible() - assert home.footer_section_bottom_is_visible + assert await home.footer_section_bottom_is_visible() - assert ("Rice University" in await home.footer_section_bottom_is_visible.inner_text() - and "license" in await home.footer_section_bottom_is_visible.inner_text()) + assert ("Rice University" in await home.footer_section_bottom.inner_text() + and "license" in await home.footer_section_bottom.inner_text()) - assert "https://creativecommons.org" in await home.footer_section_license_link + assert "https://creativecommons.org" in await home.footer_section_license_link() diff --git a/playwright/e2e/osweb/test_subjects_homepage.py b/playwright/e2e/osweb/test_subjects_homepage.py index ac13a13431..23571be5be 100644 --- a/playwright/e2e/osweb/test_subjects_homepage.py +++ b/playwright/e2e/osweb/test_subjects_homepage.py @@ -13,7 +13,7 @@ async def test_subjects_homepage(chrome_page, base_url): await chrome_page.goto(base_url) home = HomeRex(chrome_page) - assert home.subjects_page_menu + assert await home.subjects_page_menu() await home.click_subjects_page_menu() diff --git a/playwright/e2e/osweb/test_subjects_philanthropic_support.py b/playwright/e2e/osweb/test_subjects_philanthropic_support.py index fd90a5bc8a..1dd9b36d4f 100644 --- a/playwright/e2e/osweb/test_subjects_philanthropic_support.py +++ b/playwright/e2e/osweb/test_subjects_philanthropic_support.py @@ -17,14 +17,14 @@ async def test_subjects_philanthropic_support(chrome_page, base_url): await home.click_subjects_homepage_link() - assert home.philanthropic_support_section + assert await home.philanthropic_support_section() # THEN: Philanthropic support section opens await home.click_our_impact_link() assert f"{base_url}/impact" == chrome_page.url - assert home.give_today_link_is_visible + assert await home.give_today_link_is_visible() async with chrome_page.expect_popup() as popup_info: await home.click_give_today_link() diff --git a/playwright/e2e/ui/pages/home.py b/playwright/e2e/ui/pages/home.py index 31daaeec71..fb42922f3c 100644 --- a/playwright/e2e/ui/pages/home.py +++ b/playwright/e2e/ui/pages/home.py @@ -34,13 +34,13 @@ async def osweb_homepage_content_sections(self): # Subjects homepage - @property - def subjects_page_menu(self): - return self.page.get_by_role("button", name="Subjects") + @pytest.mark.asyncio + async def subjects_page_menu(self): + return await self.page.get_by_role("button", name="Subjects").is_visible() @pytest.mark.asyncio async def click_subjects_page_menu(self): - await self.subjects_page_menu.hover() + await self.page.get_by_role("button", name="Subjects").hover() @property def subjects_homepage_link(self): @@ -244,9 +244,9 @@ async def close_giving_tuesday_popup(self): # Philanthropic support - @property - def philanthropic_support_section(self): - return self.page.locator("section.philanthropic-support") + @pytest.mark.asyncio + async def philanthropic_support_section(self): + return await self.page.locator("section.philanthropic-support").is_visible() @property def our_impact_link(self): @@ -256,37 +256,40 @@ def our_impact_link(self): async def click_our_impact_link(self): await self.our_impact_link.click() - @property - def give_today_link_is_visible(self): - return self.page.locator("#footer").get_by_role("link", name="Give today") + @pytest.mark.asyncio + async def give_today_link_is_visible(self): + return await self.page.locator("#footer").get_by_role("link", name="Give today").is_visible() @pytest.mark.asyncio async def click_give_today_link(self): - await self.give_today_link_is_visible.click() + await self.page.locator("#footer").get_by_role("link", name="Give today").click() # Subjects page footer section - @property - def footer_section(self): - return self.page.locator("id=footer") + @pytest.mark.asyncio + async def footer_section(self): + return await self.page.locator("id=footer").is_visible() - @property - def footer_section_help_is_visible(self): - return self.page.locator("div.column.col1") + @pytest.mark.asyncio + async def footer_section_help_is_visible(self): + return await self.page.locator("div.column.col1").is_visible() - @property - def footer_section_openstax_is_visible(self): - return self.page.locator("div.column.col2") + @pytest.mark.asyncio + async def footer_section_openstax_is_visible(self): + return await self.page.locator("div.column.col2").is_visible() - @property - def footer_section_policies_is_visible(self): - return self.page.locator("div.column.col3") + @pytest.mark.asyncio + async def footer_section_policies_is_visible(self): + return await self.page.locator("div.column.col3").is_visible() + + @pytest.mark.asyncio + async def footer_section_bottom_is_visible(self): + return await self.page.locator("div.bottom").is_visible() @property - def footer_section_bottom_is_visible(self): + def footer_section_bottom(self): return self.page.locator("div.bottom") - @property @pytest.mark.asyncio async def footer_section_license_link(self): return await self.page.locator("div.copyrights").get_by_role("link").get_attribute("href")