Skip to content
CodeKruPro

Select Dropdown by Index

27/70

Select Dropdown by Index

Select by position using selectOption({ index: n }). Index is 0-based.

The singleSelect dropdown options:

  • Index 0: "Select Language" (disabled placeholder)
  • Index 1: "Java"
  • Index 2: "Python"
  • Index 3: "JavaScript"
  • Index 4: "C#"
  • Index 5: "Ruby"

Task:

  1. Navigate to https://testkru.com/Elements/Dropdowns
  2. Select the option at index 3 (JavaScript)
  3. Print the selected text

Expected output:

Selected at index 3: JavaScript