-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtest-ai.js
More file actions
41 lines (34 loc) · 1.53 KB
/
Copy pathtest-ai.js
File metadata and controls
41 lines (34 loc) · 1.53 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
const puppeteer = require('puppeteer');
(async () => {
const browser = await puppeteer.launch({ headless: 'new' });
const page = await browser.newPage();
page.on('console', msg => console.log('PAGE LOG:', msg.text()));
page.on('pageerror', error => console.log('PAGE ERROR:', error.message));
page.on('requestfailed', request => {
console.log('REQUEST FAILED:', request.url(), request.failure().errorText);
});
await page.goto('http://localhost:5173', { waitUntil: 'networkidle2' });
console.log('Page loaded, waiting 2 seconds...');
await new Promise(r => setTimeout(r, 2000));
console.log('Clicking Sparkles / AI button...');
// The sparkles button is in the TopBar. We can find it by its lucide-sparkles class or text.
// Actually, it has a title="AI Asistan". Let's click by title or by class.
const aiButton = await page.$('button[title="AI Asistan"], .lucide-sparkles');
if (aiButton) {
// try to get the parent button if it's the svg
await page.evaluate(() => {
const btn = document.querySelector('.lucide-sparkles').closest('button');
if (btn) btn.click();
});
} else {
// fallback, just query selector
await page.evaluate(() => {
const btns = Array.from(document.querySelectorAll('button'));
const aiBtn = btns.find(b => b.innerHTML.includes('lucide-sparkles'));
if (aiBtn) aiBtn.click();
});
}
console.log('Clicked, waiting 5 seconds for WebLLM to initialize...');
await new Promise(r => setTimeout(r, 5000));
await browser.close();
})();