Selecting a value from a drop-down option using selenium python

Adrian Ratnapala is right and also i would choose id over name, so you can try the following :

find_element_by_xpath("//select[@id='numReturnSelect']/option[@value="15000"]").click()

OR

find_element_by_css_selector("select#numReturnSelect > option[value="15000"]").click()

OR

you can use select_by_value(value) :

Select(driver.find_element_by_css_selector("select#numReturnSelect")).select_by_value(15000).click()

Click here for more info on Select.

Leave a Comment