From 829532cfad2d70b87632e5ddccaccb867abc3f3c Mon Sep 17 00:00:00 2001 From: shaylevi Date: Tue, 10 Dec 2024 10:15:37 +0200 Subject: [PATCH 1/2] vp test: test if videos on audio player page are playing --- test/e2e/specs/audioPlayerPage.spec.ts | 29 ++++++++++++++++++++++++++ test/e2e/src/pom/PageManager.ts | 8 +++++++ test/e2e/src/pom/audioPlayerPage.ts | 18 ++++++++++++++++ 3 files changed, 55 insertions(+) create mode 100644 test/e2e/specs/audioPlayerPage.spec.ts create mode 100644 test/e2e/src/pom/audioPlayerPage.ts diff --git a/test/e2e/specs/audioPlayerPage.spec.ts b/test/e2e/specs/audioPlayerPage.spec.ts new file mode 100644 index 00000000..0d83e059 --- /dev/null +++ b/test/e2e/specs/audioPlayerPage.spec.ts @@ -0,0 +1,29 @@ +import { vpTest } from '../fixtures/vpTest'; +import { expect, test } from '@playwright/test'; +import { waitForPageToLoadWithTimeout } from '../src/helpers/waitForPageToLoadWithTimeout'; +import { getLinkByName } from '../testData/pageLinksData'; +import { ExampleLinkName } from '../testData/ExampleLinkNames'; + +// Link to audio player page +const link = getLinkByName(ExampleLinkName.AudioPlayer); +/** + * Testing if videos on audio player page are playing by checking that is pause return false. + */ +vpTest(`Test if 2 videos on audio player page are playing as expected`, async ({ page, pomPages }) => { + await test.step('Navigate to audio player page by clicking on link', async () => { + await pomPages.mainPage.clickLinkByName(link.name); + await waitForPageToLoadWithTimeout(page, 5000); + }); + await test.step('Click on play button of first video player to play video', async () => { + return pomPages.audioPlayerPage.audioPlayerFirstVideoComponent.clickPlay(); + }); + await test.step('Validating that the first video is playing (in case isPause is false)', async () => { + expect(await pomPages.audioPlayerPage.audioPlayerFirstVideoComponent.isPaused()).toEqual(false); + }); + await test.step('Click on play button of second video player to play video', async () => { + return pomPages.audioPlayerPage.audioPlayerSecondVideoComponent.clickPlay(); + }); + await test.step('Validating that the second video is playing (in case isPause is false)', async () => { + expect(await pomPages.audioPlayerPage.audioPlayerSecondVideoComponent.isPaused()).toEqual(false); + }); +}); \ No newline at end of file diff --git a/test/e2e/src/pom/PageManager.ts b/test/e2e/src/pom/PageManager.ts index b496aabb..1bc9e469 100644 --- a/test/e2e/src/pom/PageManager.ts +++ b/test/e2e/src/pom/PageManager.ts @@ -4,6 +4,7 @@ import { BasePage } from './BasePage'; import { MainPage } from './mainPage'; import { AnalyticsPage } from './analyticsPage'; import { ApiAndEventsPage } from './apiAndEventsPage'; +import { AudioPlayerPage } from './audioPlayerPage'; /** * Page manager, @@ -56,5 +57,12 @@ export class PageManager { public get apiAndEventsPage(): ApiAndEventsPage { return this.getPage(ApiAndEventsPage); } + + /** + * Returns audio player page object + */ + public get audioPlayerPage(): AudioPlayerPage { + return this.getPage(AudioPlayerPage); + } } export default PageManager; diff --git a/test/e2e/src/pom/audioPlayerPage.ts b/test/e2e/src/pom/audioPlayerPage.ts new file mode 100644 index 00000000..fc3cda3b --- /dev/null +++ b/test/e2e/src/pom/audioPlayerPage.ts @@ -0,0 +1,18 @@ +import { Page } from '@playwright/test'; +import { VideoComponent } from '../../components/videoComponent'; +import { BasePage } from './BasePage'; +const AUDIO_PLAYER_FIRST_VIDEO_SELECTOR = '//*[@id="player_html5_api"]'; +const AUDIO_PLAYER_SECOND_VIDEO_SELECTOR = '//*[@id="player-t_html5_api"]'; +/** + * Video player examples audio player page object + */ +export class AudioPlayerPage extends BasePage { + public audioPlayerFirstVideoComponent: VideoComponent; + public audioPlayerSecondVideoComponent: VideoComponent; + + constructor(page: Page) { + super(page); + this.audioPlayerFirstVideoComponent = new VideoComponent(page, AUDIO_PLAYER_FIRST_VIDEO_SELECTOR); + this.audioPlayerSecondVideoComponent = new VideoComponent(page, AUDIO_PLAYER_SECOND_VIDEO_SELECTOR); + } +} \ No newline at end of file From 307aaa4f575a41e5e8b0827521b091830c4a8292 Mon Sep 17 00:00:00 2001 From: shaylevi Date: Tue, 10 Dec 2024 11:14:28 +0200 Subject: [PATCH 2/2] vp test: modify selectors and components names based on review comment --- test/e2e/specs/audioPlayerPage.spec.ts | 8 ++++---- test/e2e/src/pom/audioPlayerPage.ts | 12 ++++++------ 2 files changed, 10 insertions(+), 10 deletions(-) diff --git a/test/e2e/specs/audioPlayerPage.spec.ts b/test/e2e/specs/audioPlayerPage.spec.ts index 0d83e059..d5eb9545 100644 --- a/test/e2e/specs/audioPlayerPage.spec.ts +++ b/test/e2e/specs/audioPlayerPage.spec.ts @@ -15,15 +15,15 @@ vpTest(`Test if 2 videos on audio player page are playing as expected`, async ({ await waitForPageToLoadWithTimeout(page, 5000); }); await test.step('Click on play button of first video player to play video', async () => { - return pomPages.audioPlayerPage.audioPlayerFirstVideoComponent.clickPlay(); + return pomPages.audioPlayerPage.audioPlayerVideoComponent.clickPlay(); }); await test.step('Validating that the first video is playing (in case isPause is false)', async () => { - expect(await pomPages.audioPlayerPage.audioPlayerFirstVideoComponent.isPaused()).toEqual(false); + expect(await pomPages.audioPlayerPage.audioPlayerVideoComponent.isPaused()).toEqual(false); }); await test.step('Click on play button of second video player to play video', async () => { - return pomPages.audioPlayerPage.audioPlayerSecondVideoComponent.clickPlay(); + return pomPages.audioPlayerPage.audioPlayerWithTransformationVideoComponent.clickPlay(); }); await test.step('Validating that the second video is playing (in case isPause is false)', async () => { - expect(await pomPages.audioPlayerPage.audioPlayerSecondVideoComponent.isPaused()).toEqual(false); + expect(await pomPages.audioPlayerPage.audioPlayerWithTransformationVideoComponent.isPaused()).toEqual(false); }); }); \ No newline at end of file diff --git a/test/e2e/src/pom/audioPlayerPage.ts b/test/e2e/src/pom/audioPlayerPage.ts index fc3cda3b..132003a5 100644 --- a/test/e2e/src/pom/audioPlayerPage.ts +++ b/test/e2e/src/pom/audioPlayerPage.ts @@ -1,18 +1,18 @@ import { Page } from '@playwright/test'; import { VideoComponent } from '../../components/videoComponent'; import { BasePage } from './BasePage'; -const AUDIO_PLAYER_FIRST_VIDEO_SELECTOR = '//*[@id="player_html5_api"]'; -const AUDIO_PLAYER_SECOND_VIDEO_SELECTOR = '//*[@id="player-t_html5_api"]'; +const AUDIO_PLAYER_VIDEO_SELECTOR = '//*[@id="player_html5_api"]'; +const AUDIO_PLAYER_WITH_TRANSFORMATION_VIDEO_SELECTOR = '//*[@id="player-t_html5_api"]'; /** * Video player examples audio player page object */ export class AudioPlayerPage extends BasePage { - public audioPlayerFirstVideoComponent: VideoComponent; - public audioPlayerSecondVideoComponent: VideoComponent; + public audioPlayerVideoComponent: VideoComponent; + public audioPlayerWithTransformationVideoComponent: VideoComponent; constructor(page: Page) { super(page); - this.audioPlayerFirstVideoComponent = new VideoComponent(page, AUDIO_PLAYER_FIRST_VIDEO_SELECTOR); - this.audioPlayerSecondVideoComponent = new VideoComponent(page, AUDIO_PLAYER_SECOND_VIDEO_SELECTOR); + this.audioPlayerVideoComponent = new VideoComponent(page, AUDIO_PLAYER_VIDEO_SELECTOR); + this.audioPlayerWithTransformationVideoComponent = new VideoComponent(page, AUDIO_PLAYER_WITH_TRANSFORMATION_VIDEO_SELECTOR); } } \ No newline at end of file