How can you find HTML element that can be clicked on to use dropdown?
I have managed to find element for some dropdowns but for a specific dropdown I cant find it.
Is there any HTML attribute I can look at to determine which can be clicked? There does not seem to be a onClick() or similar
9 Replies
harsh-harlequin•3y ago
Got a link to the page and a screenshot of what you want to click?
fair-roseOP•3y ago

fair-roseOP•3y ago
Document search page
Search by criteria (reference, author, date, etc.)
fair-roseOP•3y ago
I want to click on "FULL"
dropdown
Forgot to mention you need to click on the top element on the page before it is shown as displayed
harsh-harlequin•3y ago
There is
page.selectOption()
: https://playwright.dev/docs/api/class-page#page-select-option
This selector seems to match all the dropdowns on the page that you want:
Since all the select elements are already PRESENT in the DOM (just not visible until the container is clicked), you can do:
force
set to true
means the element doesn't necessarily have to be visible (see more here: https://playwright.dev/docs/actionability)
But since you want to click all of them, you'll need to loop through all elements that that selector resolves to and run the selecting logic for each one.Page | Playwright
* extends: [EventEmitter]
harsh-harlequin•3y ago
Hope this helps 😄
fair-roseOP•3y ago
Thanks I will try that out. Propably better than just selecting each element and trying to click it 😛
How would the corresponding code look like in chrome dev tools?
harsh-harlequin•3y ago
So I was wrong about the page. The title MUST be clicked for the
<select>
to be added to the DOM. Try running this code:
fair-roseOP•3y ago
thanks I will test it soon