Skip to content
Advertisement

How I can select an element from a dropdown list?

Problem: I try to select an element from a dropdown list

I have a dropdown list with the following HTML code:

JavaScript

I try to select the element with the following Java code but didn’t work:

JavaScript

How I can select the element,I tried to increase the time in Wait, I also tried with Thread.sleep () but it still doesn’t recognize the items in the list or dropdownLocation.selectByText("Bucuresti CARAMFI");

Advertisement

Answer

JavaScript

I don’t see any option text as Bucuresti

try replacing with that :

JavaScript

Adding few more things :

JavaScript

You do not need to click on Select WebElement since it will be taken care by Select class that you have used.

You should use id, do not use ID with XPATH. until it’s necessary.

Something like this :

JavaScript

Update 1 :

Code in sequence :

JavaScript

Udpate 2 :

JavaScript
User contributions licensed under: CC BY-SA
4 People found this is helpful
Advertisement