From 7b6afda0c957d790c3f7ff408a46a9e10855ebc1 Mon Sep 17 00:00:00 2001 From: Malar Natarajan Date: Mon, 17 Jun 2024 08:28:08 -0500 Subject: [PATCH 01/11] test --- playwright/tests/rex-test/rex.behaviorspec.ts | 59 +++++++++++++++++++ 1 file changed, 59 insertions(+) diff --git a/playwright/tests/rex-test/rex.behaviorspec.ts b/playwright/tests/rex-test/rex.behaviorspec.ts index 29b73b1a7b..d9157cee2d 100644 --- a/playwright/tests/rex-test/rex.behaviorspec.ts +++ b/playwright/tests/rex-test/rex.behaviorspec.ts @@ -674,3 +674,62 @@ test('C543225 canonicals for old editions point to the latest edition', async ({ // THEN: Canonical page points to latest edition of the original content expect(await bookPage.canonical()).toBe('https://openstax.org/books/principles-economics-3e/pages/d-the-expenditure-output-model') }) + + +test('C543225 canonicals for multi-volumed books point to a single volume', async ({ page, isMobile, browserName }) => { + test.skip(isMobile as boolean, 'test only desktop resolution') + test.skip(browserName == 'webkit', 'test only chrome') + test.skip(browserName == 'firefox', 'test only chrome') + + // GIVEN: Open Volume 1 of calculus book + const bookPage = new ContentPage(page) + const path = '/books/calculus-volume-1/pages/1-introduction' + await bookPage.open(path) + // THEN: Canonical of Volume 1 points to itself + expect(await bookPage.canonical()).toBe('https://openstax.org/books/calculus-volume-1/pages/1-introduction') + + // WHEN: Open EOC page + const Toc = new TOC(page) + await Toc.pageClick(17) + // THEN: Canonical of volume 1 EOC page points to itself + expect(await bookPage.canonical()).toBe('https://openstax.org/books/calculus-volume-1/pages/2-key-terms') + + // WHEN: Open EOB nested page + await Toc.pageClick(81) + // THEN: Canonical of volume 1 EOB nested page points to itself + expect(await bookPage.canonical()).toBe('https://openstax.org/books/calculus-volume-1/pages/chapter-3') + + // WHEN: Open EOB page + await Toc.pageClick(76) + // THEN: Canonical of volume 1 EOB page points to itself + expect(await bookPage.canonical()).toBe('https://openstax.org/books/calculus-volume-1/pages/a-table-of-integrals') +}) + +test('C543225 canonicals for multi-volumed books point to a single volume', async ({ page, isMobile, browserName }) => { + test.skip(isMobile as boolean, 'test only desktop resolution') + test.skip(browserName == 'webkit', 'test only chrome') + test.skip(browserName == 'firefox', 'test only chrome') + + // GIVEN: Open Volume 1 of calculus book + const bookPage = new ContentPage(page) + const path = '/books/calculus-volume-2/pages/1-introduction' + await bookPage.open(path) + // THEN: Canonical of Volume 1 points to itself + expect(await bookPage.canonical()).toBe('https://openstax.org/books/calculus-volume-1/pages/1-introduction') + + // WHEN: Open EOC page + const Toc = new TOC(page) + await Toc.pageClick(17) + // THEN: Canonical of volume 1 EOC page points to itself + expect(await bookPage.canonical()).toBe('https://openstax.org/books/calculus-volume-1/pages/2-key-terms') + + // WHEN: Open EOB nested page + await Toc.pageClick(81) + // THEN: Canonical of volume 1 EOB nested page points to itself + expect(await bookPage.canonical()).toBe('https://openstax.org/books/calculus-volume-1/pages/chapter-3') + + // WHEN: Open EOB page + await Toc.pageClick(76) + // THEN: Canonical of volume 1 EOB page points to itself + expect(await bookPage.canonical()).toBe('https://openstax.org/books/calculus-volume-1/pages/a-table-of-integrals') +}) \ No newline at end of file From bc3c5dc11716eae476294b0a6d7bcab40d89c77d Mon Sep 17 00:00:00 2001 From: Malar Natarajan Date: Mon, 17 Jun 2024 08:28:38 -0500 Subject: [PATCH 02/11] test --- pytest-selenium/regions/my_highlights.py | 8 ++++---- pytest-selenium/utils/books.json | 12 ++++++++++++ 2 files changed, 16 insertions(+), 4 deletions(-) diff --git a/pytest-selenium/regions/my_highlights.py b/pytest-selenium/regions/my_highlights.py index 4b53da5b89..ddceb3379d 100644 --- a/pytest-selenium/regions/my_highlights.py +++ b/pytest-selenium/regions/my_highlights.py @@ -582,8 +582,8 @@ def remove_tag(self) -> MyHighlights: class Highlights(Region): """The modal body containing the filtered list of highlights.""" - _chapter_locator = (By.XPATH, "//div[@data-testid='chapter-title']") - _section_locator = (By.XPATH, "//div[@data-testid='section-title']") + _chapter_locator = (By.XPATH, "//h2[@data-testid='chapter-title']") + _section_locator = (By.XPATH, "//h3[@data-testid='section-title']") _no_results_message_locator = (By.CSS_SELECTOR, "[class*=GeneralTextWrapper]") _highlight_locator = (By.CSS_SELECTOR, "[class*=HighlightOuterWrapper]") _empty_state_nudge_locator = (By.CSS_SELECTOR, "[class*=MyHighlightsWrapper]") @@ -1041,11 +1041,11 @@ class Section(ChapterData): """A chapter section with highlights.""" _number_locator = ( - By.CSS_SELECTOR, "div:first-child .os-number") + By.CSS_SELECTOR, "h3:first-child .os-number") _highlight_locator = ( By.XPATH, "./following-sibling::div//div[@data-highlight-id]") _title_locator = ( - By.CSS_SELECTOR, "div:first-child .os-text") + By.CSS_SELECTOR, "h3:first-child .os-text") @property def highlights(self) -> List[Highlight]: diff --git a/pytest-selenium/utils/books.json b/pytest-selenium/utils/books.json index 8813683f98..0333cd2015 100644 --- a/pytest-selenium/utils/books.json +++ b/pytest-selenium/utils/books.json @@ -472,6 +472,18 @@ "search_term": "mental health", "chapter_search_results_total": 2674, "rkt_search_results_total": 4 + }, + "maternal-newborn": { + "default_page": "1-introduction", + "search_term": "newborn babies", + "chapter_search_results_total": 446, + "rkt_search_results_total": 0 + }, + "clinical-nursing-skills": { + "default_page": "1-introduction", + "search_term": "clinical nursing skills", + "chapter_search_results_total": 118, + "rkt_search_results_total": 1 } } From ed171ba075e5e09fdbe4002d97443a167e17af03 Mon Sep 17 00:00:00 2001 From: Malar Natarajan Date: Mon, 1 Jul 2024 14:51:52 -0500 Subject: [PATCH 03/11] try runnning in ci --- playwright/src/fixtures/content.page.ts | 3 +- playwright/tests/rex-test/rex.behaviorspec.ts | 81 ++++++++++++++----- 2 files changed, 61 insertions(+), 23 deletions(-) diff --git a/playwright/src/fixtures/content.page.ts b/playwright/src/fixtures/content.page.ts index 191bfd2dff..731a07d87d 100644 --- a/playwright/src/fixtures/content.page.ts +++ b/playwright/src/fixtures/content.page.ts @@ -1,6 +1,6 @@ // Content page locators and functions import { Locator, Page } from 'playwright' -import { MobileNavigation } from '../utilities/utilities' +import { MobileNavigation, sleep } from '../utilities/utilities' class ContentPage { colorlocator: any @@ -93,6 +93,7 @@ class ContentPage { async canonical() { // Return canonical link of the current page let canonicalPageSelector = await this.page.$('[rel="canonical"]') + sleep(4) const canonicalPage = await canonicalPageSelector.evaluate((e) => e.getAttribute('href')) return canonicalPage } diff --git a/playwright/tests/rex-test/rex.behaviorspec.ts b/playwright/tests/rex-test/rex.behaviorspec.ts index d9157cee2d..a55247161b 100644 --- a/playwright/tests/rex-test/rex.behaviorspec.ts +++ b/playwright/tests/rex-test/rex.behaviorspec.ts @@ -683,53 +683,90 @@ test('C543225 canonicals for multi-volumed books point to a single volume', asyn // GIVEN: Open Volume 1 of calculus book const bookPage = new ContentPage(page) - const path = '/books/calculus-volume-1/pages/1-introduction' - await bookPage.open(path) + const path1 = '/books/calculus-volume-1/pages/1-introduction' + sleep(1) + await bookPage.open(path1) // THEN: Canonical of Volume 1 points to itself expect(await bookPage.canonical()).toBe('https://openstax.org/books/calculus-volume-1/pages/1-introduction') // WHEN: Open EOC page const Toc = new TOC(page) await Toc.pageClick(17) + sleep(1) // THEN: Canonical of volume 1 EOC page points to itself expect(await bookPage.canonical()).toBe('https://openstax.org/books/calculus-volume-1/pages/2-key-terms') // WHEN: Open EOB nested page await Toc.pageClick(81) + sleep(1) // THEN: Canonical of volume 1 EOB nested page points to itself expect(await bookPage.canonical()).toBe('https://openstax.org/books/calculus-volume-1/pages/chapter-3') // WHEN: Open EOB page await Toc.pageClick(76) + sleep(1) // THEN: Canonical of volume 1 EOB page points to itself expect(await bookPage.canonical()).toBe('https://openstax.org/books/calculus-volume-1/pages/a-table-of-integrals') -}) -test('C543225 canonicals for multi-volumed books point to a single volume', async ({ page, isMobile, browserName }) => { - test.skip(isMobile as boolean, 'test only desktop resolution') - test.skip(browserName == 'webkit', 'test only chrome') - test.skip(browserName == 'firefox', 'test only chrome') + // WHEN: Open Volume 2 of calculus book + const path2 = '/books/calculus-volume-2/pages/1-3-the-fundamental-theorem-of-calculus' + await bookPage.open(path2) + sleep(10) + // THEN: Canonical of Volume 2 points to volume 1 for shared content + expect(await bookPage.canonical()).toBe('https://openstax.org/books/calculus-volume-1/pages/5-3-the-fundamental-theorem-of-calculus') - // GIVEN: Open Volume 1 of calculus book - const bookPage = new ContentPage(page) - const path = '/books/calculus-volume-2/pages/1-introduction' - await bookPage.open(path) - // THEN: Canonical of Volume 1 points to itself - expect(await bookPage.canonical()).toBe('https://openstax.org/books/calculus-volume-1/pages/1-introduction') + // WHEN: Open volume 2 page that is not shared with previous volume + await Toc.pageClick(71) + sleep(1) + // THEN: Canonical of Volume 2 points to self for non-shared content + expect(await bookPage.canonical()).toBe('https://openstax.org/books/calculus-volume-2/pages/7-2-calculus-of-parametric-curves') // WHEN: Open EOC page - const Toc = new TOC(page) - await Toc.pageClick(17) - // THEN: Canonical of volume 1 EOC page points to itself - expect(await bookPage.canonical()).toBe('https://openstax.org/books/calculus-volume-1/pages/2-key-terms') + await Toc.pageClick(11) + sleep(1) + // THEN: Canonical of volume 2 EOC page points to itself + expect(await bookPage.canonical()).toBe('https://openstax.org/books/calculus-volume-2/pages/1-key-concepts') // WHEN: Open EOB nested page + await Toc.pageClick(84) + sleep(1) + // THEN: Canonical of volume 2 EOB nested page points to itself + expect(await bookPage.canonical()).toBe('https://openstax.org/books/calculus-volume-2/pages/chapter-3') + + // WHEN: Open EOB page await Toc.pageClick(81) - // THEN: Canonical of volume 1 EOB nested page points to itself - expect(await bookPage.canonical()).toBe('https://openstax.org/books/calculus-volume-1/pages/chapter-3') + sleep(1) + // THEN: Canonical of volume 2 EOB page points to volume 1 + expect(await bookPage.canonical()).toBe('https://openstax.org/books/calculus-volume-1/pages/b-table-of-derivatives') + + // WHEN: Open volume 3 page that is shared with previous volumes + const path3 = '/books/calculus-volume-3/pages/1-1-parametric-equations' + await bookPage.open(path3) + sleep(10) + // THEN: Canonical of Volume 3 points to shared content + expect(await bookPage.canonical()).toBe('https://openstax.org/books/calculus-volume-2/pages/7-1-parametric-equations') + + // WHEN: Open volume 3 page that is not shared with previous volume + await Toc.pageClick(13) + sleep(1) + // THEN: Canonical of Volume 3 points to self for non-shared content + expect(await bookPage.canonical()).toBe('https://openstax.org/books/calculus-volume-3/pages/2-2-vectors-in-three-dimensions') + + // WHEN: Open EOC page + await Toc.pageClick(11) + sleep(1) + // THEN: Canonical of volume 3 EOC page points to itself + expect(await bookPage.canonical()).toBe('https://openstax.org/books/calculus-volume-3/pages/1-key-concepts') + + // WHEN: Open EOB nested page + await Toc.pageClick(84) + sleep(1) + // THEN: Canonical of volume 3 EOB nested page points to itself + expect(await bookPage.canonical()).toBe('https://openstax.org/books/calculus-volume-3/pages/chapter-3') // WHEN: Open EOB page - await Toc.pageClick(76) - // THEN: Canonical of volume 1 EOB page points to itself - expect(await bookPage.canonical()).toBe('https://openstax.org/books/calculus-volume-1/pages/a-table-of-integrals') + await Toc.pageClick(81) + sleep(1) + // THEN: Canonical of volume 2 EOB page points to volume 1 + expect(await bookPage.canonical()).toBe('https://openstax.org/books/calculus-volume-1/pages/c-review-of-pre-calculus') }) \ No newline at end of file From 04101c1d9cde0ba9c33df279b4c42376a597dfd8 Mon Sep 17 00:00:00 2001 From: Malar Natarajan Date: Tue, 9 Jul 2024 13:26:22 -0500 Subject: [PATCH 04/11] chromedriver --- pytest-selenium/requirements-dev.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pytest-selenium/requirements-dev.txt b/pytest-selenium/requirements-dev.txt index 93b0bc012f..928ef66470 100644 --- a/pytest-selenium/requirements-dev.txt +++ b/pytest-selenium/requirements-dev.txt @@ -5,7 +5,7 @@ certifi==2023.7.22 cffi==1.15.0 cfgv==3.3.1 chardet==4.0.0 -chromedriver-binary==124.0.6367.78.0 +chromedriver-binary==126.0.6478.62 cryptography==42.0.4 Faker==13.3.4 identify==2.4.12 From 1f6d18027a9792a3d4de2f802d18ee9dd7320089 Mon Sep 17 00:00:00 2001 From: Malar Natarajan Date: Thu, 11 Jul 2024 14:20:04 -0500 Subject: [PATCH 05/11] math check --- playwright/src/fixtures/content.page.ts | 12 +++++++++++- playwright/tests/rex-test/rex.behaviorspec.ts | 4 ++-- 2 files changed, 13 insertions(+), 3 deletions(-) diff --git a/playwright/src/fixtures/content.page.ts b/playwright/src/fixtures/content.page.ts index 731a07d87d..63eb07b850 100644 --- a/playwright/src/fixtures/content.page.ts +++ b/playwright/src/fixtures/content.page.ts @@ -33,6 +33,7 @@ class ContentPage { osanoManageButton: Locator osanoAccept: Locator osanoDialog: Locator + mathLocator: Locator constructor(page: Page) { this.page = page @@ -59,11 +60,20 @@ class ContentPage { this.textarea = this.page.locator('textarea[class*="TextArea"]') this.osanoCloseButton = this.page.locator('button[class*="osano-cm-dialog__close"]') this.osanoAccept = this.page.locator('button[class*="type_accept"]') + this.mathLocator = this.page.locator(".math") } async open(path: string) { // Open a Rex page with base url await this.page.goto(path) + // await Promise.all([this.mathLocator.waitFor()]) + + if(await this.page.$$(".math")) { + + await Promise.all([await this.page.$$("[id*=MathJax][id*=Frame] .math")]) + } + + // Close the osano cookie management widget if (await this.osanoAccept.isVisible()) { @@ -93,7 +103,7 @@ class ContentPage { async canonical() { // Return canonical link of the current page let canonicalPageSelector = await this.page.$('[rel="canonical"]') - sleep(4) + // sleep(4) const canonicalPage = await canonicalPageSelector.evaluate((e) => e.getAttribute('href')) return canonicalPage } diff --git a/playwright/tests/rex-test/rex.behaviorspec.ts b/playwright/tests/rex-test/rex.behaviorspec.ts index a55247161b..e19342feac 100644 --- a/playwright/tests/rex-test/rex.behaviorspec.ts +++ b/playwright/tests/rex-test/rex.behaviorspec.ts @@ -683,11 +683,11 @@ test('C543225 canonicals for multi-volumed books point to a single volume', asyn // GIVEN: Open Volume 1 of calculus book const bookPage = new ContentPage(page) - const path1 = '/books/calculus-volume-1/pages/1-introduction' + const path1 = '/books/calculus-volume-1/pages/1-1-review-of-functions' sleep(1) await bookPage.open(path1) // THEN: Canonical of Volume 1 points to itself - expect(await bookPage.canonical()).toBe('https://openstax.org/books/calculus-volume-1/pages/1-introduction') + expect(await bookPage.canonical()).toBe('https://openstax.org/books/calculus-volume-1/pages/1-1-review-of-functions') // WHEN: Open EOC page const Toc = new TOC(page) From a822aa3cc09a5aadeaae83fe738d20da71179e99 Mon Sep 17 00:00:00 2001 From: Malar Natarajan Date: Fri, 12 Jul 2024 12:13:47 -0500 Subject: [PATCH 06/11] remove sleep --- playwright/src/fixtures/content.page.ts | 10 +++-- playwright/tests/rex-test/rex.behaviorspec.ts | 38 +++++++++---------- 2 files changed, 25 insertions(+), 23 deletions(-) diff --git a/playwright/src/fixtures/content.page.ts b/playwright/src/fixtures/content.page.ts index 63eb07b850..4a1c17f553 100644 --- a/playwright/src/fixtures/content.page.ts +++ b/playwright/src/fixtures/content.page.ts @@ -34,6 +34,7 @@ class ContentPage { osanoAccept: Locator osanoDialog: Locator mathLocator: Locator + closeOverlay: Locator constructor(page: Page) { this.page = page @@ -61,20 +62,17 @@ class ContentPage { this.osanoCloseButton = this.page.locator('button[class*="osano-cm-dialog__close"]') this.osanoAccept = this.page.locator('button[class*="type_accept"]') this.mathLocator = this.page.locator(".math") + this.closeOverlay = this.page.locator('[aria-label="close overlay"]') } async open(path: string) { // Open a Rex page with base url await this.page.goto(path) - // await Promise.all([this.mathLocator.waitFor()]) if(await this.page.$$(".math")) { - await Promise.all([await this.page.$$("[id*=MathJax][id*=Frame] .math")]) } - - // Close the osano cookie management widget if (await this.osanoAccept.isVisible()) { try { @@ -98,6 +96,10 @@ class ContentPage { await this.page .context() .addCookies([{ name: 'nudge_study_guides_date', value: current_date, url: this.page.url() }]) + + if(await this.closeOverlay.isVisible()) { + await this.closeOverlay.click() + } } async canonical() { diff --git a/playwright/tests/rex-test/rex.behaviorspec.ts b/playwright/tests/rex-test/rex.behaviorspec.ts index e19342feac..ab887f1df7 100644 --- a/playwright/tests/rex-test/rex.behaviorspec.ts +++ b/playwright/tests/rex-test/rex.behaviorspec.ts @@ -683,90 +683,90 @@ test('C543225 canonicals for multi-volumed books point to a single volume', asyn // GIVEN: Open Volume 1 of calculus book const bookPage = new ContentPage(page) - const path1 = '/books/calculus-volume-1/pages/1-1-review-of-functions' - sleep(1) + const path1 = '/books/calculus-volume-1/pages/1-introduction' + await bookPage.open(path1) // THEN: Canonical of Volume 1 points to itself - expect(await bookPage.canonical()).toBe('https://openstax.org/books/calculus-volume-1/pages/1-1-review-of-functions') + expect(await bookPage.canonical()).toBe('https://openstax.org/books/calculus-volume-1/pages/1-introduction') // WHEN: Open EOC page const Toc = new TOC(page) await Toc.pageClick(17) - sleep(1) + // THEN: Canonical of volume 1 EOC page points to itself expect(await bookPage.canonical()).toBe('https://openstax.org/books/calculus-volume-1/pages/2-key-terms') // WHEN: Open EOB nested page await Toc.pageClick(81) - sleep(1) + // THEN: Canonical of volume 1 EOB nested page points to itself expect(await bookPage.canonical()).toBe('https://openstax.org/books/calculus-volume-1/pages/chapter-3') // WHEN: Open EOB page await Toc.pageClick(76) - sleep(1) + // THEN: Canonical of volume 1 EOB page points to itself expect(await bookPage.canonical()).toBe('https://openstax.org/books/calculus-volume-1/pages/a-table-of-integrals') // WHEN: Open Volume 2 of calculus book const path2 = '/books/calculus-volume-2/pages/1-3-the-fundamental-theorem-of-calculus' await bookPage.open(path2) - sleep(10) + // THEN: Canonical of Volume 2 points to volume 1 for shared content expect(await bookPage.canonical()).toBe('https://openstax.org/books/calculus-volume-1/pages/5-3-the-fundamental-theorem-of-calculus') // WHEN: Open volume 2 page that is not shared with previous volume await Toc.pageClick(71) - sleep(1) + // THEN: Canonical of Volume 2 points to self for non-shared content expect(await bookPage.canonical()).toBe('https://openstax.org/books/calculus-volume-2/pages/7-2-calculus-of-parametric-curves') // WHEN: Open EOC page await Toc.pageClick(11) - sleep(1) + // THEN: Canonical of volume 2 EOC page points to itself expect(await bookPage.canonical()).toBe('https://openstax.org/books/calculus-volume-2/pages/1-key-concepts') // WHEN: Open EOB nested page await Toc.pageClick(84) - sleep(1) + // THEN: Canonical of volume 2 EOB nested page points to itself expect(await bookPage.canonical()).toBe('https://openstax.org/books/calculus-volume-2/pages/chapter-3') // WHEN: Open EOB page await Toc.pageClick(81) - sleep(1) + // THEN: Canonical of volume 2 EOB page points to volume 1 - expect(await bookPage.canonical()).toBe('https://openstax.org/books/calculus-volume-1/pages/b-table-of-derivatives') + expect(await bookPage.canonical()).toBe('https://openstax.org/books/calculus-volume-1/pages/c-review-of-pre-calculus') // WHEN: Open volume 3 page that is shared with previous volumes const path3 = '/books/calculus-volume-3/pages/1-1-parametric-equations' await bookPage.open(path3) - sleep(10) + // THEN: Canonical of Volume 3 points to shared content expect(await bookPage.canonical()).toBe('https://openstax.org/books/calculus-volume-2/pages/7-1-parametric-equations') // WHEN: Open volume 3 page that is not shared with previous volume await Toc.pageClick(13) - sleep(1) + // THEN: Canonical of Volume 3 points to self for non-shared content expect(await bookPage.canonical()).toBe('https://openstax.org/books/calculus-volume-3/pages/2-2-vectors-in-three-dimensions') // WHEN: Open EOC page - await Toc.pageClick(11) - sleep(1) + await Toc.pageClick(10) + // THEN: Canonical of volume 3 EOC page points to itself - expect(await bookPage.canonical()).toBe('https://openstax.org/books/calculus-volume-3/pages/1-key-concepts') + expect(await bookPage.canonical()).toBe('https://openstax.org/books/calculus-volume-3/pages/1-review-exercises') // WHEN: Open EOB nested page await Toc.pageClick(84) - sleep(1) + // THEN: Canonical of volume 3 EOB nested page points to itself expect(await bookPage.canonical()).toBe('https://openstax.org/books/calculus-volume-3/pages/chapter-3') // WHEN: Open EOB page await Toc.pageClick(81) - sleep(1) + // THEN: Canonical of volume 2 EOB page points to volume 1 expect(await bookPage.canonical()).toBe('https://openstax.org/books/calculus-volume-1/pages/c-review-of-pre-calculus') }) \ No newline at end of file From 9a8d66aaeb8096e633efba364af35114e5c06da1 Mon Sep 17 00:00:00 2001 From: Malar Natarajan Date: Mon, 22 Jul 2024 08:35:28 -0500 Subject: [PATCH 07/11] sleep --- playwright/src/fixtures/content.page.ts | 5 +++-- playwright/tests/rex-test/rex.behaviorspec.ts | 2 ++ 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/playwright/src/fixtures/content.page.ts b/playwright/src/fixtures/content.page.ts index 4a1c17f553..043d22000c 100644 --- a/playwright/src/fixtures/content.page.ts +++ b/playwright/src/fixtures/content.page.ts @@ -104,8 +104,9 @@ class ContentPage { async canonical() { // Return canonical link of the current page - let canonicalPageSelector = await this.page.$('[rel="canonical"]') - // sleep(4) + const canonicalPageSelector = await this.page.$('[rel="canonical"]') + + sleep(1) const canonicalPage = await canonicalPageSelector.evaluate((e) => e.getAttribute('href')) return canonicalPage } diff --git a/playwright/tests/rex-test/rex.behaviorspec.ts b/playwright/tests/rex-test/rex.behaviorspec.ts index ab887f1df7..d0191e4ddd 100644 --- a/playwright/tests/rex-test/rex.behaviorspec.ts +++ b/playwright/tests/rex-test/rex.behaviorspec.ts @@ -711,6 +711,7 @@ test('C543225 canonicals for multi-volumed books point to a single volume', asyn // WHEN: Open Volume 2 of calculus book const path2 = '/books/calculus-volume-2/pages/1-3-the-fundamental-theorem-of-calculus' await bookPage.open(path2) + sleep(3) // THEN: Canonical of Volume 2 points to volume 1 for shared content expect(await bookPage.canonical()).toBe('https://openstax.org/books/calculus-volume-1/pages/5-3-the-fundamental-theorem-of-calculus') @@ -742,6 +743,7 @@ test('C543225 canonicals for multi-volumed books point to a single volume', asyn // WHEN: Open volume 3 page that is shared with previous volumes const path3 = '/books/calculus-volume-3/pages/1-1-parametric-equations' await bookPage.open(path3) + sleep(3) // THEN: Canonical of Volume 3 points to shared content expect(await bookPage.canonical()).toBe('https://openstax.org/books/calculus-volume-2/pages/7-1-parametric-equations') From c99fe56c96b6de01eeceec9e72387e3e44bdfa92 Mon Sep 17 00:00:00 2001 From: Malar Natarajan Date: Thu, 25 Jul 2024 14:05:02 -0500 Subject: [PATCH 08/11] remove playwright changes --- playwright/src/fixtures/content.page.ts | 18 +--- playwright/tests/rex-test/rex.behaviorspec.ts | 98 ------------------- 2 files changed, 2 insertions(+), 114 deletions(-) diff --git a/playwright/src/fixtures/content.page.ts b/playwright/src/fixtures/content.page.ts index 043d22000c..191bfd2dff 100644 --- a/playwright/src/fixtures/content.page.ts +++ b/playwright/src/fixtures/content.page.ts @@ -1,6 +1,6 @@ // Content page locators and functions import { Locator, Page } from 'playwright' -import { MobileNavigation, sleep } from '../utilities/utilities' +import { MobileNavigation } from '../utilities/utilities' class ContentPage { colorlocator: any @@ -33,8 +33,6 @@ class ContentPage { osanoManageButton: Locator osanoAccept: Locator osanoDialog: Locator - mathLocator: Locator - closeOverlay: Locator constructor(page: Page) { this.page = page @@ -61,18 +59,12 @@ class ContentPage { this.textarea = this.page.locator('textarea[class*="TextArea"]') this.osanoCloseButton = this.page.locator('button[class*="osano-cm-dialog__close"]') this.osanoAccept = this.page.locator('button[class*="type_accept"]') - this.mathLocator = this.page.locator(".math") - this.closeOverlay = this.page.locator('[aria-label="close overlay"]') } async open(path: string) { // Open a Rex page with base url await this.page.goto(path) - if(await this.page.$$(".math")) { - await Promise.all([await this.page.$$("[id*=MathJax][id*=Frame] .math")]) - } - // Close the osano cookie management widget if (await this.osanoAccept.isVisible()) { try { @@ -96,17 +88,11 @@ class ContentPage { await this.page .context() .addCookies([{ name: 'nudge_study_guides_date', value: current_date, url: this.page.url() }]) - - if(await this.closeOverlay.isVisible()) { - await this.closeOverlay.click() - } } async canonical() { // Return canonical link of the current page - const canonicalPageSelector = await this.page.$('[rel="canonical"]') - - sleep(1) + let canonicalPageSelector = await this.page.$('[rel="canonical"]') const canonicalPage = await canonicalPageSelector.evaluate((e) => e.getAttribute('href')) return canonicalPage } diff --git a/playwright/tests/rex-test/rex.behaviorspec.ts b/playwright/tests/rex-test/rex.behaviorspec.ts index d0191e4ddd..54d9e5b5b2 100644 --- a/playwright/tests/rex-test/rex.behaviorspec.ts +++ b/playwright/tests/rex-test/rex.behaviorspec.ts @@ -673,102 +673,4 @@ test('C543225 canonicals for old editions point to the latest edition', async ({ await Toc.pageClick(241) // THEN: Canonical page points to latest edition of the original content expect(await bookPage.canonical()).toBe('https://openstax.org/books/principles-economics-3e/pages/d-the-expenditure-output-model') -}) - - -test('C543225 canonicals for multi-volumed books point to a single volume', async ({ page, isMobile, browserName }) => { - test.skip(isMobile as boolean, 'test only desktop resolution') - test.skip(browserName == 'webkit', 'test only chrome') - test.skip(browserName == 'firefox', 'test only chrome') - - // GIVEN: Open Volume 1 of calculus book - const bookPage = new ContentPage(page) - const path1 = '/books/calculus-volume-1/pages/1-introduction' - - await bookPage.open(path1) - // THEN: Canonical of Volume 1 points to itself - expect(await bookPage.canonical()).toBe('https://openstax.org/books/calculus-volume-1/pages/1-introduction') - - // WHEN: Open EOC page - const Toc = new TOC(page) - await Toc.pageClick(17) - - // THEN: Canonical of volume 1 EOC page points to itself - expect(await bookPage.canonical()).toBe('https://openstax.org/books/calculus-volume-1/pages/2-key-terms') - - // WHEN: Open EOB nested page - await Toc.pageClick(81) - - // THEN: Canonical of volume 1 EOB nested page points to itself - expect(await bookPage.canonical()).toBe('https://openstax.org/books/calculus-volume-1/pages/chapter-3') - - // WHEN: Open EOB page - await Toc.pageClick(76) - - // THEN: Canonical of volume 1 EOB page points to itself - expect(await bookPage.canonical()).toBe('https://openstax.org/books/calculus-volume-1/pages/a-table-of-integrals') - - // WHEN: Open Volume 2 of calculus book - const path2 = '/books/calculus-volume-2/pages/1-3-the-fundamental-theorem-of-calculus' - await bookPage.open(path2) - sleep(3) - - // THEN: Canonical of Volume 2 points to volume 1 for shared content - expect(await bookPage.canonical()).toBe('https://openstax.org/books/calculus-volume-1/pages/5-3-the-fundamental-theorem-of-calculus') - - // WHEN: Open volume 2 page that is not shared with previous volume - await Toc.pageClick(71) - - // THEN: Canonical of Volume 2 points to self for non-shared content - expect(await bookPage.canonical()).toBe('https://openstax.org/books/calculus-volume-2/pages/7-2-calculus-of-parametric-curves') - - // WHEN: Open EOC page - await Toc.pageClick(11) - - // THEN: Canonical of volume 2 EOC page points to itself - expect(await bookPage.canonical()).toBe('https://openstax.org/books/calculus-volume-2/pages/1-key-concepts') - - // WHEN: Open EOB nested page - await Toc.pageClick(84) - - // THEN: Canonical of volume 2 EOB nested page points to itself - expect(await bookPage.canonical()).toBe('https://openstax.org/books/calculus-volume-2/pages/chapter-3') - - // WHEN: Open EOB page - await Toc.pageClick(81) - - // THEN: Canonical of volume 2 EOB page points to volume 1 - expect(await bookPage.canonical()).toBe('https://openstax.org/books/calculus-volume-1/pages/c-review-of-pre-calculus') - - // WHEN: Open volume 3 page that is shared with previous volumes - const path3 = '/books/calculus-volume-3/pages/1-1-parametric-equations' - await bookPage.open(path3) - sleep(3) - - // THEN: Canonical of Volume 3 points to shared content - expect(await bookPage.canonical()).toBe('https://openstax.org/books/calculus-volume-2/pages/7-1-parametric-equations') - - // WHEN: Open volume 3 page that is not shared with previous volume - await Toc.pageClick(13) - - // THEN: Canonical of Volume 3 points to self for non-shared content - expect(await bookPage.canonical()).toBe('https://openstax.org/books/calculus-volume-3/pages/2-2-vectors-in-three-dimensions') - - // WHEN: Open EOC page - await Toc.pageClick(10) - - // THEN: Canonical of volume 3 EOC page points to itself - expect(await bookPage.canonical()).toBe('https://openstax.org/books/calculus-volume-3/pages/1-review-exercises') - - // WHEN: Open EOB nested page - await Toc.pageClick(84) - - // THEN: Canonical of volume 3 EOB nested page points to itself - expect(await bookPage.canonical()).toBe('https://openstax.org/books/calculus-volume-3/pages/chapter-3') - - // WHEN: Open EOB page - await Toc.pageClick(81) - - // THEN: Canonical of volume 2 EOB page points to volume 1 - expect(await bookPage.canonical()).toBe('https://openstax.org/books/calculus-volume-1/pages/c-review-of-pre-calculus') }) \ No newline at end of file From cd54755157e0e07465b0aa28f6359a9ccd241023 Mon Sep 17 00:00:00 2001 From: Malar Natarajan Date: Thu, 25 Jul 2024 14:07:15 -0500 Subject: [PATCH 09/11] remove space --- playwright/tests/rex-test/rex.behaviorspec.ts | 1 + 1 file changed, 1 insertion(+) diff --git a/playwright/tests/rex-test/rex.behaviorspec.ts b/playwright/tests/rex-test/rex.behaviorspec.ts index 54d9e5b5b2..966752a10c 100644 --- a/playwright/tests/rex-test/rex.behaviorspec.ts +++ b/playwright/tests/rex-test/rex.behaviorspec.ts @@ -673,4 +673,5 @@ test('C543225 canonicals for old editions point to the latest edition', async ({ await Toc.pageClick(241) // THEN: Canonical page points to latest edition of the original content expect(await bookPage.canonical()).toBe('https://openstax.org/books/principles-economics-3e/pages/d-the-expenditure-output-model') + }) \ No newline at end of file From cc21ab91f04bc2097bf4423d9a9da1d7e68d6416 Mon Sep 17 00:00:00 2001 From: Malar Natarajan Date: Tue, 13 Aug 2024 15:52:43 -0500 Subject: [PATCH 10/11] update search --- playwright/tests/rex-test/rex.behaviorspec.ts | 1 - pytest-selenium/pages/base.py | 3 +++ pytest-selenium/utils/books.json | 12 ++++++------ 3 files changed, 9 insertions(+), 7 deletions(-) diff --git a/playwright/tests/rex-test/rex.behaviorspec.ts b/playwright/tests/rex-test/rex.behaviorspec.ts index 966752a10c..54d9e5b5b2 100644 --- a/playwright/tests/rex-test/rex.behaviorspec.ts +++ b/playwright/tests/rex-test/rex.behaviorspec.ts @@ -673,5 +673,4 @@ test('C543225 canonicals for old editions point to the latest edition', async ({ await Toc.pageClick(241) // THEN: Canonical page points to latest edition of the original content expect(await bookPage.canonical()).toBe('https://openstax.org/books/principles-economics-3e/pages/d-the-expenditure-output-model') - }) \ No newline at end of file diff --git a/pytest-selenium/pages/base.py b/pytest-selenium/pages/base.py index 27b9e719cd..b45b494b33 100644 --- a/pytest-selenium/pages/base.py +++ b/pytest-selenium/pages/base.py @@ -62,6 +62,9 @@ def open(self): self.driver.add_cookie({"name": "nudge_study_guides_counter", "value": "1"}) self.driver.add_cookie({"name": "nudge_study_guides_page_counter", "value": "1"}) self.driver.add_cookie({"name": "nudge_study_guides_date", "value": current_date}) + self.driver.add_cookie({"name": "content-warning-545", "value": "true"}) + self.driver.add_cookie({"name": "content-warning-548", "value": "true"}) + self.driver.add_cookie({"name": "content-warning-549", "value": "true"}) self.driver.add_cookie({"name": "ANALYTICS_OPT_OUT", "value": "1"}) return self diff --git a/pytest-selenium/utils/books.json b/pytest-selenium/utils/books.json index 0333cd2015..e4cdaccd6e 100644 --- a/pytest-selenium/utils/books.json +++ b/pytest-selenium/utils/books.json @@ -50,7 +50,7 @@ "biology-2e": { "default_page": "1-introduction", "search_term": "evolution theory", - "chapter_search_results_total": 341, + "chapter_search_results_total": 344, "rkt_search_results_total": 0 }, "biology-ap-courses": { @@ -140,7 +140,7 @@ "calculus-volume-3": { "default_page": "1-introduction", "search_term": "zero vector", - "chapter_search_results_total": 9, + "chapter_search_results_total": 10, "rkt_search_results_total": 1 }, "college-success": { @@ -416,7 +416,7 @@ "introductory-statistics-2e": { "default_page": "1-introduction", "search_term": "Student's t-Distribution", - "chapter_search_results_total": 43, + "chapter_search_results_total": 45, "rkt_search_results_total": 2 }, "introductory-business-statistics-2e": { @@ -459,7 +459,7 @@ "default_page": "1-introduction", "search_term": "population health", "chapter_search_results_total": 3689, - "rkt_search_results_total": 11 + "rkt_search_results_total": 12 }, "nutrition": { "default_page": "1-introduction", @@ -471,9 +471,9 @@ "default_page": "1-introduction", "search_term": "mental health", "chapter_search_results_total": 2674, - "rkt_search_results_total": 4 + "rkt_search_results_total": 5 }, - "maternal-newborn": { + "maternal-newborn-nursing": { "default_page": "1-introduction", "search_term": "newborn babies", "chapter_search_results_total": 446, From 2adc2ffaa7a55bc91f5831cc04aefd37631f87b4 Mon Sep 17 00:00:00 2001 From: Malar Natarajan Date: Thu, 15 Aug 2024 16:50:26 -0500 Subject: [PATCH 11/11] more updates to selectors --- pytest-selenium/pages/base.py | 6 ++---- pytest-selenium/regions/search_sidebar.py | 2 +- pytest-selenium/tests/test_search.py | 4 +--- 3 files changed, 4 insertions(+), 8 deletions(-) diff --git a/pytest-selenium/pages/base.py b/pytest-selenium/pages/base.py index b45b494b33..262618d046 100644 --- a/pytest-selenium/pages/base.py +++ b/pytest-selenium/pages/base.py @@ -27,11 +27,9 @@ BOUNDING_RECTANGLE = "return arguments[0].getBoundingClientRect();" -XPATH_SEARCH = "//span[contains(text(),'{term}') and contains(@class,'search-highlight first text last focus')]" +XPATH_SEARCH = "//mark[contains(text(), '{term}') and (@aria-current='true') and (@class='search-highlight first text last')]" # If search term is inside a block of search highlight use this XPATH -XPATH_SEARCH_BLOCK = ( - "//span[contains(@class,'search-highlight text last focus') and contains(text(),'{term}')]" -) +XPATH_SEARCH_BLOCK = "//mark[contains(text(), '{term}') and (@aria-current='true') and (@class='search-highlight text last')]" class Page(pypom.Page): diff --git a/pytest-selenium/regions/search_sidebar.py b/pytest-selenium/regions/search_sidebar.py index a59cec46bb..39943926ed 100644 --- a/pytest-selenium/regions/search_sidebar.py +++ b/pytest-selenium/regions/search_sidebar.py @@ -23,7 +23,7 @@ class SearchSidebar(Region): _search_result_locator = (By.CSS_SELECTOR, "[data-testid$=result]") _search_results_sidebar_locator = ( By.XPATH, - "//div[@data-testid = 'search-results-sidebar']/div[2]", + "//div[@data-testid = 'search-results-sidebar']/nav", ) # fmt: off diff --git a/pytest-selenium/tests/test_search.py b/pytest-selenium/tests/test_search.py index 2bc30e8f31..3123dfc279 100644 --- a/pytest-selenium/tests/test_search.py +++ b/pytest-selenium/tests/test_search.py @@ -525,9 +525,7 @@ def test_highlight_entire_search_element(selenium, base_url, book_slug, page_slu book.assert_search_term_is_highlighted_in_content_page(search_term) # THEN: Entire search element is highlighted in content page - xpath_search_block = ( - "//span[contains(@class,'search-highlight text last focus')][contains(text(),'{term}')]" - ) + xpath_search_block = "//mark[contains(text(), '{term}') and (@aria-current='true') and (@class='search-highlight text last')]" focussed_search_term = book.find_elements(By.XPATH, xpath_search_block.format(term=search_term)) try: