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: update some expectations for headed chromium, unskip tests (#32943)
Dmitry Gozmand98fa5da2fc2
diff --git a/tests/library/browsercontext-credentials.spec.ts b/tests/library/browsercontext-credentials.spec.tsindex cc991e0e5a..7783b65aea 100644--- a/tests/library/browsercontext-credentials.spec.ts+++ b/tests/library/browsercontext-credentials.spec.ts@@ -25,30 +25,30 @@ const it = base.extend<{ isChromiumHeadedLike: boolean }>({});it('should fail without credentials', async ({ browser, server, isChromiumHeadedLike }) => {- it.fail(isChromiumHeadedLike);-server.setAuth('/empty.html', 'user', 'pass');const context = await browser.newContext();const page = await context.newPage();- try {- const response = await page.goto(server.EMPTY_PAGE);- expect(response!.status()).toBe(401);- } finally {- await context.close();- }+ const responseOrError = await page.goto(server.EMPTY_PAGE).catch(e => e);+ if (isChromiumHeadedLike)+ expect(responseOrError.message).toContain('net::ERR_INVALID_AUTH_CREDENTIALS');+ else+ expect(responseOrError.status()).toBe(401);});it('should work with setHTTPCredentials', async ({ browser, server, isChromiumHeadedLike }) => {- it.fail(isChromiumHeadedLike);-server.setAuth('/empty.html', 'user', 'pass');const context = await browser.newContext();const page = await context.newPage();- let response = await page.goto(server.EMPTY_PAGE);- expect(response!.status()).toBe(401);++ let responseOrError = await page.goto(server.EMPTY_PAGE).catch(e => e);+ if (isChromiumHeadedLike)+ expect(responseOrError.message).toContain('net::ERR_INVALID_AUTH_CREDENTIALS');+ else+ expect(responseOrError.status()).toBe(401);+await context.setHTTPCredentials({ username: 'user', password: 'pass' });- response = await page.reload();- expect(response!.status()).toBe(200);+ responseOrError = await page.reload();+ expect(responseOrError.status()).toBe(200);await context.close();});@@ -110,19 +110,20 @@ it('should work with correct credentials and matching origin case insensitive',});it('should fail with correct credentials and mismatching scheme', async ({ browser, server, isChromiumHeadedLike }) => {- it.fail(isChromiumHeadedLike);server.setAuth('/empty.html', 'user', 'pass');const context = await browser.newContext({httpCredentials: { username: 'user', password: 'pass', origin: server.PREFIX.replace('http://', 'https://') }});const page = await context.newPage();- const response = await page.goto(server.EMPTY_PAGE);- expect(response!.status()).toBe(401);+ const responseOrError = await page.goto(server.EMPTY_PAGE).catch(e => e);+ if (isChromiumHeadedLike)+ expect(responseOrError.message).toContain('net::ERR_INVALID_AUTH_CREDENTIALS');+ else+ expect(responseOrError.status()).toBe(401);await context.close();});it('should fail with correct credentials and mismatching hostname', async ({ browser, server, isChromiumHeadedLike }) => {- it.fail(isChromiumHeadedLike);server.setAuth('/empty.html', 'user', 'pass');const hostname = new URL(server.PREFIX).hostname;const origin = server.PREFIX.replace(hostname, 'mismatching-hostname');@@ -130,20 +131,25 @@ it('should fail with correct credentials and mismatching hostname', async ({ brohttpCredentials: { username: 'user', password: 'pass', origin: origin }});const page = await context.newPage();- const response = await page.goto(server.EMPTY_PAGE);- expect(response!.status()).toBe(401);+ const responseOrError = await page.goto(server.EMPTY_PAGE).catch(e => e);+ if (isChromiumHeadedLike)+ expect(responseOrError.message).toContain('net::ERR_INVALID_AUTH_CREDENTIALS');+ else+ expect(responseOrError.status()).toBe(401);await context.close();});it('should fail with correct credentials and mismatching port', async ({ browser, server, isChromiumHeadedLike }) => {- it.fail(isChromiumHeadedLike);server.setAuth('/empty.html', 'user', 'pass');const origin = server.PREFIX.replace(server.PORT.toString(), (server.PORT + 1).toString());const context = await browser.newContext({httpCredentials: { username: 'user', password: 'pass', origin: origin }});const page = await context.newPage();- const response = await page.goto(server.EMPTY_PAGE);- expect(response!.status()).toBe(401);+ const responseOrError = await page.goto(server.EMPTY_PAGE).catch(e => e);+ if (isChromiumHeadedLike)+ expect(responseOrError.message).toContain('net::ERR_INVALID_AUTH_CREDENTIALS');+ else+ expect(responseOrError.status()).toBe(401);await context.close();});diff --git a/tests/library/emulation-focus.spec.ts b/tests/library/emulation-focus.spec.tsindex 8d76b8140c..5f6b5b741f 100644--- a/tests/library/emulation-focus.spec.ts+++ b/tests/library/emulation-focus.spec.ts@@ -104,8 +104,6 @@ it('should change document.activeElement', async ({ page, server }) => {it('should not affect screenshots', async ({ page, server, browserName, headless, isWindows }) => {it.skip(browserName === 'webkit' && isWindows && !headless, 'WebKit/Windows/headed has a larger minimal viewport. See https://github.com/microsoft/playwright/issues/22616');it.skip(browserName === 'firefox' && !headless, 'Firefox headed produces a different image');- const isChromiumHeadlessNew = browserName === 'chromium' && !!headless && !!process.env.PLAYWRIGHT_CHROMIUM_USE_HEADLESS_NEW;- it.fixme(isChromiumHeadlessNew, 'Times out with --headless=new');const page2 = await page.context().newPage();await Promise.all([diff --git a/tests/library/permissions.spec.ts b/tests/library/permissions.spec.tsindex 1064eaf61f..0797a7e18b 100644--- a/tests/library/permissions.spec.ts+++ b/tests/library/permissions.spec.ts@@ -148,16 +148,21 @@ it.describe('permissions', () => {it('should support clipboard read', async ({ page, context, server, browserName, isWindows, isLinux, headless }) => {it.info().annotations.push({ type: 'issue', description: 'https://github.com/microsoft/playwright/issues/27475' });it.fail(browserName === 'firefox', 'No such permissions (requires flag) in Firefox');- it.fixme(browserName === 'chromium' && (!headless || !!process.env.PLAYWRIGHT_CHROMIUM_USE_HEADLESS_NEW));it.fixme(browserName === 'webkit' && isWindows, 'WebPasteboardProxy::allPasteboardItemInfo not implemented for Windows.');it.fixme(browserName === 'webkit' && isLinux && headless, 'WebPasteboardProxy::allPasteboardItemInfo not implemented for WPE.');+ const isChromiumHeadedLike = browserName === 'chromium' && (!headless || !!process.env.PLAYWRIGHT_CHROMIUM_USE_HEADLESS_NEW);+await page.goto(server.EMPTY_PAGE);// There is no 'clipboard-read' permission in WebKit Web API.if (browserName !== 'webkit')expect(await getPermission(page, 'clipboard-read')).toBe('prompt');- let error;- await page.evaluate(() => navigator.clipboard.readText()).catch(e => error = e);- expect(error.toString()).toContain('denied');++ if (!isChromiumHeadedLike) {+ // Headed Chromium shows a dialog and does not resolve the promise.+ const error = await page.evaluate(() => navigator.clipboard.readText()).catch(e => e);+ expect(error.toString()).toContain('denied');+ }+await context.grantPermissions(['clipboard-read']);if (browserName !== 'webkit')expect(await getPermission(page, 'clipboard-read')).toBe('granted');diff --git a/tests/page/page-set-input-files.spec.ts b/tests/page/page-set-input-files.spec.tsindex ef752ef485..59378dcaa3 100644--- a/tests/page/page-set-input-files.spec.ts+++ b/tests/page/page-set-input-files.spec.ts@@ -52,8 +52,8 @@ it('should upload a folder', async ({ page, server, browserName, headless, brows}await input.setInputFiles(dir);expect(new Set(await page.evaluate(e => [...e.files].map(f => f.webkitRelativePath), input))).toEqual(new Set([- // https://issues.chromium.org/issues/345393164- ...((browserName === 'chromium' && headless && !process.env.PLAYWRIGHT_CHROMIUM_USE_HEADLESS_NEW && browserMajorVersion < 127) ? [] : ['file-upload-test/sub-dir/really.txt']),+ // Note: this did not work before Chrome 127, see https://issues.chromium.org/issues/345393164.+ 'file-upload-test/sub-dir/really.txt','file-upload-test/file1.txt','file-upload-test/file2',]));