Magnitude AI
Magnitude is an AI browser automation framework that allows you to run browser automation scripts using AI models. It uses Vision AI to understand the webpage and interact with it, making it possible to automate tasks that require visual understanding.
You can use the framework to automate tasks on webpages, test functionality, extract data and verify any specific behavior on the webpage, just like a normal user would do.
Running Magnitude AI tests on TestingBot
To run Magnitude AI tests on TestingBot, you can use the following steps and example code to get started:
npx create-magnitude-app
- Next, modify the
src/index.tsx
file that was generated, add abrowser
option to thestartBrowserAgent
function.
Copy
import { startBrowserAgent } from "magnitude-core";
import z from 'zod';
import dotenv from 'dotenv';
dotenv.config();
const capabilities = {
'tb:options': {
key: process.env.TESTINGBOT_KEY,
secret: process.env.TESTINGBOT_SECRET,
},
browserName: 'chrome',
browserVersion: 'latest'
}
async function main() {
const agent = await startBrowserAgent({
// Starting URL for agent
url: 'https://docs.magnitude.run/getting-started/quickstart',
// Show thoughts and actions
narrate: true,
browser: {
cdp: `wss://cloud.testingbot.com/puppeteer?capabilities=${encodeURIComponent(JSON.stringify(capabilities))}`
}
});
// Intelligently extract data based on the DOM content matching a provided zod schema
const gettingStarted = await agent.extract('Extract how to get started with Magnitude', z.object({
// Agent can extract existing data or new insights
difficulty: z.enum(['easy', 'medium', 'hard']),
steps: z.array(z.string()),
}));
// Navigate to a new URL
await agent.nav('https://magnitasks.com');
// Magnitude can handle high-level tasks
await agent.act('Create a task', {
// Optionally pass data that the agent will use where appropriate
data: {
title: 'Get started with Magnitude',
description: gettingStarted.steps.map(step => `• ${step}`).join('\n')
}
});
// It can also handle low-level actions
await agent.act('Drag "Get started with Magnitude" to the top of the in progress column');
// Stop agent and browser
await agent.stop();
}
main();
When you run this example, the Magnitude AI agent will use a remote TestingBot browser to interact with. Results will appear on your machine.