Back to All Scenarios
Scenario 29 of 100
Dropdowns
Intermediate
Handling Custom Dropdowns without Select Tags
π·οΈScenario Overview
Handling Custom Dropdowns without Select Tags
Key Takeaways & Cheat Sheet
- βConfirm the element is not built using standard HTML select options
- βClick the dropdown wrapper element to expand options in DOM
- βWait for options visibility using explicit ExpectedConditions
- βLocate and click target option by relative text value
Short Direct Answer
Modern frontend frameworks build custom, stylable dropdowns using divs, spans, or ul/li lists instead of standard HTML `<select>` tags. To automate these: click the dropdown container to expand the options, wait explicitly for the option elements list to be rendered on the page, and perform a standard click on the list item containing your target text.
β οΈ Senior Warning (Red Flag)
Do not instantiate the Selenium Select helper class on non-select tags. Doing so throws an UnexpectedTagNameException immediately.
π‘ STAR Deep Dive Explanation & Pro Tip
Always inspect the DOM before coding. If you do not see a <select> tag in the HTML structure, you must treat it as a standard interactive element click workflow.
SeleniumAutomation.java
Selenium 4 + Java// β
Expand custom React/Angular dropdown
driver.findElement(By.className("custom-select-trigger")).click();
// β
Wait explicitly for dynamic options list visibility
WebDriverWait wait = new WebDriverWait(driver, Duration.ofSeconds(5));
WebElement targetOption = wait.until(
ExpectedConditions.elementToBeClickable(
By.xpath("//li[@class='option' and contains(text(),'Premium Account')]")
)
);
// β
Select the option
targetOption.click();