这应该为您工作。该代码将
像这样:
from selenium import webdriver
from selenium.webdriver.support.ui import Select, webdriverwait
browser = webdriver.Firefox()
browser.get("http://www.website.com")
select = browser.find_element_by_xpath( "//select[@id='idname']") #get the select element
options = select.find_elements_by_tag_name("option") #get all the options into a list
optionsList = []
for option in options: #iterate over the options, place attribute value in list
optionsList.append(option.get_attribute("value"))
for optionValue in optionsList:
print "starting loop on option %s" % optionValue
select = Select(browser.find_element_by_xpath( "//select[@id='idname']"))
select.select_by_value(optionValue)