-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtest-detector-direct.js
More file actions
38 lines (31 loc) · 1.16 KB
/
test-detector-direct.js
File metadata and controls
38 lines (31 loc) · 1.16 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
const { chromium } = require('playwright');
async function testDetectorDirect() {
const browser = await chromium.launch({ headless: true });
const page = await browser.newPage();
await page.setContent(`
<html>
<body>
<button id="test-btn">Click Me</button>
<input type="text" id="test-input" placeholder="Enter text">
<input type="email" name="email" required>
<a href="#" id="test-link">Test Link</a>
<button type="submit">Submit</button>
</body>
</html>
`);
// Test the actual compiled JavaScript
const { AIElementDetector } = require('./dist/detectors/AIElementDetector');
const detector = new AIElementDetector();
// Call the private method directly (for testing)
console.log('selectorPatterns size:', detector.selectorPatterns?.size);
// Try detecting elements
const result = await detector.detectInteractiveElements(page);
console.log('Elements found:', result.elements.length);
console.log('Elements:', result.elements.map(el => ({
type: el.type,
selector: el.selector,
text: el.text
})));
await browser.close();
}
testDetectorDirect().catch(console.error);