Puppeteer:如何在不使用评估的情况下获取parentNode?

问题描述 投票:0回答:1

[借助Puppeteer,我知道如何使用带有parentNodepreviousSibling之类的属性的评估]

let id = await page.evaluate(() => {
    let wantedHref = $('li a').filter(
        function (index) {
            return $(this).text().includes("Text that I Want");
        })[0];
    //get parentNode
    let id = wantedHref.parentNode.parentNode.parentNode.id;
    //get  previousSibling
    let expandIcon = wantedLink.parentNode.parentNode.previousSibling;
    expandIcon.click();
    return id;
});

我想知道如何在不使用评估的情况下检索这些类型的属性。

您能帮我吗?

google-chrome-devtools puppeteer acceptance-testing
1个回答
0
投票

elementHandle.getProperty('parentNode')

© www.soinside.com 2019 - 2024. All rights reserved.