Skip to content

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

tests: add test for page.focus() in Firefox (#3478)

Max Schmitt59e3326fc021
diff --git a/test/page-basic.spec.ts b/test/page-basic.spec.ts
index f2c6b35ca5..ca52ff6063 100644
--- a/test/page-basic.spec.ts
+++ b/test/page-basic.spec.ts
@@ -142,7 +142,7 @@ it('should fail with error upon disconnect', async({page, server}) => {
expect(error.message).toContain('Page closed');
});
-it('page.ur should work', async({page, server}) => {
+it('page.url should work', async({page, server}) => {
expect(page.url()).toBe('about:blank');
await page.goto(server.EMPTY_PAGE);
expect(page.url()).toBe(server.EMPTY_PAGE);
@@ -242,3 +242,13 @@ it('frame.press should work', async({page, server}) => {
await frame.press('textarea', 'a');
expect(await frame.evaluate(() => document.querySelector('textarea').value)).toBe('a');
});
+
+it.fail(FFOX)('frame.focus should work multiple times', async ({ context, server }) => {
+ const page1 = await context.newPage()
+ const page2 = await context.newPage()
+ for (const page of [page1, page2]) {
+ await page.setContent(`<button id="foo" onfocus="window.gotFocus=true"></button>`)
+ await page.focus("#foo")
+ expect(await page.evaluate(() => !!window['gotFocus'])).toBe(true)
+ }
+});