25 lines
1.3 KiB
JavaScript
25 lines
1.3 KiB
JavaScript
import puppeteer from 'puppeteer';
|
|
const b = await puppeteer.launch({ args:['--no-sandbox','--disable-setuid-sandbox','--use-gl=angle','--enable-unsafe-swiftshader'] });
|
|
const p = await b.newPage();
|
|
await p.setViewport({width:1280,height:1000});
|
|
await p.goto('http://10.200.201.3:4175/_lab/neu-card.html',{waitUntil:'load',timeout:60000});
|
|
await new Promise(r=>setTimeout(r,1000));
|
|
const meta = await p.evaluate(()=>{
|
|
const c=document.querySelector('#sec-shader a.contact-card');
|
|
const r=c.getBoundingClientRect();
|
|
return { docH: document.body.scrollHeight, viewH: window.innerHeight,
|
|
cardTop: r.top, cardBottom: r.bottom, cardRect: {x:r.x,y:r.y,w:r.width,h:r.height} };
|
|
});
|
|
console.log('before scroll', JSON.stringify(meta));
|
|
await p.evaluate(()=>document.querySelector('#sec-shader a.contact-card').scrollIntoView({block:'center'}));
|
|
await new Promise(r=>setTimeout(r,500));
|
|
const after = await p.evaluate(()=>{
|
|
const c=document.querySelector('#sec-shader a.contact-card');
|
|
const r=c.getBoundingClientRect();
|
|
const cx=r.x+r.width/2, cy=r.y+r.height/2;
|
|
const e=document.elementFromPoint(cx,cy);
|
|
return { cardTop: r.top, cardBottom: r.bottom, topEl: e?(e.className||e.tagName):'null', cx, cy };
|
|
});
|
|
console.log('after scroll', JSON.stringify(after));
|
|
await b.close();
|