File size: 1,748 Bytes
dbc70ee
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
import puppeteer from 'puppeteer';

(async () => {
  const browser = await puppeteer.launch();
  const page = await browser.newPage();
  
  page.on('console', msg => console.log('BROWSER LOG:', msg.text()));
  page.on('pageerror', error => console.log('BROWSER ERROR:', error.message));
  page.on('requestfailed', request => console.log('REQUEST FAILED:', request.url(), request.failure().errorText));

  try {
    await page.goto('http://localhost:5174/');
    // Wait for landing page and click the first option
    await page.waitForSelector('button');
    const buttons = await page.$$('button');
    await buttons[0].click(); // Select General wealth building
    await new Promise(r => setTimeout(r, 500));
    
    const buttons2 = await page.$$('button');
    await buttons2[0].click(); // Select I'd see it as a buying opportunity
    await new Promise(r => setTimeout(r, 500));
    
    const buttons3 = await page.$$('button');
    await buttons3[0].click(); // Select Cautious
    await new Promise(r => setTimeout(r, 2000));
    
    // Now on dashboard, click a stock to open popup
    const qqqBtn = await page.$x("//span[contains(text(), 'QQQ')]");
    if (qqqBtn.length > 0) {
      await qqqBtn[0].click();
      console.log("Clicked QQQ, waiting for crash...");
    } else {
      console.log("QQQ button not found, trying SPY");
      const spyBtn = await page.$x("//span[contains(text(), 'SPY')]");
      if (spyBtn.length > 0) {
        await spyBtn[0].click();
        console.log("Clicked SPY, waiting for crash...");
      }
    }
    
    await new Promise(r => setTimeout(r, 5000));
    console.log("Done waiting.");
  } catch (e) {
    console.log("Script error:", e);
  } finally {
    await browser.close();
  }
})();