Could someone give me an example how to read the selected value/option from a dropdown?
I have tried this syntax (JAVA), but it returns all the options of the dropdown.
page.locator("//xpath to dropdown webelement").textContent()
I only want to read what is selected.
Could you give an example how to do this with Java Playwright?
Give this a try:
String searchValue = (String) page.evalOnSelector("//xpath to dropdown webelement", "el => el.value");