docs: some syntax fixes (#2116)
This commit is contained in:
parent
d39ec35cd7
commit
4c4fa8d38c
|
|
@ -157,23 +157,23 @@ npm run ftest -- --break-on-failure
|
||||||
- To run a specific test, substitute the `it` with `fit` (mnemonic rule: '*focus it*'):
|
- To run a specific test, substitute the `it` with `fit` (mnemonic rule: '*focus it*'):
|
||||||
|
|
||||||
```js
|
```js
|
||||||
...
|
...
|
||||||
// Using "fit" to run specific test
|
// Using "fit" to run specific test
|
||||||
fit('should work', async ({server, page}) => {
|
fit('should work', async ({server, page}) => {
|
||||||
const response = await page.goto(server.EMPTY_PAGE);
|
const response = await page.goto(server.EMPTY_PAGE);
|
||||||
expect(response.ok).toBe(true);
|
expect(response.ok).toBe(true);
|
||||||
});
|
});
|
||||||
```
|
```
|
||||||
|
|
||||||
- To disable a specific test, substitute the `it` with `xit` (mnemonic rule: '*cross it*'):
|
- To disable a specific test, substitute the `it` with `xit` (mnemonic rule: '*cross it*'):
|
||||||
|
|
||||||
```js
|
```js
|
||||||
...
|
...
|
||||||
// Using "xit" to skip specific test
|
// Using "xit" to skip specific test
|
||||||
xit('should work', async ({server, page}) => {
|
xit('should work', async ({server, page}) => {
|
||||||
const response = await page.goto(server.EMPTY_PAGE);
|
const response = await page.goto(server.EMPTY_PAGE);
|
||||||
expect(response.ok).toBe(true);
|
expect(response.ok).toBe(true);
|
||||||
});
|
});
|
||||||
```
|
```
|
||||||
|
|
||||||
- To run tests in non-headless (headful) mode:
|
- To run tests in non-headless (headful) mode:
|
||||||
|
|
|
||||||
|
|
@ -100,7 +100,7 @@ const { firefox } = require('playwright');
|
||||||
height: document.documentElement.clientHeight,
|
height: document.documentElement.clientHeight,
|
||||||
deviceScaleFactor: window.devicePixelRatio
|
deviceScaleFactor: window.devicePixelRatio
|
||||||
}
|
}
|
||||||
})
|
});
|
||||||
console.log(dimensions);
|
console.log(dimensions);
|
||||||
|
|
||||||
await browser.close();
|
await browser.close();
|
||||||
|
|
|
||||||
|
|
@ -1892,9 +1892,9 @@ const { firefox } = require('playwright'); // Or 'chromium' or 'webkit'.
|
||||||
An example of getting text from an iframe element:
|
An example of getting text from an iframe element:
|
||||||
|
|
||||||
```js
|
```js
|
||||||
const frame = page.frames().find(frame => frame.name() === 'myframe');
|
const frame = page.frames().find(frame => frame.name() === 'myframe');
|
||||||
const text = await frame.$eval('.selector', element => element.textContent);
|
const text = await frame.$eval('.selector', element => element.textContent);
|
||||||
console.log(text);
|
console.log(text);
|
||||||
```
|
```
|
||||||
|
|
||||||
<!-- GEN:toc -->
|
<!-- GEN:toc -->
|
||||||
|
|
|
||||||
|
|
@ -46,8 +46,7 @@ const context = await browser.newContext({
|
||||||
});
|
});
|
||||||
|
|
||||||
// Resize viewport for individual page
|
// Resize viewport for individual page
|
||||||
await page.setViewportSize(
|
await page.setViewportSize({ width: 1600, height: 1200 });
|
||||||
{ 'width': 1600, 'height': 1200 });
|
|
||||||
|
|
||||||
// Emulate high-DPI
|
// Emulate high-DPI
|
||||||
const context = await browser.newContext({
|
const context = await browser.newContext({
|
||||||
|
|
@ -155,7 +154,7 @@ const context = await browser.newContext({
|
||||||
Change the location later:
|
Change the location later:
|
||||||
|
|
||||||
```js
|
```js
|
||||||
await context.setGeolocation({ longitude: 29.979097, latitude: 31.134256 };
|
await context.setGeolocation({ longitude: 29.979097, latitude: 31.134256 });
|
||||||
```
|
```
|
||||||
|
|
||||||
**Note** you can only change geolocation for all pages in the context.
|
**Note** you can only change geolocation for all pages in the context.
|
||||||
|
|
|
||||||
|
|
@ -207,10 +207,10 @@ Simple version produces a single character. This character is case-sensitive, so
|
||||||
|
|
||||||
|
|
||||||
```js
|
```js
|
||||||
// <input id=name></input>
|
// <input id=name>
|
||||||
await page.press('#name', 'Shift+A');
|
await page.press('#name', 'Shift+A');
|
||||||
|
|
||||||
// <input id=name></input>
|
// <input id=name>
|
||||||
await page.press('#name', 'Shift+ArrowLeft');
|
await page.press('#name', 'Shift+ArrowLeft');
|
||||||
```
|
```
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -14,7 +14,7 @@
|
||||||
|
|
||||||
Use npm or Yarn to install Playwright in your Node.js project. Playwright requires Node.js 10 or higher.
|
Use npm or Yarn to install Playwright in your Node.js project. Playwright requires Node.js 10 or higher.
|
||||||
|
|
||||||
```
|
```sh
|
||||||
npm i playwright
|
npm i playwright
|
||||||
```
|
```
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -7,9 +7,9 @@ This test server is used internally by Playwright to test Playwright itself.
|
||||||
```js
|
```js
|
||||||
const {TestServer} = require('.');
|
const {TestServer} = require('.');
|
||||||
|
|
||||||
(async(() => {
|
(async () => {
|
||||||
const httpServer = await TestServer.create(__dirname, 8000),
|
const httpServer = await TestServer.create(__dirname, 8000);
|
||||||
const httpsServer = await TestServer.createHTTPS(__dirname, 8001)
|
const httpsServer = await TestServer.createHTTPS(__dirname, 8001);
|
||||||
httpServer.setRoute('/hello', (req, res) => {
|
httpServer.setRoute('/hello', (req, res) => {
|
||||||
res.end('Hello, world!');
|
res.end('Hello, world!');
|
||||||
});
|
});
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue