playwright
Advanced tools
Comparing version 0.11.1-next.1583306456276 to 0.11.1-next.1583349510791
{ | ||
"name": "playwright", | ||
"version": "0.11.1-next.1583306456276", | ||
"version": "0.11.1-next.1583349510791", | ||
"description": "A high-level API to automate web browsers", | ||
@@ -15,4 +15,4 @@ "repository": "github:Microsoft/playwright", | ||
"dependencies": { | ||
"playwright-core": "=0.11.1-next.1583306456276" | ||
"playwright-core": "=0.11.1-next.1583349510791" | ||
} | ||
} |
@@ -77,27 +77,4 @@ # Playwright | ||
And here is the same script for Chrome on Android. | ||
#### Evaluate in browser context | ||
```js | ||
const { chromium, devices } = require('playwright'); | ||
const pixel2 = devices['Pixel 2']; | ||
(async () => { | ||
const browser = await chromium.launch(); | ||
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' }); | ||
await browser.close(); | ||
})(); | ||
``` | ||
#### Evaluate script | ||
This code snippet navigates to example.com in Firefox, and executes a script in the page context. | ||
@@ -126,2 +103,25 @@ | ||
#### Intercept network requests | ||
This code snippet sets up network interception for a WebKit page to log all network requests. | ||
```js | ||
const { webkit } = require('playwright'); | ||
(async () => { | ||
const browser = await webkit.launch(); | ||
const context = await browser.newContext(); | ||
const page = await context.newPage(); | ||
// Log and continue all network requests | ||
page.route('**', request => { | ||
console.log(request.url()); | ||
request.continue(); | ||
}); | ||
await page.goto('http://todomvc.com'); | ||
await browser.close(); | ||
})(); | ||
``` | ||
## Contributing | ||
@@ -128,0 +128,0 @@ |
14118