Skip to content

Commit ab2135b

Browse files
committed
Use postMessage to try to avoid timeout
1 parent e279a34 commit ab2135b

2 files changed

Lines changed: 8 additions & 8 deletions

File tree

features/support/step_definitions/youtube_steps.js

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4,12 +4,12 @@ When("I wait for the YouTube iframe API to load", async function () {
44
await this.page.waitForFunction(() => typeof YT !== 'undefined' && YT.loaded);
55
});
66

7-
When("I click on YouTube video {string}", async function (videoId) {
8-
const elementHandle = await this.page.$('iframe[id="' + videoId + '"]');
9-
const frame = await elementHandle.contentFrame();
10-
11-
await frame.waitForSelector('#player');
12-
await frame.click('#player');
7+
When("I play YouTube video {string}", async function (videoId) {
8+
await this.page.evaluate((id) => {
9+
const iframe = document.querySelector('iframe[id="' + id + '"]');
10+
const origin = new URL(iframe.src).origin;
11+
iframe.contentWindow.postMessage(JSON.stringify({ event: 'command', func: 'playVideo', args: [] }), origin);
12+
}, videoId);
1313
});
1414

1515
const mockYouTubeScript = `

features/youtube_tracking_integration.feature

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,8 @@ Feature: DAP successfully integrates with the YouTube iframe API
1111
Scenario:
1212
When I load the test page "youtube.html"
1313
And I wait for the YouTube iframe API to load
14-
And I click on YouTube video "LcvYjkCBY28"
15-
And I wait 10 seconds
14+
And I play YouTube video "LcvYjkCBY28"
15+
And I wait 5 seconds
1616
Then a "video_start" event is sent to DAP with parameters
1717
| video_provider | youtube |
1818
| video_id | LcvYjkCBY28 |

0 commit comments

Comments
 (0)