diff --git a/packages/README.md b/packages/README.md index 21121518a8..9851a57d04 100644 --- a/packages/README.md +++ b/packages/README.md @@ -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` - diff --git a/packages/build_package.js b/packages/build_package.js index e6a10fb822..9c5ab40611 100755 --- a/packages/build_package.js +++ b/packages/build_package.js @@ -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 diff --git a/packages/common/index.mjs b/packages/common/index.mjs index 337c589660..9d9b095ae0 100644 --- a/packages/common/index.mjs +++ b/packages/common/index.mjs @@ -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; diff --git a/packages/installation-tests/installation-tests.sh b/packages/installation-tests/installation-tests.sh index d880bb07e6..74275f90a6 100755 --- a/packages/installation-tests/installation-tests.sh +++ b/packages/installation-tests/installation-tests.sh @@ -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" diff --git a/packages/installation-tests/sanity-electron.js b/packages/installation-tests/sanity-electron.js index 4c5bf0f676..8475f129af 100644 --- a/packages/installation-tests/sanity-electron.js +++ b/packages/installation-tests/sanity-electron.js @@ -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); diff --git a/packages/playwright-android/README.md b/packages/playwright-android/README.md deleted file mode 100644 index b2651c3f26..0000000000 --- a/packages/playwright-android/README.md +++ /dev/null @@ -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(); -})(); -``` diff --git a/packages/playwright-android/index.d.ts b/packages/playwright-android/index.d.ts deleted file mode 100644 index e12e3c245f..0000000000 --- a/packages/playwright-android/index.d.ts +++ /dev/null @@ -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; diff --git a/packages/playwright-android/index.js b/packages/playwright-android/index.js deleted file mode 100644 index b1901919de..0000000000 --- a/packages/playwright-android/index.js +++ /dev/null @@ -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; diff --git a/packages/playwright-android/index.mjs b/packages/playwright-android/index.mjs deleted file mode 100644 index b750bd3dc4..0000000000 --- a/packages/playwright-android/index.mjs +++ /dev/null @@ -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; diff --git a/packages/playwright-android/install.js b/packages/playwright-android/install.js deleted file mode 100644 index b8037e25b3..0000000000 --- a/packages/playwright-android/install.js +++ /dev/null @@ -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. */ diff --git a/packages/playwright-electron/README.md b/packages/playwright-electron/README.md deleted file mode 100644 index 3e4266fe00..0000000000 --- a/packages/playwright-electron/README.md +++ /dev/null @@ -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 - - - - - Hello World! - - - - -

Hello World!

- - - -``` - -`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: 'Hello World', - }) - }); - - // 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()); - }); - -}); -``` diff --git a/packages/playwright-electron/index.d.ts b/packages/playwright-electron/index.d.ts deleted file mode 100644 index 95e790b521..0000000000 --- a/packages/playwright-electron/index.d.ts +++ /dev/null @@ -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; diff --git a/packages/playwright-electron/index.js b/packages/playwright-electron/index.js deleted file mode 100644 index fa1134b48d..0000000000 --- a/packages/playwright-electron/index.js +++ /dev/null @@ -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; diff --git a/packages/playwright-electron/index.mjs b/packages/playwright-electron/index.mjs deleted file mode 100644 index 619e0026ec..0000000000 --- a/packages/playwright-electron/index.mjs +++ /dev/null @@ -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; diff --git a/packages/playwright-electron/install.js b/packages/playwright-electron/install.js deleted file mode 100644 index 6a70e659c8..0000000000 --- a/packages/playwright-electron/install.js +++ /dev/null @@ -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. */