It is not only a fully functional graph visualization library, but also an explorer of data relationships.
!!!###!!!title=Use Midscene.js to simplify testing with AI——VisActor/VChart tutorial documents!!!###!!!!!!###!!!description=[Midscene.js](https://midscenejs.com) is an automation tool powered by multimodal AI for UI testing. Midscene.js makes UI automation test scripts easier to write and maintain.<div style="width: 40%; text-align: center;"> <video src="https://midscenejs.com/introduction/Midscene.mp4" controls style="width: 100%"></video></div>When using VisActor products, Midscene.js's action capabilities can help quickly complete UI test cases. The query and assert functionalities provided by Midscene.js also make writing test cases more convenient.!!!###!!!
Using Midscene.js to Simplify Testing with AI
Midscene.js is an automation tool powered by multimodal AI for UI testing. Midscene.js makes UI automation test scripts easier to write and maintain.
When using VisActor products, Midscene.js's action capabilities can help quickly complete UI test cases. The query and assert functionalities provided by Midscene.js also make writing test cases more convenient.
Configure model parameters according to the documentation: https://midscenejs.com/en/model-provider.html (UI-TARS or Qwen-2.5-VL models are recommended since VisActor components are implemented based on canvas, so gpt-4o model cannot be used)
Clone the repository and run pnpm install to install dependencies
Create a .env file and configure the AI model
# replace by your own, example(qwen):
OPENAI_BASE_URL="https://dashscope.aliyuncs.com/compatible-mode/v1"
OPENAI_API_KEY="YOUR_TOKEN"
MIDSCENE_MODEL_NAME="qwen-vl-max-latest"
MIDSCENE_USE_QWEN_VL=1
Run the tests
# run vchart demo
pnpm run start-test-vchart
# run vtable demo
pnpm run start-test-vtable
Example Code Explanation
Test code is in test/vchart-test.ts
Create browser & page, open test URL
const browser = await puppeteer.launch({
headless: false, // 'true' means we can't see the browser window
args: ['--no-sandbox', '--disable-setuid-sandbox']
});
const page = await browser.newPage();
await page.setViewport({
width: 1280,
height: 768,
deviceScaleFactor: os.platform() === 'darwin' ? 2 : 1 // this is used to avoid flashing on UI Mode when doing screenshot on Mac
});
await page.goto(URL);
// init Midscene agent
const agent = new PuppeteerAgent(page);
// Click the USA legend in the line chart
await agent.aiAction('Click the USA legend in the line chart');
// Get all Y-axis labels in the line chart
const items = await agent.aiQuery('Get all Y-axis labels in the line chart');
console.log('Y-axis labels:', items);
// Assert that the maximum Y-axis label in the line chart is 20000. Returns a Promise that resolves to void when assertion passes; throws an error with errorMsg and AI-generated reason if assertion fails
await agent.aiAssert('Assert that the maximum Y-axis label in the line chart is 20000');