mirror of
https://github.com/microsoft/playwright.git
synced 2025-01-05 19:04:43 +03:00
docs: remove browser.newPage from README
This commit is contained in:
parent
50f96eb9fc
commit
2dd11eaa09
17
README.md
17
README.md
@ -40,7 +40,9 @@ const playwright = require('playwright');
|
||||
(async () => {
|
||||
for (const browserType of ['chromium', 'firefox', 'webkit']) {
|
||||
const browser = await playwright[browserType].launch();
|
||||
const page = await browser.newPage('http://whatsmyuseragent.org/');
|
||||
const context = await browser.newContext();
|
||||
const page = await context.newPage();
|
||||
await page.goto('http://whatsmyuseragent.org/');
|
||||
await page.screenshot({ path: `example-${browserType}.png` });
|
||||
await browser.close();
|
||||
}
|
||||
@ -57,13 +59,14 @@ const iPhone11 = devices['iPhone 11 Pro'];
|
||||
|
||||
(async () => {
|
||||
const browser = await webkit.launch();
|
||||
const page = await browser.newPage('https://maps.google.com', {
|
||||
const context = await browser.newContext({
|
||||
viewport: iPhone11.viewport,
|
||||
userAgent: iPhone11.userAgent,
|
||||
geolocation: { longitude: 12.492507, latitude: 41.889938 },
|
||||
permissions: { 'https://www.google.com': ['geolocation'] }
|
||||
});
|
||||
|
||||
const page = await context.newPage();
|
||||
await page.goto('https://maps.google.com');
|
||||
await page.click('text="Your location"');
|
||||
await page.waitForRequest(/.*preview\/pwa/);
|
||||
await page.screenshot({ path: 'colosseum-iphone.png' });
|
||||
@ -79,12 +82,14 @@ const pixel2 = devices['Pixel 2'];
|
||||
|
||||
(async () => {
|
||||
const browser = await chromium.launch();
|
||||
const page = await browser.newPage('https://maps.google.com', {
|
||||
const context = await browser.newContext({
|
||||
viewport: pixel2.viewport,
|
||||
userAgent: pixel2.userAgent,
|
||||
geolocation: { longitude: 12.492507, latitude: 41.889938 },
|
||||
permissions: { 'https://www.google.com': ['geolocation'] }
|
||||
});
|
||||
const page = await context.newPage();
|
||||
await page.goto('https://maps.google.com');
|
||||
await page.click('text="Your location"');
|
||||
await page.waitForRequest(/.*pwa\/net.js.*/);
|
||||
await page.screenshot({ path: 'colosseum-android.png' });
|
||||
@ -101,7 +106,9 @@ const { firefox } = require('playwright');
|
||||
|
||||
(async () => {
|
||||
const browser = await firefox.launch();
|
||||
const page = await browser.newPage('https://www.example.com/');
|
||||
const context = await browser.newContext();
|
||||
const page = await context.newPage();
|
||||
await page.goto('https://www.example.com/');
|
||||
const dimensions = await page.evaluate(() => {
|
||||
return {
|
||||
width: document.documentElement.clientWidth,
|
||||
|
Loading…
Reference in New Issue
Block a user