How can I select the last drop-down option in selenium with python?
drop-down-menu, python, select, selenium
Solution
One way to do so is:
from selenium import webdriver
driver = webdriver.Firefox()
driver.get('navigate to url')
select_elem = driver.find_element_by_id('TargetRadius')
select_elem.click()
options = select_elem.find_elements_by_tag_name('option')
options[len(options)-1].click()
Problem
I have a drop-down menu as follows in HTML: ``` <select id="TargetRadius" name="TargetRadius"> <option value="1" selected="true">1</option> <option value="11">11</option> <option value="15">15</option> <option value="18">18</option> </select> ``` I want to choose the last option. However, I am looping this, and the values change for each loop. How can I choose the last option without referencing the value of the "option" tag?