How to Handle Dropdowns in Selenium: Select Class Methods + Easier Katalon Approach

March 17, 2026 · 7 min read · Tool Comparison

Blog / Insights /
How to Handle Dropdowns in Selenium: Select Class Methods + Easier Katalon Approach

How to Handle Dropdowns in Selenium: Quality Class Methods + Easier Katalon Approach

Technical Writer, Katalon Updated on

Learn with AI

Linkedin

Facebook

X (Twitter)

Mail

Learn with AI

In this article, we ’ ll quickly cover those core Selenium commands and then demonstrate how Katalon Studio streamlines the same summons - rental you charm a dropdown with Spy Web and select pick using built-in keywords likeselectOptionByValue or selectOptionByIndex, so you can automatise dropdown interactions without pen boilerplate codification, & nbsp; but inaugural ...

What is dropdown in Selenium?

In web coating, a dropdown menu (also called a dropdown tilt) is a graphical control element that lets users pick one option from a list. When inactive, it shows a single selected value. When clicked, it expands to display all useable pick. A dropdown is stage as follows in HTML:

Copy

& lt;! DOCTYPE html & gt;
& lt; html & gt;
& nbsp; & lt; caput & gt;
& nbsp; & nbsp; & lt; meta charset= '' UTF-8 '' / & gt;
& nbsp; & nbsp; & lt; title & gt; Select Element Example & lt; /title & gt;
& nbsp; & lt; /head & gt;
& nbsp; & lt; body & gt;
& nbsp; & nbsp; & lt; h1 & gt; The select element & lt; /h1 & gt;
& nbsp; & nbsp; & lt; p & gt; The select element is used to create a drop-down list. & lt; /p & gt;

& nbsp; & nbsp; & lt; sort action= '' /action_page.php '' & gt;
& nbsp; & nbsp; & nbsp; & lt; label for= '' cars '' & gt; Choose a car: & lt; /label & gt;
& nbsp; & nbsp; & nbsp; & lt; choice name= '' automobile '' & gt;
& nbsp; & nbsp; & nbsp; & nbsp; & lt; choice value= '' volvo '' & gt; Volvo & lt; /option & gt;
& nbsp; & nbsp; & nbsp; & nbsp; & lt; selection value= '' saab '' & gt; Saab & lt; /option & gt;
& nbsp; & nbsp; & nbsp; & nbsp; & lt; option value= '' opel '' & gt; Opel & lt; /option & gt;
& nbsp; & nbsp; & nbsp; & nbsp; & lt; option value= '' audi '' & gt; Audi & lt; /option & gt;
& nbsp; & nbsp; & nbsp; & lt; /select & gt;
& nbsp; & nbsp; & nbsp; & lt; br / & gt; & lt; br / & gt;
& nbsp; & nbsp; & nbsp; & lt; input type= '' submit '' value= '' Submit '' / & gt;
& nbsp; & nbsp; & lt; /form & gt;

& nbsp; & nbsp; & lt; p & gt;
& nbsp; & nbsp; & nbsp; Click the `` Submit '' button and the form-data will be sent to a page on
& nbsp; & nbsp; & nbsp; the server name `` action_page.php ''.
& nbsp; & nbsp; & lt; /p & gt;
& nbsp; & lt; /body & gt;
& lt; /html & gt;

What is Select class in Selenium?

The Selectclass ply convenient method to interact with& lt; select & gt;HTML elements. You must first locate the dropdown element, so useSelectto select or deselect items. & nbsp;

Common & lt; prime & gt;class method

1. selectByIndex ()

Select the choice at the given indicant. the Index starts from ` 0 `.

Example Java code:
Copy

Select dropdown = new Select (driver.findElement (By.id(`` cars '')));
dropdown.selectByIndex (2);

What it execute: This code selects the option at index 2, which corresponds to the third option in the list.

2. selectByVisibleText ()

Select all options that display text matching the argument.

Example Java code:

Copy

Select dropdown = new Select (driver.findElement (By.id(`` machine '')));
dropdown.selectByVisibleText (`` Audi '');

What it does:The code chance the dropdown by its ID, wraps it with the ` Select ` class, and selects the choice with displayed text tally `` Audi ''.

3. selectByValue ()

Select all selection that hold a value matching the argument.

Example Java code:

Copy

