// 选中问题诊断: 真实点击组合画布单元, 截图对比 + 捕获状态 import puppeteer from 'puppeteer-core' const EDGE = 'C:/Program Files (x86)/Microsoft/Edge/Application/msedge.exe' const BASE = 'http://localhost:8000' const token = process.argv[2] const browser = await puppeteer.launch({ executablePath: EDGE, headless: 'new', args: ['--window-size=1440,900', '--enable-unsafe-swiftshader', '--use-gl=angle', '--use-angle=swiftshader'], defaultViewport: { width: 1440, height: 900 }, }) const page = await browser.newPage() page.on('pageerror', e => console.log(`[JS异常] ${String(e).slice(0, 160)}`)) page.on('console', m => { if (m.type() === 'error') console.log(`[console.error] ${m.text().slice(0, 160)}`) }) await page.goto(`${BASE}/combine?token=${encodeURIComponent(token)}`, { waitUntil: 'networkidle2' }) await page.waitForSelector('.lib-item') await page.click('.lib-item') await new Promise(r => setTimeout(r, 600)) // 取画布盒 const box = await (await page.$('.canvas-box')).boundingBox() console.log('canvas-box:', JSON.stringify(box)) // 点击画布几何中心(单一样板居中,必在单元内) await page.mouse.click(box.x + box.width / 2, box.y + box.height / 2) await new Promise(r => setTimeout(r, 300)) await page.screenshot({ path: 'D:/Code/huamenchuang/shots/diag-click-center.png' }) // 在提示行读取画布 hint(含单元数) const hint = await page.$eval('.hud span', el => el.textContent) console.log('hint:', hint) // 再点击右下象限(可能在单元外) await page.mouse.click(box.x + box.width * 0.85, box.y + box.height * 0.85) await new Promise(r => setTimeout(r, 300)) await page.screenshot({ path: 'D:/Code/huamenchuang/shots/diag-click-outside.png' }) // 键盘 Del(若有选中则删除 → 单元数变化可证选中生效) await page.keyboard.press('Delete') await new Promise(r => setTimeout(r, 400)) const hint2 = await page.$eval('.hud span', el => el.textContent) console.log('Del 后 hint:', hint2) await page.screenshot({ path: 'D:/Code/huamenchuang/shots/diag-after-del.png' }) await browser.close() console.log('诊断完成')