简体   繁体   English

如何在 JavaScript 中使用剧作家 select 下拉选项?

[英]How to select a dropdown option using playwright in JavaScript?

I would like to select "All" option from the below DOM using Playwright JS, and I have tried page.selectOption('select#rows per page', '-1');我想使用 Playwright JS 从下面的 DOM 中选择 select “All”选项,并且我已经尝试过page.selectOption('select#rows per page', '-1'); and page.selectOption('id=mui-55656', '-1');page.selectOption('id=mui-55656', '-1'); to no avail.无济于事。 Any help would be appreciated.任何帮助,将不胜感激。 Thanks.谢谢。 在此处输入图像描述

You should be able to select the option using the aria-label您应该能够使用aria-label来 select 选项

await page.selectOption('[aria-label="rows per page"]', '-1');

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM