首次上传
This commit is contained in:
1 parent
af9bda066c
commit
9b156a32c9
29 files changed
+14567
No files matched your search
@@ -0,0 +1,39 @@
|
||||
import puppeteer from 'puppeteer-core'
|
||||
const CHROME='/Applications/Google Chrome.app/Contents/MacOS/Google Chrome'
|
||||
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('PAGEERR: '+e.message))
|
||||
await p.goto('http://localhost:5173/',{waitUntil:'networkidle2',timeout:30000})
|
||||
await new Promise(r=>setTimeout(r,2500))
|
||||
const r=await p.evaluate(()=>({
|
||||
groupTitles:[...document.querySelectorAll('.group-head')].map(e=>e.textContent.trim()),
|
||||
nsCount:document.querySelectorAll('.ns').length,
|
||||
nsRange:document.querySelectorAll('.ns-range').length,
|
||||
nsNum:document.querySelectorAll('.ns-num').length,
|
||||
// 第一个数值滑块标签+当前值
|
||||
firstNs:(()=>{const e=document.querySelector('.ns');return e?{label:e.querySelector('.ns-label')?.textContent,num:e.querySelector('.ns-num')?.value}:null})(),
|
||||
}))
|
||||
// 改一个数值框:把"速率/秒"的数字框改值
|
||||
const before=await p.evaluate(()=>document.querySelector('.hud')?.innerText)
|
||||
const changed=await p.evaluate(()=>{
|
||||
// 找到 label=速率/秒 的 .ns-num
|
||||
const ns=[...document.querySelectorAll('.ns')].find(n=>n.querySelector('.ns-label')?.textContent.includes('速率'))
|
||||
const num=ns?.querySelector('.ns-num')
|
||||
if(num){ const old=num.value; num.value='150'; num.dispatchEvent(new Event('input',{bubbles:true})); return {changed:true,old,new:num.value} }
|
||||
return {changed:false}
|
||||
})
|
||||
await new Promise(r=>setTimeout(r,2500))
|
||||
const after=await p.evaluate(()=>document.querySelector('.hud')?.innerText)
|
||||
const rateVal=await p.evaluate(()=>{const ns=[...document.querySelectorAll('.ns')].find(n=>n.querySelector('.ns-label')?.textContent.includes('速率'));return ns?.querySelector('.ns-num')?.value})
|
||||
await p.screenshot({path:'/tmp/panel-numslider.png'})
|
||||
console.log('=== 分组 ==='); console.log(JSON.stringify(r.groupTitles))
|
||||
console.log('NumSlider: 控件=',r.nsCount,'滑块=',r.nsRange,'数字框=',r.nsNum)
|
||||
console.log('首控件=', JSON.stringify(r.firstNs))
|
||||
console.log('改速率:', JSON.stringify(changed), '改后数字框值=', rateVal)
|
||||
console.log('HUD before:', before?.replace(/\s+/g,' ').trim())
|
||||
console.log('HUD after :', after?.replace(/\s+/g,' ').trim())
|
||||
console.log('=== 错误 ==='); console.log(errs.join('\n')||'(无)')
|
||||
}finally{await b.close()}
|
||||
Reference in new issue
Block a user