Skip to content
CodeKruPro

List every option in a dropdown

Automation taskEasy-MediumAsked in: Accenture, Capgemini, Infosys, SaaS Labs, TCS, Wipro

Interviewers ask: "Print every option in the dropdown", and then "check that no option appears twice". Both start with the list of all options, which the Select helper gives you.

Get All Dropdown Options with getOptions()

Get All Dropdown Options

getOptions() returns a list of all <option> elements in the dropdown.

Task:

  1. Navigate to https://testkru.com/Elements/Dropdowns
  2. Get all options from the singleSelect dropdown
  3. Print the total count
  4. Print each option's visible text (skip the placeholder)

Expected output:

Total options: 6
Java
Python
JavaScript
C#
Ruby