Skip to content
CodeKruPro

Select Dropdown by Value

25/70

Select Dropdown by Value

Playwright uses locator.selectOption(value) for <select> elements. You can pass the option's value attribute.

On the Dropdowns page, the single-select dropdown (ID: singleSelect) has options: Java, Python, JavaScript, C#, Ruby.

Task:

  1. Navigate to https://testkru.com/Elements/Dropdowns
  2. Select the option with value python
  3. Print the visible text of the selected option

Expected output:

Selected: Python