This thread is trying to answer question "How can I select a button with `aria-haspopup="listbox"` in Playwright?"
Best I've got so far:
const buttons = page.getByRole("button", { name, ...baseOpts })
let locator: Locator | undefined
for (const button of await buttons.all()) {
if ((await button.getAttribute("aria-haspopup")) === "listbox") {
locator = locator ? locator.and(button) : button
}
}
if (!locator) throw new Error(`No dropdown found for ${name}`)
Rayrun is a community for QA engineers. I am constantly looking for new ways to add value to people learning Playwright and other browser automation frameworks. If you have feedback, email [email protected].