2.2.20 • Published 4 years ago

puppeteer-extra-commands v2.2.20

Weekly downloads
4
License
Unlicense
Repository
github
Last release
4 years ago

Tiny library with additional puppeteer commands

Use commands this way:

const puppeteer = require('puppeteer');
const p = require('puppeteer-extra-commands');

(async () => {
    const browser = await puppeteer.launch();
    const [page] = await browser.pages();

    await page.goto('http://example.com');
    const [text] = await p.getTextContent(page, 'h1'); // 'Example Domain'
    const [prop] = await p.getCssProperty(page, 'h1', 'font-size'); // '32px'
    const [href] = await p.getAttribute(page, 'a', 'href'); // 'http://www.iana.org/domains/example'

    await browser.close();
})();

All available commands:

clickForNavigation\ fillForm\ getAttribute\ getCssProperty\ getTextContent\ getWindowOffset\ saveScreenshot\ scrollWindowBy\ switchToFrameIncludes

A little more abstract examples:

const frame = await p.switchToFrameIncludes(page, 'url', 'mysite.hello.com/iframe.html');
const text = await p.getTextContent(frame, '.titles'); // ['title1', 'title2', 'title3']
// ...
const frame = await p.switchToFrameIncludes(page, 'name', 'auth');
await p.scrollWindowBy(frame, {y: 100});
const newPosition = await p.getWindowOffset(frame); // {x: 0; y: 100}
// ...
await p.fillForm(page, [
    {field: '.login', text: 'maggy1998'},
    {field: '.password', text: 'flower'},
    {click: '.button'},
]);

Tests

# run all
npm run test

# or one test
npm run one-test --test=getText

# disable headless mode
npm run one-test --test=getText --show
2.2.20

4 years ago

2.2.19

4 years ago

2.2.18

4 years ago

2.2.17

4 years ago

2.2.15

5 years ago

2.2.14

5 years ago

2.2.13

5 years ago

2.2.12

5 years ago

2.2.11

5 years ago

2.2.10

5 years ago

2.2.9

5 years ago

2.2.8

5 years ago

2.2.7

5 years ago

2.2.6

5 years ago

2.2.5

5 years ago

2.2.4

6 years ago

2.2.3

6 years ago

2.2.2

6 years ago

2.2.1

6 years ago

2.2.0

6 years ago

2.1.0

6 years ago

2.0.2

6 years ago

2.0.0

6 years ago

1.1.0

6 years ago

1.0.1

6 years ago

1.0.0

6 years ago

0.1.5

6 years ago

0.1.4

6 years ago

0.1.3

6 years ago

0.1.2

6 years ago

0.1.1

6 years ago

0.1.0

6 years ago