-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtest-visual-map.cjs
More file actions
66 lines (54 loc) · 2.33 KB
/
test-visual-map.cjs
File metadata and controls
66 lines (54 loc) · 2.33 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
// Use dynamic import for ES modules
async function testVisualElementMap() {
console.log('🧪 Testing devtools_visual_element_map functionality...');
const { SupapupServer } = await import('./dist/core/index.js');
const server = new SupapupServer();
try {
// Navigate to a test page
console.log('📍 Navigating to example.com...');
const navResult = await server.callTool('browser_navigate', { url: 'https://example.com' });
console.log('✅ Navigation result:', navResult.content[0].text.substring(0, 100) + '...');
// Test the visual element map
console.log('🗺️ Creating visual element map...');
const mapResult = await server.callTool('devtools_visual_element_map', {});
console.log('📊 Visual element map results:');
console.log('- Content items:', mapResult.content.length);
mapResult.content.forEach((item, index) => {
if (item.type === 'image') {
console.log(`- Item ${index}: Image (${item.data.length} chars)`);
} else if (item.type === 'text') {
console.log(`- Item ${index}: Text`);
console.log(item.text);
}
});
// Test if the functions mentioned in the output actually work
console.log('\n🔍 Testing interaction methods...');
// Check if the response mentions execute_action (should)
const textContent = mapResult.content.find(item => item.type === 'text')?.text || '';
const hasExecuteAction = textContent.includes('execute_action');
const hasOldHelpers = textContent.includes('window.__AGENT_PAGE__.clickElement');
console.log('✅ Response mentions execute_action:', hasExecuteAction);
console.log('❌ Response mentions old helper functions:', hasOldHelpers);
if (hasExecuteAction && !hasOldHelpers) {
console.log('🎉 SUCCESS: Visual element map now uses correct MCP tools!');
} else {
console.log('⚠️ ISSUE: Visual element map still has problems');
}
} catch (error) {
console.error('❌ Test failed:', error.message);
} finally {
// Clean up
try {
await server.callTool('browser_close', {});
} catch (e) {
// Ignore cleanup errors
}
}
}
testVisualElementMap().then(() => {
console.log('🏁 Test completed');
process.exit(0);
}).catch(error => {
console.error('💥 Test crashed:', error);
process.exit(1);
});