案例:
有一个列表,您需要在其中选择一个项目,然后它就会关闭。当您单击另一个项目时,列表没有时间关闭。最后,再次单击另一个列表元素。
await page.waitForSelector('.list');
await page.click('.list');
await page.waitForSelector('.list-element');
await page.click('.list-element'); // click on the list element and list closes
await page.click('.another-element'); // click on the list
最佳答案
您可以从列表中一次选择多个项目,如下所示:
// multiple selection
page.selectOption('select#colors', ['red', 'green', 'blue']);
来源:https://playwright.dev/docs/api/class-page#page-select-option
关于Puppeteer:我怎样才能等到列表关闭?如何等到元素从 DOM 中消失?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/62022979/