mirror of
https://github.com/microsoft/playwright.git
synced 2024-09-11 20:37:54 +03:00
chore: remove electron/android from build_packages (#6827)
We do not update these packages anymore, and bundle the code in playwright.
This commit is contained in:
parent
b4ffe86fd1
commit
24dca969b6
@ -46,16 +46,3 @@ To test packages, use [`//packages/installation-tests/installation-tests.sh`](./
|
||||
|
||||
All package publishing happens **exclusively** over CI/CD using the [`//utils/publish_all_packages.sh`](../utils/publish_all_packages.sh) script.
|
||||
|
||||
|
||||
# Special handling for `playwright-electron`
|
||||
|
||||
- `playwright-electron` version is pre-1.0.0 and thus managed separately. It's specified inside the [`//packages/build_package.js`]('./build_package.js') file.
|
||||
- `playwright-electron` is published manually.
|
||||
|
||||
To publish a new version of `playwright-electron`:
|
||||
|
||||
1. Bump `playwright-electron` version inside [`//packages/build_package.js`]('./build_package.js')
|
||||
2. Submit PR with the updated version
|
||||
3. Build package with `./build_package.js playwright-electron ./playwright-electron.tgz`
|
||||
4. Publish package with `npm publish playwright-electron.tgz`
|
||||
|
||||
|
@ -57,18 +57,6 @@ const PACKAGES = {
|
||||
browsers: ['chromium', 'ffmpeg'],
|
||||
files: [...PLAYWRIGHT_CORE_FILES],
|
||||
},
|
||||
'playwright-electron': {
|
||||
version: '0.4.0', // Manually manage playwright-electron version.
|
||||
description: 'A high-level API to automate Electron',
|
||||
browsers: ['ffmpeg'],
|
||||
files: [...PLAYWRIGHT_CORE_FILES],
|
||||
},
|
||||
'playwright-android': {
|
||||
version: '0.0.8', // Manually manage playwright-android version.
|
||||
description: 'A high-level API to automate Chrome for Android',
|
||||
browsers: ['ffmpeg'],
|
||||
files: [...PLAYWRIGHT_CORE_FILES],
|
||||
},
|
||||
};
|
||||
|
||||
// 1. Parse CLI arguments
|
||||
|
@ -22,4 +22,6 @@ export const webkit = playwright.webkit;
|
||||
export const selectors = playwright.selectors;
|
||||
export const devices = playwright.devices;
|
||||
export const errors = playwright.errors;
|
||||
export const _electron = playwright._electron;
|
||||
export const _android = playwright._android;
|
||||
export default playwright;
|
||||
|
@ -27,10 +27,6 @@ PLAYWRIGHT_WEBKIT_TGZ="$(node ${PACKAGE_BUILDER} playwright-webkit ./playwright-
|
||||
echo "playwright-webkit built"
|
||||
PLAYWRIGHT_FIREFOX_TGZ="$(node ${PACKAGE_BUILDER} playwright-firefox ./playwright-firefox.tgz)"
|
||||
echo "playwright-firefox built"
|
||||
PLAYWRIGHT_ELECTRON_TGZ="$(node ${PACKAGE_BUILDER} playwright-electron ./playwright-electron.tgz)"
|
||||
echo "playwright-electron built"
|
||||
PLAYWRIGHT_ANDROID_TGZ="$(node ${PACKAGE_BUILDER} playwright-android ./playwright-android.tgz)"
|
||||
echo "playwright-android built"
|
||||
|
||||
SCRIPTS_PATH="$(pwd -P)/.."
|
||||
TEST_ROOT="/tmp/playwright-installation-tests"
|
||||
@ -401,7 +397,7 @@ function test_playwright_validate_dependencies_skip_executable_path {
|
||||
function test_playwright_electron_should_work {
|
||||
initialize_test "${FUNCNAME[0]}"
|
||||
|
||||
npm install ${PLAYWRIGHT_ELECTRON_TGZ}
|
||||
PLAYWRIGHT_SKIP_BROWSER_DOWNLOAD=1 npm install ${PLAYWRIGHT_TGZ}
|
||||
npm install electron@9.0
|
||||
copy_test_scripts
|
||||
|
||||
@ -413,11 +409,11 @@ function test_playwright_electron_should_work {
|
||||
|
||||
function test_electron_types {
|
||||
initialize_test "${FUNCNAME[0]}"
|
||||
npm install ${PLAYWRIGHT_ELECTRON_TGZ}
|
||||
PLAYWRIGHT_SKIP_BROWSER_DOWNLOAD=1 npm install ${PLAYWRIGHT_TGZ}
|
||||
npm install electron@9.0
|
||||
npm install -D typescript@3.8
|
||||
npm install -D @types/node@10.17
|
||||
echo "import { Page, electron, ElectronApplication, Electron } from 'playwright-electron';" > "test.ts"
|
||||
echo "import { Page, _electron, ElectronApplication, Electron } from 'playwright';" > "test.ts"
|
||||
|
||||
echo "Running tsc"
|
||||
npx -p typescript@3.7.5 tsc "test.ts"
|
||||
@ -428,10 +424,10 @@ function test_electron_types {
|
||||
function test_android_types {
|
||||
initialize_test "${FUNCNAME[0]}"
|
||||
|
||||
npm install ${PLAYWRIGHT_ANDROID_TGZ}
|
||||
PLAYWRIGHT_SKIP_BROWSER_DOWNLOAD=1 npm install ${PLAYWRIGHT_TGZ}
|
||||
npm install -D typescript@3.8
|
||||
npm install -D @types/node@10.17
|
||||
echo "import { AndroidDevice, android, AndroidWebView, Page } from 'playwright-android';" > "test.ts"
|
||||
echo "import { AndroidDevice, _android, AndroidWebView, Page } from 'playwright';" > "test.ts"
|
||||
|
||||
echo "Running tsc"
|
||||
npx -p typescript@3.7.5 tsc "test.ts"
|
||||
|
@ -14,18 +14,18 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
const playwright = require('playwright-electron');
|
||||
const playwright = require('playwright');
|
||||
const path = require('path');
|
||||
|
||||
(async () => {
|
||||
const application = await playwright.electron.launch({
|
||||
const application = await playwright._electron.launch({
|
||||
args: [path.join(__dirname, 'electron-app.js')],
|
||||
});
|
||||
const appPath = await application.evaluate(async ({ app }) => app.getAppPath());
|
||||
await application.close();
|
||||
if (appPath !== __dirname)
|
||||
throw new Error(`Malformed app path: got "${appPath}", expected "${__dirname}"`);
|
||||
console.log(`playwright-electron SUCCESS`);
|
||||
console.log(`playwright._electron SUCCESS`);
|
||||
})().catch(err => {
|
||||
console.error(err);
|
||||
process.exit(1);
|
||||
|
@ -1,44 +0,0 @@
|
||||
# playwright-android
|
||||
This package contains the [Android](https://www.android.com/) flavor of [Playwright](http://github.com/microsoft/playwright).
|
||||
|
||||
## Requirements
|
||||
|
||||
- Android device or AVD Emulator.
|
||||
- [ADB daemon](https://developer.android.com/studio/command-line/adb) running and authenticated with your device. Typically running `adb devices` is all you need to do.
|
||||
- [Chrome 87](https://play.google.com/store/apps/details?id=com.android.chrome) or newer installed on the device
|
||||
- "Enable command line on non-rooted devices" enabled in `chrome://flags`.
|
||||
|
||||
## How to demo
|
||||
|
||||
```js
|
||||
const { android } = require('playwright-android');
|
||||
|
||||
(async () => {
|
||||
const [device] = await android.devices();
|
||||
console.log(`Model: ${device.model()}`);
|
||||
console.log(`Serial: ${device.serial()}`);
|
||||
|
||||
await device.shell('am force-stop org.chromium.webview_shell');
|
||||
await device.shell('am start org.chromium.webview_shell/.WebViewBrowserActivity');
|
||||
|
||||
const webview = await device.webView({ pkg: 'org.chromium.webview_shell' });
|
||||
const page = await webview.page();
|
||||
|
||||
await device.fill({ res: 'org.chromium.webview_shell:id/url_field' }, 'github.com/microsoft/playwright');
|
||||
await Promise.all([
|
||||
page.waitForNavigation(),
|
||||
device.press({ res: 'org.chromium.webview_shell:id/url_field' }, 'Enter')
|
||||
]);
|
||||
console.log(await page.title());
|
||||
|
||||
{
|
||||
const context = await device.launchBrowser();
|
||||
const [page] = context.pages();
|
||||
await page.goto('https://webkit.org/');
|
||||
console.log(await page.evaluate(() => window.location.href));
|
||||
await context.close();
|
||||
}
|
||||
|
||||
await device.close();
|
||||
})();
|
||||
```
|
19
packages/playwright-android/index.d.ts
vendored
19
packages/playwright-android/index.d.ts
vendored
@ -1,19 +0,0 @@
|
||||
/**
|
||||
* 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 { Android } from './types/types';
|
||||
export * from './types/types';
|
||||
export const android: Android;
|
@ -1,18 +0,0 @@
|
||||
/**
|
||||
* 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.
|
||||
*/
|
||||
|
||||
module.exports = require('./lib/inprocess');
|
||||
module.exports.android = module.exports._android;
|
@ -1,23 +0,0 @@
|
||||
/**
|
||||
* 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 playwright from './index.js';
|
||||
|
||||
export const android = playwright.android;
|
||||
export const selectors = playwright.selectors;
|
||||
export const devices = playwright.devices;
|
||||
export const errors = playwright.errors;
|
||||
export default playwright;
|
@ -1,17 +0,0 @@
|
||||
/**
|
||||
* 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.
|
||||
*/
|
||||
|
||||
/* NOTE: playwright-android does not install browsers by design. */
|
@ -1,154 +0,0 @@
|
||||
# playwright-electron
|
||||
This package contains the [Electron](https://www.electronjs.org/) flavor of [Playwright](http://github.com/microsoft/playwright).
|
||||
|
||||
## How to demo
|
||||
|
||||
```bash
|
||||
npm i --save-dev electron@beta playwright-electron
|
||||
npx mocha
|
||||
```
|
||||
|
||||
|
||||
`index.js` - main Electron application file.
|
||||
```js
|
||||
const { app, BrowserWindow } = require('electron');
|
||||
|
||||
function createWindow () {
|
||||
let win = new BrowserWindow({
|
||||
width: 800,
|
||||
height: 600,
|
||||
});
|
||||
|
||||
win.loadFile('index.html');
|
||||
}
|
||||
|
||||
app.whenReady().then(createWindow);
|
||||
```
|
||||
|
||||
`index.html` - page that Electron opens in a BrowserWindow.
|
||||
```js
|
||||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<title>Hello World!</title>
|
||||
<meta http-equiv="Content-Security-Policy" content="script-src 'self' 'unsafe-inline';" />
|
||||
<style>
|
||||
html {
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
display: flex;
|
||||
background: white;
|
||||
}
|
||||
|
||||
body {
|
||||
flex: auto;
|
||||
display: flex;
|
||||
justify-content: center;
|
||||
align-items: center;
|
||||
flex-direction: column;
|
||||
}
|
||||
</style>
|
||||
</head>
|
||||
<body>
|
||||
<h1>Hello World!</h1>
|
||||
<button onclick="console.log('click')">Click me</button>
|
||||
</body>
|
||||
</html>
|
||||
```
|
||||
|
||||
`test/spec.js` - test file
|
||||
```js
|
||||
const { electron } = require('playwright-electron');
|
||||
const assert = require('assert');
|
||||
const path = require('path')
|
||||
|
||||
describe('Sanity checks', function () {
|
||||
this.timeout(10000);
|
||||
|
||||
beforeEach(async () => {
|
||||
// Before each test start Electron application.
|
||||
this.app = await electron.launch({
|
||||
args: [path.join(__dirname, '..')] // loads index.js
|
||||
});
|
||||
});
|
||||
|
||||
afterEach(async () => {
|
||||
// After each test close Electron application.
|
||||
await this.app.close();
|
||||
});
|
||||
|
||||
it('script application', async () => {
|
||||
const appPath = await this.app.evaluate(async ({ app }) => {
|
||||
// This runs in the main Electron process, first parameter is
|
||||
// the result of the require('electron') in the main app script.
|
||||
return app.getAppPath();
|
||||
});
|
||||
assert.equal(appPath, path.join(__dirname, '..'));
|
||||
});
|
||||
|
||||
it('window title', async () => {
|
||||
// Return value of this.app.firstWindow a Playwright Page.
|
||||
// See https://playwright.dev/#path=docs%2Fapi.md&q=class-page.
|
||||
|
||||
// Get a Playwright page for the first Electron window.
|
||||
// It awaits for the page to be available. Alternatively use
|
||||
// this.app.windows() or this.app.waitForEvent('window').
|
||||
const page = await this.app.firstWindow();
|
||||
assert.equal(await page.title(), 'Hello World!');
|
||||
});
|
||||
|
||||
it('capture screenshot', async () => {
|
||||
const page = await this.app.firstWindow();
|
||||
|
||||
// Capture window screenshot.
|
||||
await page.screenshot({ path: 'intro.png' });
|
||||
});
|
||||
|
||||
it('sniff console', async () => {
|
||||
const page = await this.app.firstWindow();
|
||||
|
||||
// Collect console logs.
|
||||
let consoleText;
|
||||
page.on('console', message => consoleText = message.text());
|
||||
|
||||
// Click button.
|
||||
await page.click('text=Click me');
|
||||
|
||||
// Check that click produced console message.
|
||||
assert.equal(consoleText, 'click');
|
||||
});
|
||||
|
||||
it('intercept network', async () => {
|
||||
await this.app.firstWindow();
|
||||
|
||||
// Return value of this.app.context() is a Playwright BrowserContext.
|
||||
// See https://playwright.dev/#path=docs%2Fapi.md&q=class-browsercontext.
|
||||
|
||||
await await this.app.context().route('**/empty.html', (route, request) => {
|
||||
route.fulfill({
|
||||
status: 200,
|
||||
contentType: 'text/html',
|
||||
body: '<title>Hello World</title>',
|
||||
})
|
||||
});
|
||||
|
||||
// Helper method to create BrowserWindow.
|
||||
const page = await this.app.newBrowserWindow({ width: 800, height: 600 });
|
||||
await page.goto('https://localhost:1000/empty.html');
|
||||
|
||||
assert.equal(await page.title(), 'Hello World');
|
||||
});
|
||||
|
||||
it('should maximize window', async () => {
|
||||
await this.app.firstWindow();
|
||||
|
||||
const page = await this.app.newBrowserWindow({ width: 800, height: 600 });
|
||||
// page.browserWindow is a Playwright JSHandle pointing at Electron's
|
||||
// BrowserWindow.
|
||||
// https://playwright.dev/#path=docs%2Fapi.md&q=class-jshandle
|
||||
await page.browserWindow.evaluate(browserWindow => browserWindow.maximize());
|
||||
});
|
||||
|
||||
});
|
||||
```
|
19
packages/playwright-electron/index.d.ts
vendored
19
packages/playwright-electron/index.d.ts
vendored
@ -1,19 +0,0 @@
|
||||
/**
|
||||
* 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 { Electron } from './types/types';
|
||||
export * from './types/types';
|
||||
export const electron: Electron;
|
@ -1,18 +0,0 @@
|
||||
/**
|
||||
* 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.
|
||||
*/
|
||||
|
||||
module.exports = require('./lib/inprocess');
|
||||
module.exports.electron = module.exports._electron;
|
@ -1,23 +0,0 @@
|
||||
/**
|
||||
* 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 playwright from './index.js';
|
||||
|
||||
export const electron = playwright.electron;
|
||||
export const selectors = playwright.selectors;
|
||||
export const devices = playwright.devices;
|
||||
export const errors = playwright.errors;
|
||||
export default playwright;
|
@ -1,17 +0,0 @@
|
||||
/**
|
||||
* 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.
|
||||
*/
|
||||
|
||||
/* NOTE: playwright-electron does not install browsers by design. */
|
Loading…
Reference in New Issue
Block a user