With Chrome 59 came the ability to run a Headless Chrome. Controlling it via code isn’t that easy nor elegant. Enter Chromeless (not be confused with Mozilla’s Chromeless):
With Chromeless you can control Chrome (open website, click elements, fill out forms…) using an elegant API. This is useful for integration tests or any other scenario where you’d need to script a real browser.
Runs locally or headless on AWS Lambda. The API to control it is really elegant, as the code is very easy to understand:
const { Chromeless } = require('chromeless');
async function run() {
const chromeless = new Chromeless();
const screenshot = await chromeless
.goto('https://www.google.com')
.type('chromeless', 'input[name="q"]')
.press(13)
.wait('#resultStats')
.screenshot();
console.log(screenshot); // prints local file path or S3 url
await chromeless.end();
}
run().catch(console.error.bind(console));