问题
I want to hover on some element, let say document.getElementById("abc")
and find its hover computed style.
How should I do it in Node.js using Puppeteer?
回答1:
You can use the following solution to iterate and hover over certain elements to obtain the computed style:
const elements = await page.$$('.abc');
const data = [];
for (let i = 0; i < elements.length; i++) {
await elements[i].hover();
data.push(await page.evaluate(element => window.getComputedStyle(element), elements[i]));
}
console.log(data);
来源:https://stackoverflow.com/questions/52165320/hover-on-element-and-getcomputedstyle-in-node-js-using-puppeteer