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(android): run selected page tests on android (3) (#5910)
Pavel Feldmanca35da0a338d
diff --git a/test/browsercontext-set-extra-http-headers.spec.ts b/test/browsercontext-set-extra-http-headers.spec.tsnew file mode 100644index 0000000000..2ee4a1fe79--- /dev/null+++ b/test/browsercontext-set-extra-http-headers.spec.ts@@ -0,0 +1,35 @@+/**+ * Copyright 2018 Google Inc. All rights reserved.+ * Modifications copyright (c) Microsoft Corporation.+ *+ * Licensed under the Apache License, Version 2.0 (the "License");+ * you may not use this file except in compliance with the License.+ * You may obtain a copy of the License at+ *+ * http://www.apache.org/licenses/LICENSE-2.0+ *+ * Unless required by applicable law or agreed to in writing, software+ * distributed under the License is distributed on an "AS IS" BASIS,+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.+ * See the License for the specific language governing permissions and+ * limitations under the License.+ */++import { it, expect } from './fixtures';++it('should override extra headers from browser context', async ({browser, server}) => {+ const context = await browser.newContext({+ extraHTTPHeaders: { 'fOo': 'bAr', 'baR': 'foO' },+ });+ const page = await context.newPage();+ await page.setExtraHTTPHeaders({+ 'Foo': 'Bar'+ });+ const [request] = await Promise.all([+ server.waitForRequest('/empty.html'),+ page.goto(server.EMPTY_PAGE),+ ]);+ await context.close();+ expect(request.headers['foo']).toBe('Bar');+ expect(request.headers['bar']).toBe('foO');+});diff --git a/test/page-dispatchevent.spec.ts b/test/page/page-dispatchevent.spec.tssimilarity index 99%rename from test/page-dispatchevent.spec.tsrename to test/page/page-dispatchevent.spec.tsindex 1d831d216d..1fb9f58ba6 100644--- a/test/page-dispatchevent.spec.ts+++ b/test/page/page-dispatchevent.spec.ts@@ -14,7 +14,7 @@* limitations under the License.*/-import { it, expect } from './fixtures';+import { it, expect } from '../fixtures';it('should dispatch click event', async ({page, server}) => {await page.goto(server.PREFIX + '/input/button.html');diff --git a/test/page-fill.spec.ts b/test/page/page-fill.spec.tssimilarity index 99%rename from test/page-fill.spec.tsrename to test/page/page-fill.spec.tsindex d2ecd6102c..e1bb839692 100644--- a/test/page-fill.spec.ts+++ b/test/page/page-fill.spec.ts@@ -15,7 +15,7 @@* limitations under the License.*/-import { it, expect } from './fixtures';+import { it, expect } from '../fixtures';async function giveItAChanceToFill(page) {for (let i = 0; i < 5; i++)diff --git a/test/page-route.spec.ts b/test/page/page-route.spec.tssimilarity index 99%rename from test/page-route.spec.tsrename to test/page/page-route.spec.tsindex cf62c89e3d..beb02ef2d5 100644--- a/test/page-route.spec.ts+++ b/test/page/page-route.spec.ts@@ -15,7 +15,7 @@* limitations under the License.*/-import { it, expect } from './fixtures';+import { it, expect } from '../fixtures';it('should intercept', async ({page, server}) => {let intercepted = false;diff --git a/test/page-select-option.spec.ts b/test/page/page-select-option.spec.tssimilarity index 99%rename from test/page-select-option.spec.tsrename to test/page/page-select-option.spec.tsindex 91cc66c23c..0c52a8402c 100644--- a/test/page-select-option.spec.ts+++ b/test/page/page-select-option.spec.ts@@ -15,7 +15,7 @@* limitations under the License.*/-import { it, expect } from './fixtures';+import { it, expect } from '../fixtures';async function giveItAChanceToResolve(page) {diff --git a/test/page-set-content.spec.ts b/test/page/page-set-content.spec.tssimilarity index 98%rename from test/page-set-content.spec.tsrename to test/page/page-set-content.spec.tsindex e658771337..aaeaf80119 100644--- a/test/page-set-content.spec.ts+++ b/test/page/page-set-content.spec.ts@@ -15,7 +15,7 @@* limitations under the License.*/-import { it, expect } from './fixtures';+import { it, expect } from '../fixtures';const expectedOutput = '<html><head></head><body><div>hello</div></body></html>';diff --git a/test/page-set-extra-http-headers.spec.ts b/test/page/page-set-extra-http-headers.spec.tssimilarity index 76%rename from test/page-set-extra-http-headers.spec.tsrename to test/page/page-set-extra-http-headers.spec.tsindex 2244fe7f6a..011c330bf7 100644--- a/test/page-set-extra-http-headers.spec.ts+++ b/test/page/page-set-extra-http-headers.spec.ts@@ -15,7 +15,7 @@* limitations under the License.*/-import { it, expect } from './fixtures';+import { it, expect } from '../fixtures';it('should work', async ({page, server}) => {await page.setExtraHTTPHeaders({@@ -42,37 +42,17 @@ it('should work with redirects', async ({page, server}) => {expect(request.headers['foo']).toBe('bar');});-it('should work with extra headers from browser context', async ({browser, server}) => {- const context = await browser.newContext();- await context.setExtraHTTPHeaders({+it('should work with extra headers from browser context', async ({page, server}) => {+ await page.context().setExtraHTTPHeaders({'foo': 'bar',});- const page = await context.newPage();const [request] = await Promise.all([server.waitForRequest('/empty.html'),page.goto(server.EMPTY_PAGE),]);- await context.close();expect(request.headers['foo']).toBe('bar');});-it('should override extra headers from browser context', async ({browser, server}) => {- const context = await browser.newContext({- extraHTTPHeaders: { 'fOo': 'bAr', 'baR': 'foO' },- });- const page = await context.newPage();- await page.setExtraHTTPHeaders({- 'Foo': 'Bar'- });- const [request] = await Promise.all([- server.waitForRequest('/empty.html'),- page.goto(server.EMPTY_PAGE),- ]);- await context.close();- expect(request.headers['foo']).toBe('Bar');- expect(request.headers['bar']).toBe('foO');-});-it('should throw for non-string header values', async ({browser, page}) => {// @ts-expect-error headers must be stringsconst error1 = await page.setExtraHTTPHeaders({ 'foo': 1 }).catch(e => e);diff --git a/test/page-set-input-files.spec.ts b/test/page/page-set-input-files.spec.tssimilarity index 95%rename from test/page-set-input-files.spec.tsrename to test/page/page-set-input-files.spec.tsindex 3e7640489d..8f60306687 100644--- a/test/page-set-input-files.spec.ts+++ b/test/page/page-set-input-files.spec.ts@@ -15,13 +15,13 @@* limitations under the License.*/-import { it, expect } from './fixtures';+import { it, expect } from '../fixtures';import path from 'path';import fs from 'fs';import formidable from 'formidable';-const FILE_TO_UPLOAD = path.join(__dirname, '/assets/file-to-upload.txt');+const FILE_TO_UPLOAD = path.join(__dirname, '../assets/file-to-upload.txt');it('should upload the file', async ({page, server}) => {await page.goto(server.PREFIX + '/input/fileupload.html');@@ -39,7 +39,7 @@ it('should upload the file', async ({page, server}) => {it('should work', async ({page}) => {await page.setContent(`<input type=file>`);- await page.setInputFiles('input', path.join(__dirname, '/assets/file-to-upload.txt'));+ await page.setInputFiles('input', path.join(__dirname, '../assets/file-to-upload.txt'));expect(await page.$eval('input', input => input.files.length)).toBe(1);expect(await page.$eval('input', input => input.files[0].name)).toBe('file-to-upload.txt');});@@ -168,7 +168,7 @@ it('should work with CSP', async ({page, server}) => {server.setCSP('/empty.html', 'default-src "none"');await page.goto(server.EMPTY_PAGE);await page.setContent(`<input type=file>`);- await page.setInputFiles('input', path.join(__dirname, '/assets/file-to-upload.txt'));+ await page.setInputFiles('input', path.join(__dirname, '../assets/file-to-upload.txt'));expect(await page.$eval('input', input => input.files.length)).toBe(1);expect(await page.$eval('input', input => input.files[0].name)).toBe('file-to-upload.txt');});@@ -244,8 +244,8 @@ it('should detect mime type', async ({page, server}) => {<input type="file" name="file2"><input type="submit" value="Submit"></form>`);- await (await page.$('input[name=file1]')).setInputFiles(path.join(__dirname, '/assets/file-to-upload.txt'));- await (await page.$('input[name=file2]')).setInputFiles(path.join(__dirname, '/assets/pptr.png'));+ await (await page.$('input[name=file1]')).setInputFiles(path.join(__dirname, '../assets/file-to-upload.txt'));+ await (await page.$('input[name=file2]')).setInputFiles(path.join(__dirname, '../assets/pptr.png'));await Promise.all([page.click('input[type=submit]'),server.waitForRequest('/upload'),@@ -254,11 +254,11 @@ it('should detect mime type', async ({page, server}) => {expect(file1.name).toBe('file-to-upload.txt');expect(file1.type).toBe('text/plain');expect(fs.readFileSync(file1.path).toString()).toBe(- fs.readFileSync(path.join(__dirname, '/assets/file-to-upload.txt')).toString());+ fs.readFileSync(path.join(__dirname, '../assets/file-to-upload.txt')).toString());expect(file2.name).toBe('pptr.png');expect(file2.type).toBe('image/png');expect(fs.readFileSync(file2.path).toString()).toBe(- fs.readFileSync(path.join(__dirname, '/assets/pptr.png')).toString());+ fs.readFileSync(path.join(__dirname, '../assets/pptr.png')).toString());});it('should be able to read selected file', async ({page, server}) => {diff --git a/test/page-wait-for-function.spec.ts b/test/page/page-wait-for-function.spec.tssimilarity index 99%rename from test/page-wait-for-function.spec.tsrename to test/page/page-wait-for-function.spec.tsindex 907b571646..273ff1abf8 100644--- a/test/page-wait-for-function.spec.ts+++ b/test/page/page-wait-for-function.spec.ts@@ -15,7 +15,7 @@* limitations under the License.*/-import { it, expect } from './fixtures';+import { it, expect } from '../fixtures';it('should timeout', async ({page}) => {const startTime = Date.now();diff --git a/test/page-wait-for-load-state.spec.ts b/test/page/page-wait-for-load-state.spec.tssimilarity index 96%rename from test/page-wait-for-load-state.spec.tsrename to test/page/page-wait-for-load-state.spec.tsindex 10fb28fa92..3c5e162f68 100644--- a/test/page-wait-for-load-state.spec.ts+++ b/test/page/page-wait-for-load-state.spec.ts@@ -15,8 +15,8 @@* limitations under the License.*/-import { it, expect } from './fixtures';-import type { Route } from '..';+import { it, expect } from '../fixtures';+import type { Route } from '../..';it('should pick up ongoing navigation', async ({page, server}) => {let response = null;@@ -140,9 +140,7 @@ it('should wait for load state of newPage', async ({browser, context, page, servexpect(await newPage.evaluate(() => document.readyState)).toBe('complete');});-it('should resolve after popup load', async ({browser, server}) => {- const context = await browser.newContext();- const page = await context.newPage();+it('should resolve after popup load', async ({page, server}) => {await page.goto(server.EMPTY_PAGE);// Stall the 'load' by delaying css.let cssResponse;@@ -162,7 +160,6 @@ it('should resolve after popup load', async ({browser, server}) => {await loadSatePromise;expect(resolved).toBe(true);expect(popup.url()).toBe(server.PREFIX + '/one-style.html');- await context.close();});it('should work for frame', async ({page, server}) => {diff --git a/test/page-wait-for-navigation.spec.ts b/test/page/page-wait-for-navigation.spec.tssimilarity index 98%rename from test/page-wait-for-navigation.spec.tsrename to test/page/page-wait-for-navigation.spec.tsindex d02e59f926..d381bc5f63 100644--- a/test/page-wait-for-navigation.spec.ts+++ b/test/page/page-wait-for-navigation.spec.ts@@ -15,9 +15,9 @@* limitations under the License.*/-import { it, expect } from './fixtures';-import type { Frame } from '../index';-import { expectedSSLError } from './utils';+import { it, expect } from '../fixtures';+import type { Frame } from '../../index';+import { expectedSSLError } from '../utils';it('should work', async ({page, server}) => {await page.goto(server.EMPTY_PAGE);diff --git a/test/page-wait-for-request.spec.ts b/test/page/page-wait-for-request.spec.tssimilarity index 98%rename from test/page-wait-for-request.spec.tsrename to test/page/page-wait-for-request.spec.tsindex 506a25fac8..0fd97770bf 100644--- a/test/page-wait-for-request.spec.ts+++ b/test/page/page-wait-for-request.spec.ts@@ -15,7 +15,7 @@* limitations under the License.*/-import { it, expect } from './fixtures';+import { it, expect } from '../fixtures';import vm from 'vm';diff --git a/test/page-wait-for-response.spec.ts b/test/page/page-wait-for-response.spec.tssimilarity index 98%rename from test/page-wait-for-response.spec.tsrename to test/page/page-wait-for-response.spec.tsindex ab75f75e35..c83f7dab70 100644--- a/test/page-wait-for-response.spec.ts+++ b/test/page/page-wait-for-response.spec.ts@@ -15,7 +15,7 @@* limitations under the License.*/-import { it, expect } from './fixtures';+import { it, expect } from '../fixtures';it('should work', async ({page, server}) => {await page.goto(server.EMPTY_PAGE);diff --git a/test/page-wait-for-selector-1.spec.ts b/test/page/page-wait-for-selector-1.spec.tssimilarity index 99%rename from test/page-wait-for-selector-1.spec.tsrename to test/page/page-wait-for-selector-1.spec.tsindex 75cd859f7c..3d8440996c 100644--- a/test/page-wait-for-selector-1.spec.ts+++ b/test/page/page-wait-for-selector-1.spec.ts@@ -15,8 +15,8 @@* limitations under the License.*/-import { it, expect } from './fixtures';-import { attachFrame, detachFrame } from './utils';+import { it, expect } from '../fixtures';+import { attachFrame, detachFrame } from '../utils';async function giveItTimeToLog(frame) {await frame.evaluate(() => new Promise(f => requestAnimationFrame(() => requestAnimationFrame(f))));diff --git a/test/page-wait-for-selector-2.spec.ts b/test/page/page-wait-for-selector-2.spec.tssimilarity index 99%rename from test/page-wait-for-selector-2.spec.tsrename to test/page/page-wait-for-selector-2.spec.tsindex b81addcb2b..dad6016639 100644--- a/test/page-wait-for-selector-2.spec.ts+++ b/test/page/page-wait-for-selector-2.spec.ts@@ -15,8 +15,8 @@* limitations under the License.*/-import { it, expect } from './fixtures';-import { attachFrame, detachFrame } from './utils';+import { it, expect } from '../fixtures';+import { attachFrame, detachFrame } from '../utils';const addElement = tag => document.body.appendChild(document.createElement(tag));