如何等待浏览器,直到数据在下拉框中填充而不在puppeteer中使用delay()?

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

我尝试使用{waitUntil:'networkidle2'}等待数据加载但它不起作用。所以,我使用了很长的等待延迟(时间)因为我不知道将数据填充到下拉框需要多长时间。这耗费了很多时间。所以必须有某种方式,浏览器等待,直到下拉框填充数据。

automation automated-tests jestjs ui-automation puppeteer
1个回答
0
投票

您可以使用waitForFunction函数。这将等到填充<your selector>元素。

await page.waitForFunction('document.querySelector("<your selector>").options.length');
© www.soinside.com 2019 - 2024. All rights reserved.