25 lines
1.4 KiB
JavaScript
25 lines
1.4 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));
|
|
await p.evaluate(()=>document.querySelector('#sec-shader').scrollIntoView());
|
|
await new Promise(r=>setTimeout(r,400));
|
|
await p.evaluate(()=>{
|
|
window.__clicked=false;
|
|
const c=document.querySelector('#sec-shader a.contact-card');
|
|
c.addEventListener('click', ()=>{ window.__clicked=true; }, true);
|
|
});
|
|
const box = await p.$eval('#sec-shader a.contact-card', el=>{const r=el.getBoundingClientRect();return {x:r.x,y:r.y,w:r.width,h:r.height};});
|
|
const x=box.x+box.w/2, y=box.y+box.h/2;
|
|
await p.mouse.move(x,y);
|
|
await new Promise(r=>setTimeout(r,400));
|
|
const hover = await p.evaluate(()=>getComputedStyle(document.querySelector('#sec-shader a.contact-card')).transform);
|
|
await p.mouse.click(x,y);
|
|
await new Promise(r=>setTimeout(r,300));
|
|
const clicked = await p.evaluate(()=>window.__clicked);
|
|
const top = await p.evaluate((x,y)=>{const e=document.elementFromPoint(x,y);return e?(e.className||e.tagName):'null';}, x, y);
|
|
console.log(JSON.stringify({hover, clicked, topElAtCenter: top},null,1));
|
|
await b.close();
|