selenium——下拉框

xiangxiaojun 2020-05-17

select_ele = driver.find_element_by_xpath("//select[@name=‘gpc‘]")
select = Select(select_ele)
time.sleep(1)
# 方式一:通过索引进行选择
select.select_by_index(3)
# 方式二:通过文本进行选择
select.select_by_visible_text(‘最近一年‘)
# 方式三:通过value进行选择
s2 = Select(driver.find_element_by_xpath("//select[@name=‘ft‘]"))
s2.select_by_value(‘doc‘)

相关推荐

jiong / 0评论 2020-09-17