-
Notifications
You must be signed in to change notification settings - Fork 25
ME-17952: test if video is playing on main page #733
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
b2e0839
vp test: test if video is playing on main page
ShayLevi 4a1fdaf
Merge branch 'edge' into me-17952-test-video-play-main-page
ShayLevi 34df815
vp test: rename playVideo to clickPlay
ShayLevi f990e9b
Merge remote-tracking branch 'origin/me-17952-test-video-play-main-pa…
ShayLevi File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,35 @@ | ||
| import { Page } from '@playwright/test'; | ||
|
|
||
| /** | ||
| * Video component | ||
| */ | ||
| export class VideoComponent { | ||
| private page: Page; | ||
| private readonly videoSelector: string; | ||
|
|
||
| constructor(page: Page, videoSelector: string) { | ||
| this.page = page; | ||
| this.videoSelector = videoSelector; | ||
| } | ||
|
|
||
| /** | ||
| * Click the play button if necessary in case video is not autoplay | ||
| */ | ||
| public async clickPlay(): Promise<void> { | ||
| const videoPlayButtonLocator = this.page.locator(`${this.videoSelector}/following-sibling::button[contains(@class, "vjs-big-play-button")]`); | ||
| // Click the play button to start the video | ||
| return videoPlayButtonLocator.click(); | ||
| } | ||
|
|
||
| /** | ||
| * Checks if video element is paused | ||
| */ | ||
| public async isPaused(): Promise<boolean> { | ||
| return this.page.evaluate((selector: string) => { | ||
| console.log('Evaluating selector in browser context:', selector); // Logs selector in browser context | ||
| const xpathResult = document.evaluate(selector, document, null, XPathResult.FIRST_ORDERED_NODE_TYPE, null); | ||
| const video = xpathResult.singleNodeValue as HTMLVideoElement | null; | ||
| return video.paused; | ||
| }, this.videoSelector); | ||
| } | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,18 @@ | ||
| import { vpTest } from '../fixtures/vpTest'; | ||
| import { expect, test } from '@playwright/test'; | ||
| import { waitForPageToLoadWithTimeout } from '../src/helpers/waitForPageToLoadWithTimeout'; | ||
|
|
||
| /** | ||
| * Testing if video on main page is playing by checking that is pause return false. | ||
| * The video in the main page is not configured as autoplay so first need to click on play button. | ||
| */ | ||
| vpTest(`Test if video on main page is playing`, async ({ page, vpExamples }) => { | ||
| await test.step('Click on play button to play video', async () => { | ||
| //making sure the page is loaded | ||
| await waitForPageToLoadWithTimeout(page, 5000); | ||
| return vpExamples.videoMainPage.clickPlay(); | ||
| }); | ||
| await test.step('Validating that the video is playing (in case isPause is false)', async () => { | ||
| expect(await vpExamples.videoMainPage.isPaused()).toEqual(false); | ||
| }); | ||
| }); | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Test if video on main page can play as expectedsince it is not an autoplay i think such a msg is more clearThere was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sorry was in my drafts so when i sent it the PR was already merged...anyway it is was a minor suggestion and can be done later.