If the random elements can sometimes be repeated, this can suffice:
await page.evaluate(() => {
const elements = [...document.querySelectorAll(".pioscnbf")]
.filter(element => element.style[0].includes("background-image"));
if (elements.length) {
const randomIndex = Math.floor(Math.random() * elements.length);
elements[randomIndex].click();
}
});
Otherwise, you can return the index of the clicked element, store it in an array and transfer this array to the next evaluated functions to exclude these elements.
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…