Selenium, ComboBox, select value by text

Hello everyone,

I’m currently working on automating some UI tests with Selenium and I’ve run into a bit of a snag. I’ve successfully located the specific ComboBox I need to interact with by using an XPath selector. However, I’m stuck on how to proceed with selecting a specific value from the ComboBox that matches certain criteria.

Here’s what I’ve done so far:

  • I used XPath to correctly identify and interact with the ComboBox on my UI.

From here, I’m unsure how to filter and select a particular value. Does anyone have suggestions or best practices on how to programmatically select an item from a ComboBox based on its text or another attribute? Any examples or guidance would be greatly appreciated!

Thank you in advance for your help!

It’s going to be some kind of JavaScript job with executeScript. If you know the item you want to select, something like combobox.value = selectThis in JavaScript should work. Vaadin TestBench has ready-made functionality for all this.

1 Like

Tenks Olli. I switched to playwright with Mopo. For now, I can’t afford pro subscription.

1 Like

That’s a good choice. Selenium can be very flaky

2 Likes

I’d rather recommend you use https://playwright.dev. Selenium is kinda outdated tool by my POV.

2 Likes