网页定位中,针对select选框有下列三种方式:
通过选项文字 :
from selenium.webdriver.support.ui import Select
Select(driver.find_element_by_xpath(".//*[@id='province']")).select_by_visible_text("XXX")
通过索引 :
from selenium.webdriver.support.ui import Select
Select(driver.find_element_by_name("city")).select_by_index(X)
通过value值 :
from selenium.webdriver.support.ui import Select
Select(driver.find_element_by_name("county")).select_by_value("XXX")