mirror of
https://github.com/puppeteer/puppeteer
synced 2024-06-14 14:02:48 +00:00
test: add installation test for BiDi (#11311)
This commit is contained in:
parent
8a54722328
commit
08615f848c
27
test/installation/assets/puppeteer/bidi.js
Normal file
27
test/installation/assets/puppeteer/bidi.js
Normal file
@ -0,0 +1,27 @@
|
||||
/**
|
||||
* Copyright 2023 Google Inc. All rights reserved.
|
||||
*
|
||||
* 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 puppeteer from 'puppeteer';
|
||||
(async () => {
|
||||
const browser = await puppeteer.launch({
|
||||
protocol: 'webDriverBiDi',
|
||||
});
|
||||
const page = await browser.newPage();
|
||||
await page.goto('http://example.com');
|
||||
await page.$('h1');
|
||||
await page.screenshot({path: 'example.png'});
|
||||
await browser.close();
|
||||
})();
|
@ -36,17 +36,26 @@ import {readAsset} from './util.js';
|
||||
},
|
||||
});
|
||||
|
||||
it('evaluates CommonJS', async function () {
|
||||
const files = await readdir(join(this.sandbox, '.cache', 'puppeteer'));
|
||||
assert.equal(files.length, 1);
|
||||
assert.equal(files[0], 'firefox');
|
||||
const script = await readAsset('puppeteer-core', 'requires.cjs');
|
||||
await this.runScript(script, 'cjs');
|
||||
describe('with CDP', () => {
|
||||
it('evaluates CommonJS', async function () {
|
||||
const files = await readdir(join(this.sandbox, '.cache', 'puppeteer'));
|
||||
assert.equal(files.length, 1);
|
||||
assert.equal(files[0], 'firefox');
|
||||
const script = await readAsset('puppeteer-core', 'requires.cjs');
|
||||
await this.runScript(script, 'cjs');
|
||||
});
|
||||
|
||||
it('evaluates ES modules', async function () {
|
||||
const script = await readAsset('puppeteer-core', 'imports.js');
|
||||
await this.runScript(script, 'mjs');
|
||||
});
|
||||
});
|
||||
|
||||
it('evaluates ES modules', async function () {
|
||||
const script = await readAsset('puppeteer-core', 'imports.js');
|
||||
await this.runScript(script, 'mjs');
|
||||
describe('with WebDriverBiDi', () => {
|
||||
it('evaluates ES modules', async function () {
|
||||
const script = await readAsset('puppeteer', 'bidi.js');
|
||||
await this.runScript(script, 'mjs');
|
||||
});
|
||||
});
|
||||
}
|
||||
);
|
||||
|
Loading…
Reference in New Issue
Block a user