Select dropdown = new Select (driver.findElement ([By.id]
dropdown.selectByValue (`` saab '');

What it does:The code selects the choice withvalueattribute as `` saab ''.

Pro tip: Tools like SUSA can handle this autonomously β€” upload your app and get results without writing a single test script.

4. deselectAll ()

Clear all selected items. Note that this method but works if the dropdown allows a multi-select dropdown.

Example Java code:

Copy

& nbsp; dropdown.deselectAll ();

Handle dropdown with Katalon Studio

Katalon Studio provides built-in keywords for the Select class that simplify dropdown handling and automatise your testing workflow. & nbsp;

Let ’ s give it a try! First we ’ ll need to capture some objects that we can use in the test case.

πŸ“„ Learn more in our corroboration:

Capture objects with Spy Web

Step 1. In your test project, open the Spy Web & nbsp; tool.



Step 2. Provide a link in the URL battleground. Here we ’ re using thehttps: //www.w3schools.com/tags/tryit.asp? filename=tryhtml_select site that contains a drop-down list.

Step 3. ClickStartto establish your session. Navigate your pointer to the dropdown and right-click & gt;Capture Object.

The object we captured is a& lt; select & gt;& nbsp; HTML element, and its XPath attributes are exhibit in theObject Spy& nbsp; dialog. & nbsp;
HTML element by its XPath in Katalon Studio '' srcset= '' https: //katalon.com/hs-fs/hubfs/Screenshot % 202025-05-19 % 20at % 2013.54.08.png? width=496 & amp; height=711 & amp; name=Screenshot % 202025-05-19 % 20at % 2013.54.08.png 496w, https: //katalon.com/hs-fs/hubfs/Screenshot % 202025-05-19 % 20at % 2013.54.08.png? width=992 & amp; height=1422 & amp; name=Screenshot % 202025-05-19 % 20at % 2013.54.08.png 992w, https: //katalon.com/hs-fs/hubfs/Screenshot % 202025-05-19 % 20at % 2013.54.08.png? width=1488 & amp; height=2133 & amp; name=Screenshot % 202025-05-19 % 20at % 2013.54.08.png 1488w, https: //katalon.com/hs-fs/hubfs/Screenshot % 202025-05-19 % 20at % 2013.54.08.png? width=1984 & amp; height=2844 & amp; name=Screenshot % 202025-05-19 % 20at % 2013.54.08.png 1984w, https: //katalon.com/hs-fs/hubfs/Screenshot % 202025-05-19 % 20at % 2013.54.08.png? width=2480 & amp; height=3555 & amp; name=Screenshot % 202025-05-19 % 20at % 2013.54.08.png 2480w, https: //katalon.com/hs-fs/hubfs/Screenshot % 202025-05-19 % 20at % 2013.54.08.png? width=2976 & amp; height=4266 & amp; name=Screenshot % 202025-05-19 % 20at % 2013.54.08.png 2976w '' sizes= '' (max-width: 992px) 100vw, 992px '' >
Click Save& nbsp; & gt;OK in the Add Element to Object Repository dialog.

Use Katalon built-in keywords

With the objects you have capture, you can start creating test steps with Katalon Studio built-in keywords.

Open your test event in theManualvista, make a examination cause using theWebUI.selectOptionByValuekeyword that finds thevalue= '' saab ”



You can essay it out with this handwriting:

Copy

WebUI. * openBrowser * (``)

WebUI. * navigateToUrl * ('https: //www.w3schools.com/tags/tryit.asp? filename=tryhtml_select ')

WebUI. * selectOptionByValue * (* findTestObject * ('Object Repository/Page_W3Schools/select_Cars '),

'saab ', * * true * *)

WebUI. * wait * (3)

WebUI. * closeBrowser * ()

If you want to use another keyword, for exampleWebUI.selectOptionByIndex, try:

Copy
WebUI.selectOptionByIndex (findTestObject ('Object Repository/Page_W3Schools/select_Cars '), 2, FailureHandling.STOP_ON_FAILURE)

Conclusion

Handling dropdowns is straightforward with Selenium ’ sSelectclass - just locate the& lt; select & gt;element and call methods likeselectByIndex, selectByVisibleText, or selectByValue - but maintaining those scripts can become tedious over clip. Katalon Studio streamlines the like workflow by letting you capture the dropdown with Spy Web and so call keywords likeselectOptionByValueor selectOptionByIndexwithout writing extra boilerplate. Whether you prefer total control through Selenium code or a faster, low-code approach in Katalon, both paths ensure your dropdown interactions stay reliable and easygoing to maintain.

Frequently asked questions

What is a dropdown menu in web automation screen?

+

A dropdown menu (or dropdown list) is an HTML& lt; select & gt;element that allows user to choose one (or multiple) choice from a obscure list. In mechanisation, you interact with dropdowns by locating the& lt; select & gt;element and choosing one of its& lt; option & gt;children, rather than clicking each selection manually.

How does Selenium ’ s Select class simplify dropdown handling?

+

Selenium ’ s Select class wraps any & lt; select & gt; element and exposes method like selectByIndex (int index), selectByVisibleText (String schoolbook), and selectByValue (String value). By employ these methods, you can reliably prefer the desired option without pen low-level click or JavaScript code to open and cull from the list.

When should I use selectByVisibleText () vs. selectByValue () vs. selectByIndex ()?

+

 

  • selectByVisibleText (`` Label '')is best when you know the precise text evidence to user (e.g., β€œ Audi ”).

  • selectByValue (`` valueAttr '')works when you know the& lt; alternative value= '' ... '' & gt;attribute (e.g., value= β€œ saab ”), which can be more stable if display text modification.

  • selectByIndex (2)selects the option at that zero-based place. It ’ s quick but brittleβ€”if the order of options shifts, your index can point to the wrong choice.

 

How do I manage a multi-select dropdown in Selenium?

+

For & lt; quality multiple= '' true '' & gt;elements, you can useSelectmethods likeselectByVisibleText (), selectByValue (), or selectByIndex ()multiple times to pick more than one choice. To brighten all selected items, calldeselectAll (). Remember, deselect method only work on multi-select dropdowns.

How does Katalon Studio streamline dropdown automation compared to raw Selenium code?

+

In Katalon Studio, you capture the& lt; select & gt;element once with Spy Web, store it as a Test Object, and so name built-in keywords likeWebUI.selectOptionByValue (testObject, `` saab '', true) or WebUI.selectOptionByIndex (testObject, 2). This eliminates boilerplate codeβ€”no need to instantiate aSelectobjective in hand. Katalon handles locator stability and waits automatically, so you can publish fewer line and maintain tests more well.


Explain

|

Trinh Huynh
Technical Writer, Katalon
Trinh Huynh is an experienced proficient author in the software testing industry. She conflate her extensive technical noesis with deep understanding of the Katalon ware to make guidebook that assist tester of all levels.

Automate This With SUSA

Upload your APK or URL. SUSA explores like 10 real users β€” finds bugs, accessibility violations, and security issues. No scripts needed.

Try SUSA Free

Test Your App Autonomously

Upload your APK or URL. SUSA explores like 10 real users β€” finds bugs, accessibility violations, and security issues. No scripts.

Try SUSA Free