Playwright is a framework for Web Testing and Automation. It allows testing Chromium, Firefox and WebKit with a single API.
TypeScript automationchromechromiume2e-testingelectronend-to-end-testingfirefoxjavascriptplaywrighttesttest-automationtestingtesting-toolswebwebkit
test: add a test for focused input screenshot (#5060)
Dmitry Gozman018727db8ef8
diff --git a/test/__snapshots__/headful/focused-input-should-produce-the-same-screenshot/chromium-darwin/focused-input.png b/test/__snapshots__/headful/focused-input-should-produce-the-same-screenshot/chromium-darwin/focused-input.pngnew file mode 100644index 0000000000..327fce8537Binary files /dev/null and b/test/__snapshots__/headful/focused-input-should-produce-the-same-screenshot/chromium-darwin/focused-input.png differdiff --git a/test/__snapshots__/headful/focused-input-should-produce-the-same-screenshot/chromium-linux/focused-input.png b/test/__snapshots__/headful/focused-input-should-produce-the-same-screenshot/chromium-linux/focused-input.pngnew file mode 100644index 0000000000..ca5082b3bfBinary files /dev/null and b/test/__snapshots__/headful/focused-input-should-produce-the-same-screenshot/chromium-linux/focused-input.png differdiff --git a/test/__snapshots__/headful/focused-input-should-produce-the-same-screenshot/chromium-win32/focused-input.png b/test/__snapshots__/headful/focused-input-should-produce-the-same-screenshot/chromium-win32/focused-input.pngnew file mode 100644index 0000000000..ca5082b3bfBinary files /dev/null and b/test/__snapshots__/headful/focused-input-should-produce-the-same-screenshot/chromium-win32/focused-input.png differdiff --git a/test/__snapshots__/headful/focused-input-should-produce-the-same-screenshot/firefox-darwin/focused-input.png b/test/__snapshots__/headful/focused-input-should-produce-the-same-screenshot/firefox-darwin/focused-input.pngnew file mode 100644index 0000000000..ee6ca12b5cBinary files /dev/null and b/test/__snapshots__/headful/focused-input-should-produce-the-same-screenshot/firefox-darwin/focused-input.png differdiff --git a/test/__snapshots__/headful/focused-input-should-produce-the-same-screenshot/firefox-linux/focused-input.png b/test/__snapshots__/headful/focused-input-should-produce-the-same-screenshot/firefox-linux/focused-input.pngnew file mode 100644index 0000000000..bcff3cba33Binary files /dev/null and b/test/__snapshots__/headful/focused-input-should-produce-the-same-screenshot/firefox-linux/focused-input.png differdiff --git a/test/__snapshots__/headful/focused-input-should-produce-the-same-screenshot/firefox-win32/focused-input.png b/test/__snapshots__/headful/focused-input-should-produce-the-same-screenshot/firefox-win32/focused-input.pngnew file mode 100644index 0000000000..ea65d7a79fBinary files /dev/null and b/test/__snapshots__/headful/focused-input-should-produce-the-same-screenshot/firefox-win32/focused-input.png differdiff --git a/test/__snapshots__/headful/focused-input-should-produce-the-same-screenshot/webkit-darwin/focused-input.png b/test/__snapshots__/headful/focused-input-should-produce-the-same-screenshot/webkit-darwin/focused-input.pngnew file mode 100644index 0000000000..0526762bf9Binary files /dev/null and b/test/__snapshots__/headful/focused-input-should-produce-the-same-screenshot/webkit-darwin/focused-input.png differdiff --git a/test/__snapshots__/headful/focused-input-should-produce-the-same-screenshot/webkit-linux/focused-input.png b/test/__snapshots__/headful/focused-input-should-produce-the-same-screenshot/webkit-linux/focused-input.pngnew file mode 100644index 0000000000..f76edad846Binary files /dev/null and b/test/__snapshots__/headful/focused-input-should-produce-the-same-screenshot/webkit-linux/focused-input.png differdiff --git a/test/__snapshots__/headful/focused-input-should-produce-the-same-screenshot/webkit-win32/focused-input.png b/test/__snapshots__/headful/focused-input-should-produce-the-same-screenshot/webkit-win32/focused-input.pngnew file mode 100644index 0000000000..c587794530Binary files /dev/null and b/test/__snapshots__/headful/focused-input-should-produce-the-same-screenshot/webkit-win32/focused-input.png differdiff --git a/test/headful.spec.ts b/test/headful.spec.tsindex 120fee4aa3..3842d467e3 100644--- a/test/headful.spec.ts+++ b/test/headful.spec.ts@@ -14,7 +14,7 @@* limitations under the License.*/-import { it, expect } from './fixtures';+import { it, expect, folio } from './fixtures';it('should have default url when launching browser', async ({browserType, browserOptions, createUserDataDir}) => {const browserContext = await browserType.launchPersistentContext(await createUserDataDir(), {...browserOptions, headless: false });@@ -168,3 +168,31 @@ it('Page.bringToFront should work', async ({browserType, browserOptions}) => {);await browser.close();});++const fixtures = folio.extend();+fixtures.testParametersPathSegment.override(async ({ browserName, platform }, run) => {+ await run(browserName + '-' + platform);+});+fixtures.build().it('focused input should produce the same screenshot', (test, { browserName, platform }) => {+ test.fail(browserName === 'firefox' && platform === 'darwin', 'headless has thinner outline');+ test.fail(browserName === 'firefox' && platform === 'linux', 'headless has no outline');+ test.skip(browserName === 'webkit' && platform === 'linux', 'gtk vs wpe');+ test.fail(browserName === 'chromium', 'Different outline color');+}, async ({browserType, browserOptions}) => {+ const headful = await browserType.launch({...browserOptions, headless: false });+ const headfulPage = await headful.newPage();+ await headfulPage.setContent('<input>');+ await headfulPage.focus('input');+ const headfulScreenshot = await headfulPage.screenshot();+ await headful.close();++ const headless = await browserType.launch({...browserOptions, headless: true });+ const headlessPage = await headless.newPage();+ await headlessPage.setContent('<input>');+ await headlessPage.focus('input');+ const headlessScreenshot = await headlessPage.screenshot();+ await headless.close();++ expect(headfulScreenshot).toMatchSnapshot('focused-input.png');+ expect(headlessScreenshot).toMatchSnapshot('focused-input.png');+});