Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/emilhein/puppeteer-cmp-clicker
Helper function to click a cmp popup widget
https://github.com/emilhein/puppeteer-cmp-clicker
Last synced: 28 days ago
JSON representation
Helper function to click a cmp popup widget
- Host: GitHub
- URL: https://github.com/emilhein/puppeteer-cmp-clicker
- Owner: emilhein
- Created: 2022-04-21T16:01:26.000Z (over 2 years ago)
- Default Branch: main
- Last Pushed: 2022-04-25T15:44:10.000Z (over 2 years ago)
- Last Synced: 2024-09-30T16:27:44.722Z (about 1 month ago)
- Language: JavaScript
- Size: 59.6 KB
- Stars: 4
- Watchers: 1
- Forks: 0
- Open Issues: 2
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
[![Build Status](https://app.travis-ci.com/emilhein/puppeteer-cmp-clicker.svg?branch=main)](https://app.travis-ci.com/emilhein/puppeteer-cmp-clicker)
## What do i do
For now i only have one function
#### 1. clickCmp({page, customKnownIds = [], customKnownClasses = []})
This function takes a puppeteer page as an argument and tries its best to click a cmp if its there
## Get started
You need to have puppeteer or puppeteer-core install, but this package should work with your existing puppeteer setup```js
const { clickCmp } = require("puppeteer-cmp-clicker");
const chromium = require('chrome-aws-lambda') // or normal puppeteer packagelet browser = await chromium.puppeteer.launch({
args: chromium.args,
defaultViewport: chromium.defaultViewport,
executablePath: await chromium.executablePath,
headless: true, // chromium.headless,
ignoreHTTPSErrors: true,
});let page = await browser.newPage();
await page.goto('https://nytimes.com', { waitUntil: 'networkidle0' });
let res = await clickCmp({ page })
// Output
// The CMP of nytimes should be clicked```