diff --git a/playwright/e2e/ui/pages/home.py b/playwright/e2e/ui/pages/home.py index 1a3f14b4c6..f2a5f4e56e 100644 --- a/playwright/e2e/ui/pages/home.py +++ b/playwright/e2e/ui/pages/home.py @@ -76,11 +76,17 @@ def book_toc_slideout_is_visible(self): @pytest.mark.asyncio async def click_book_cover_link(self): - await self.page.locator("a").get_by_text("Calculus Volume 1").click() + await self.page.locator("a").get_by_text( + "Principles of Management" + ).scroll_into_view_if_needed() + await self.page.locator("a").get_by_text("Principles of Management").click() @pytest.mark.asyncio async def click_view_online_link(self): - await self.page.locator("a").get_by_text("View online").click() + await self.page.get_by_role( + "link", name="View online" + ).scroll_into_view_if_needed() + await self.page.get_by_role("link", name="View online").click() @pytest.mark.asyncio async def click_go_to_your_book_link(self): @@ -116,6 +122,10 @@ async def subjects_title(self): await self.page.locator("section.subject-intro > div > h1").inner_text() ).lower() + @property + def book_title_image(self): + return self.page.get_by_alt_text("Principles of Management") + # Highlights and Notes @pytest.mark.asyncio diff --git a/playwright/e2e/ui/test_book.py b/playwright/e2e/ui/test_book.py index 83c2df982d..d82f8b5ac1 100644 --- a/playwright/e2e/ui/test_book.py +++ b/playwright/e2e/ui/test_book.py @@ -18,8 +18,8 @@ async def test_book_title_links_to_books_detail_page(chrome_page, base_url): await home.click_book_selection() - # THEN: The page navigates to {base_url}/details/books/astronomy-2e - assert "astronomy-2e" in chrome_page.url + # THEN: The page navigates to {base_url}/details/books/astronomy + assert "astronomy" in chrome_page.url.lower() @pytest.mark.parametrize("book_slug", ["physics"]) @@ -73,7 +73,7 @@ async def test_order_options_link(chrome_page, base_url, book_slug): ) @pytest.mark.asyncio async def test_accessibility_help(chrome_page, base_url, book_slug, page_slug): - # Verifies the hidden 'Go to accessibility page' + """Verifies the hidden 'Go to accessibility page'""" # GIVEN: Open osweb book details page diff --git a/playwright/e2e/ui/test_book_opens.py b/playwright/e2e/ui/test_book_opens.py index eed981c963..e9d38526d9 100644 --- a/playwright/e2e/ui/test_book_opens.py +++ b/playwright/e2e/ui/test_book_opens.py @@ -9,21 +9,29 @@ async def test_book_opens(chrome_page, base_url): # GIVEN: Playwright, chromium and the rex_base_url # WHEN: The Home page is fully loaded - await chrome_page.goto(f"{base_url}/subjects/math") + await chrome_page.goto(f"{base_url}/subjects/business") home = HomeRex(chrome_page) - await home.click_book_cover_link() + if "staging" not in chrome_page.url: - # THEN: Book details page opens + # THEN: Book details page opens (openstax prod) + await home.click_book_cover_link() - assert "calculus-volume-1" in chrome_page.url + await home.book_title_image.is_visible() - assert await home.highlight_recommended_popup_is_visible() + assert await home.highlight_recommended_popup_is_visible() - assert await home.order_print_copy_options_box_is_visible() + assert await home.order_print_copy_options_box_is_visible() - await home.click_view_online_link() + await home.click_view_online_link() - await home.click_go_to_your_book_link() + await home.click_go_to_your_book_link() - assert await home.toc_is_visible() + assert await home.toc_is_visible() + + else: + + # THEN: Book details page opens (openstax staging) + await home.click_book_cover_link() + + await home.book_title_image.is_visible()