Working with Puppeteer

# What is the Puppeteer API?


Puppeteer is a library provided by Google that provides a high-level API to control Chrome/Chromium over the DevTools Protocol. You can learn more about Puppeteer over at Puppeteer (opens new window)

# Using the Puppeteer API


The Axiom.ai app is built on top of Google's Puppeteer framework - this means that some of the functions provided by the library can be used in your automations when using the Write JavaScript step.

When using the Write JavaScript step, you will need to ensure that the "Run in app" toggle and "Run in app" checkbox are enabled.

# Supported methods


We support Page Interactions (opens new window) methods from Puppeteer. Other methods will not be available for use within the Write JavaScript step.

# Examples using Puppeteer


To perform page interactions programmatically with Puppeteer, you will need to work out which selectors you need to use. "Inspect" in Chrome DevTools can be used to get this information. Example selectors are provided below, but will need to be changed for your use case.

# Clicking a button

await page.click('#button')

# Filling a text input

await page.locator('input.name').fill('Hello, world!');

# Retrieving an element by text

For more information, see Text selector (opens new window).

const element = await page.waitForSelector('div ::-p-text(Submit)');

# Using custom selectors

const mySelector = 'input';

const element = await page.waitForSelector(`form.${mySelector}`);