Code snippets
The Write javascript step lets you extend axiom.ai with custom code. The snippets in this section have been tried and tested in real automations, and many came from user requests. They're split into two categories: standard JavaScript that runs against the page, and Puppeteer snippets that drive the browser through Puppeteer's API.
Snippet categories
Javascript
Data snippets
JavaScript snippets for manipulating data in axiom.ai automations, including dates, timestamps, constants, CSV exports, and regex transformations.
Interaction snippets
JavaScript snippets for interacting with page elements in axiom.ai automations, including clicks, dropdowns, text entry, Shadow DOM access, and event listeners.
Navigation snippets
JavaScript snippets for moving through browser history in axiom.ai automations, including going back one or several pages.
Network snippets
JavaScript snippets for inspecting and capturing network activity in axiom.ai automations using the Performance API.
Page manipulation snippets
JavaScript snippets for manipulating the current page during an axiom.ai automation, including hiding elements that block other interactions.
Scrape snippets
JavaScript snippets for scraping data in axiom.ai automations, including HTML tables, element attributes, page body, and meta tags.
Puppeteer
Interaction snippets
Puppeteer snippets for interacting with page elements in axiom.ai automations, including scrolling and filtering elements with the locator API.
Network snippets
Puppeteer snippets for axiom.ai automations to intercept, log, or block network requests by URL, file extension, or resource type.
Other
JavaScript snippets
Ready-to-use JavaScript snippets for the Write javascript step, organised by category covering data, interaction, navigation, network, and scraping.
Puppeteer snippets
Ready-to-use Puppeteer snippets for the Write javascript step in axiom.ai, organised into interaction and network categories.
Run in app
The Run in app toggle on the Write javascript step runs your code inside the desktop application instead of inside the page. This is required for any snippet that uses the Puppeteer API. It's also useful when:
- You don't want your code to interact with the page's own scripts. Running in the page can trigger the page's event listeners or clash with its function and variable names.
- You need access to Node.js APIs (the
fsmodule, for example) that aren't available in a browser context.
There are trade-offs:
- You can't access elements, functions, or variables from the page being automated.
- Console output isn't visible during the run when
Run in appis enabled.
Note:
Run in apponly works on desktop runs. Cloud runs always execute scripts in the page context.
Need help? Contact support or ask a question in our Reddit community.