Skip to content

Playwright is a framework for Web Testing and Automation. It allows testing Chromium, Firefox and WebKit with a single API.

test: add test for playing audio (#10890)

Max Schmitt40bd15617352
diff --git a/tests/assets/example.mp3 b/tests/assets/example.mp3
new file mode 100644
index 0000000000..f7d3831e55
Binary files /dev/null and b/tests/assets/example.mp3 differ
diff --git a/tests/capabilities.spec.ts b/tests/capabilities.spec.ts
index bab2461e41..97c9246de6 100644
--- a/tests/capabilities.spec.ts
+++ b/tests/capabilities.spec.ts
@@ -83,6 +83,19 @@ it('should play video', async ({ page, asset, browserName, platform }) => {
await page.$eval('video', v => v.pause());
});
+it('should play audio', async ({ page, server, browserName, platform }) => {
+ it.fixme(browserName === 'firefox' && platform === 'win32', 'https://github.com/microsoft/playwright/issues/10887');
+ it.fixme(browserName === 'firefox' && platform === 'linux', 'https://github.com/microsoft/playwright/issues/10887');
+ it.fixme(browserName === 'webkit' && platform === 'win32', 'https://github.com/microsoft/playwright/issues/10892');
+ it.fixme(browserName === 'webkit' && platform === 'darwin', 'https://github.com/microsoft/playwright/issues/10892');
+ await page.goto(server.EMPTY_PAGE);
+ await page.setContent(`<audio src="${server.PREFIX}/example.mp3"></audio>`);
+ await page.$eval('audio', e => e.play());
+ await page.waitForTimeout(1000);
+ await page.$eval('audio', e => e.pause());
+ expect(await page.$eval('audio', e => e.currentTime)).toBeGreaterThan(0.5);
+});
+
it('should support webgl', async ({ page, browserName, headless }) => {
it.fixme(browserName === 'firefox' && headless);