59 lines
2.4 KiB
JavaScript
59 lines
2.4 KiB
JavaScript
import puppeteer from 'puppeteer-core'
|
|
const CHROME = '/Applications/Google Chrome.app/Contents/MacOS/Google Chrome'
|
|
const URL = 'http://localhost:5173/'
|
|
const b = await puppeteer.launch({
|
|
executablePath: CHROME, headless: 'new',
|
|
args: ['--no-sandbox','--use-gl=swiftshader','--enable-unsafe-swiftshader','--window-size=1400,900'],
|
|
})
|
|
try {
|
|
const p = await b.newPage()
|
|
await p.setViewport({ width: 1400, height: 900 })
|
|
const errs = []
|
|
p.on('pageerror', (e) => errs.push('PAGEERROR: ' + e.message))
|
|
|
|
await p.goto(URL, { waitUntil: 'networkidle2', timeout: 30000 })
|
|
await new Promise((r) => setTimeout(r, 2500))
|
|
|
|
// 1) 初期应为空态
|
|
const init = await p.evaluate(() => {
|
|
const empty = document.querySelector('.empty')
|
|
const animSelect = document.querySelector('.topbar select')
|
|
const sysNames = [...document.querySelectorAll('.sys-name')].map(e => e.textContent)
|
|
return {
|
|
emptyShown: !!empty,
|
|
emptyTitle: empty?.querySelector('.empty-title')?.textContent || null,
|
|
hasAnimSelect: !!animSelect,
|
|
systemCount: sysNames.length,
|
|
loadBtn: [...document.querySelectorAll('.topbar button')].map(e=>e.textContent).join('|'),
|
|
}
|
|
})
|
|
|
|
// 2) 点击"加载示例骨骼"
|
|
await p.evaluate(() => {
|
|
const btn = [...document.querySelectorAll('.topbar button')].find((b) => b.textContent.includes('加载示例骨骼'))
|
|
if (btn) btn.click()
|
|
})
|
|
await new Promise((r) => setTimeout(r, 3000))
|
|
|
|
const after = await p.evaluate(() => {
|
|
const animSelect = document.querySelector('.topbar select')
|
|
const opts = animSelect ? [...animSelect.querySelectorAll('option')].map(o => o.textContent) : []
|
|
return {
|
|
emptyShown: !!document.querySelector('.empty'),
|
|
animOptionCount: opts.length,
|
|
firstOpts: opts.slice(0, 6),
|
|
sysCount: [...document.querySelectorAll('.sys-name')].length,
|
|
hud: document.querySelector('.hud')?.innerText?.replace(/\s+/g,' ').trim() || null,
|
|
boneSelect: document.querySelector('.group select')?.textContent?.split('\n').map(s=>s.trim()).filter(Boolean).slice(0,8) || [],
|
|
}
|
|
})
|
|
|
|
await p.screenshot({ path: '/tmp/empty-after-load.png' })
|
|
console.log('=== 初始(应空态) ===')
|
|
console.log(JSON.stringify(init, null, 2))
|
|
console.log('=== 加载骨骼后 ===')
|
|
console.log(JSON.stringify(after, null, 2))
|
|
console.log('=== 错误 ===')
|
|
console.log(errs.join('\n') || '(无)')
|
|
} finally { await b.close() }
|