ofc01/sentinel-zero
0
1const puppeteer = require('puppeteer-core');2 3(async () => {4 console.log("Launching headed Chrome browser to test clicks...");5 try {6 const browser = await puppeteer.launch({7 executablePath: 'C:\\Program Files\\Google\\Chrome\\Application\\chrome.exe',8 headless: false, // Run headed as requested9 args: ['--no-sandbox', '--disable-setuid-sandbox', '--window-size=1280,800']10 });11 const page = await browser.newPage();12 await page.setViewport({ width: 1280, height: 800 });13 14 page.on('console', msg => console.log(`[BROWSER LOG] ${msg.type().toUpperCase()}: ${msg.text()}`));15 page.on('pageerror', err => console.error(`[BROWSER ERROR] ${err.toString()}`));16 17 console.log("Navigating to http://127.0.0.1:8001/ ...");18 await page.goto('http://127.0.0.1:8001/', { waitUntil: 'networkidle0', timeout: 15000 });19 20 console.log("Page loaded. Testing clicks...");21 22 // 1. Check if elements exist23 const minimizeBtns = await page.$$('.btn-minimize');24 if (minimizeBtns.length > 0) {25 console.log(`Found ${minimizeBtns.length} minimize buttons. Attempting to click the first one...`);26 try {27 const logs = [];28 page.on('console', msg => logs.push(msg.text()));29 30 await minimizeBtns[0].click();31 console.log("Minimize button clicked via Puppeteer Simulated Click.");32 33 // Verify DOM mutation34 await page.waitForFunction(() => {35 return document.querySelector('.minimized-card') !== null;36 }, { timeout: 2000 });37 console.log("SUCCESS: The card successfully minimized into the dock.");38 39 } catch (err) {40 console.error("FAILED to click Minimize button! Error:", err.message);41 42 const coveringElement = await page.evaluate(() => {43 const btn = document.querySelector('.btn-minimize');44 const rect = btn.getBoundingClientRect();45 const x = rect.left + rect.width / 2;46 const y = rect.top + rect.height / 2;47 const topElement = document.elementFromPoint(x, y);48 if (topElement) {49 return {50 tag: topElement.tagName,51 id: topElement.id,52 className: topElement.className53 };54 }55 return null;56 });57 console.log("Element covering the minimize button is:", coveringElement);58 }59 }60 61 // Let's also check if scrolling works62 console.log("Evaluating document pointer-events and z-indexes...");63 const diagnosis = await page.evaluate(() => {64 const splunkSection = document.getElementById('sec-splunk');65 const splunkCard = splunkSection.querySelector('.glass-panel');66 const splunkLoading = splunkSection.querySelector('.loading-state');67 68 return {69 splunkSectionVisibility: window.getComputedStyle(splunkSection).visibility,70 splunkSectionOpacity: window.getComputedStyle(splunkSection).opacity,71 splunkSectionEvents: window.getComputedStyle(splunkSection).pointerEvents,72 splunkCardEvents: splunkCard ? window.getComputedStyle(splunkCard).pointerEvents : null,73 loadingEvents: splunkLoading ? window.getComputedStyle(splunkLoading).pointerEvents : null,74 };75 });76 console.log("CSS Diagnosis:", diagnosis);77 78 console.log("Closing browser in 2 seconds...");79 await new Promise(r => setTimeout(r, 2000));80 await browser.close();81 console.log("Browser closed.");82 83 } catch (error) {84 console.error("Puppeteer Script Error:", error);85 }86})();87 