This commit is contained in:
Vasilii Artemchuk 2020-05-07 22:33:35 +03:00 коммит произвёл GitHub
Родитель d39ec35cd7
Коммит 4c4fa8d38c
Не найден ключ, соответствующий данной подписи
Идентификатор ключа GPG: 4AEE18F83AFDEB23
10 изменённых файлов: 45 добавлений и 46 удалений

Просмотреть файл

@ -157,23 +157,23 @@ npm run ftest -- --break-on-failure
- To run a specific test, substitute the `it` with `fit` (mnemonic rule: '*focus it*'):
```js
...
// Using "fit" to run specific test
fit('should work', async ({server, page}) => {
...
// Using "fit" to run specific test
fit('should work', async ({server, page}) => {
const response = await page.goto(server.EMPTY_PAGE);
expect(response.ok).toBe(true);
});
});
```
- To disable a specific test, substitute the `it` with `xit` (mnemonic rule: '*cross it*'):
```js
...
// Using "xit" to skip specific test
xit('should work', async ({server, page}) => {
...
// Using "xit" to skip specific test
xit('should work', async ({server, page}) => {
const response = await page.goto(server.EMPTY_PAGE);
expect(response.ok).toBe(true);
});
});
```
- To run tests in non-headless (headful) mode:

Просмотреть файл

@ -100,7 +100,7 @@ const { firefox } = require('playwright');
height: document.documentElement.clientHeight,
deviceScaleFactor: window.devicePixelRatio
}
})
});
console.log(dimensions);
await browser.close();

Просмотреть файл

@ -1892,9 +1892,9 @@ const { firefox } = require('playwright'); // Or 'chromium' or 'webkit'.
An example of getting text from an iframe element:
```js
const frame = page.frames().find(frame => frame.name() === 'myframe');
const text = await frame.$eval('.selector', element => element.textContent);
console.log(text);
const frame = page.frames().find(frame => frame.name() === 'myframe');
const text = await frame.$eval('.selector', element => element.textContent);
console.log(text);
```
<!-- GEN:toc -->

Просмотреть файл

@ -46,8 +46,7 @@ const context = await browser.newContext({
});
// Resize viewport for individual page
await page.setViewportSize(
{ 'width': 1600, 'height': 1200 });
await page.setViewportSize({ width: 1600, height: 1200 });
// Emulate high-DPI
const context = await browser.newContext({
@ -155,7 +154,7 @@ const context = await browser.newContext({
Change the location later:
```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.

Просмотреть файл

@ -207,10 +207,10 @@ Simple version produces a single character. This character is case-sensitive, so
```js
// <input id=name></input>
// <input id=name>
await page.press('#name', 'Shift+A');
// <input id=name></input>
// <input id=name>
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.
```
```sh
npm i playwright
```

Просмотреть файл

@ -7,9 +7,9 @@ This test server is used internally by Playwright to test Playwright itself.
```js
const {TestServer} = require('.');
(async(() => {
const httpServer = await TestServer.create(__dirname, 8000),
const httpsServer = await TestServer.createHTTPS(__dirname, 8001)
(async () => {
const httpServer = await TestServer.create(__dirname, 8000);
const httpsServer = await TestServer.createHTTPS(__dirname, 8001);
httpServer.setRoute('/hello', (req, res) => {
res.end('Hello, world!');
});