Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/k03mad/puppeteer-extra-commands
Tiny library with additional puppeteer commands
https://github.com/k03mad/puppeteer-extra-commands
Last synced: 16 days ago
JSON representation
Tiny library with additional puppeteer commands
- Host: GitHub
- URL: https://github.com/k03mad/puppeteer-extra-commands
- Owner: k03mad
- License: unlicense
- Archived: true
- Created: 2018-10-09T13:41:07.000Z (about 6 years ago)
- Default Branch: master
- Last Pushed: 2020-09-02T17:43:40.000Z (about 4 years ago)
- Last Synced: 2024-08-01T05:22:56.898Z (3 months ago)
- Language: JavaScript
- Homepage:
- Size: 430 KB
- Stars: 1
- Watchers: 3
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
## Tiny library with additional puppeteer commands
Use commands this way:
```js
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](https://github.com/k03mad/puppeteer-extra-commands/blob/master/commands/clickForNavigation.js)\
> [fillForm](https://github.com/k03mad/puppeteer-extra-commands/blob/master/commands/fillForm.js)\
> [getAttribute](https://github.com/k03mad/puppeteer-extra-commands/blob/master/commands/getAttribute.js)\
> [getCssProperty](https://github.com/k03mad/puppeteer-extra-commands/blob/master/commands/getCssProperty.js)\
> [getTextContent](https://github.com/k03mad/puppeteer-extra-commands/blob/master/commands/getInnerText.js)\
> [getWindowOffset](https://github.com/k03mad/puppeteer-extra-commands/blob/master/commands/getWindowOffset.js)\
> [saveScreenshot](https://github.com/k03mad/puppeteer-extra-commands/blob/master/commands/saveScreenshot.js)\
> [scrollWindowBy](https://github.com/k03mad/puppeteer-extra-commands/blob/master/commands/scrollWindowBy.js)\
> [switchToFrameIncludes](https://github.com/k03mad/puppeteer-extra-commands/blob/master/commands/switchToFrameIncludes.js)A little more abstract examples:
```js
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
```bash
# run all
npm run test# or one test
npm run one-test --test=getText# disable headless mode
npm run one-test --test=getText --show
```