Run scripts

There are two ways to run a Code Dashboard script: from your own local environment, or from the axiom.ai Live editor.

Run a script locally


Once your script is connected to axiom.ai (see create scripts), run it from your local environment with Node.js.

  1. Install Puppeteer in your project:
    npm install puppeteer-core
    
  2. Save your script. For example, scrape.js:
    const puppeteer = require('puppeteer-core');
    
    (async () => {
      const browser = await puppeteer.connect({
        browserWSEndpoint: 'wss://cdp-lb.axiom.ai/?token=YOUR_API_KEY'
      });
      const page = await browser.newPage();
      await page.goto('https://axiom.ai');
      console.log(await page.title());
      await browser.close();
    })();
    
  3. Run it with Node:
    node scrape.js
    

The script connects to axiom.ai's hosted browser and runs against it. Sprinkle console.log() calls through your script while you're developing so you can monitor progress and catch issues from the terminal.

Tip: To watch the script in action, open run reports in the dashboard. Each in-progress run has a Watch link that opens a live view of the hosted browser.

Run a script in the Live editor


The Live editor lets you run scripts without any local setup, so it's useful for quick experiments and for sharing a script with someone who doesn't have Node.js installed.

  1. Open the Live editor from the dashboard.
  2. Paste the script into the code editor.
  3. Click Run.
  4. Open the browser panel to watch the run.