from selenium import webdriver from selenium.webdriver.support.select import Select from time import sleep
driver = webdriver.Chrome() ......
Select(driver.find_element_by_name("storeDeclare.cityLine")).select_by_index("3")
Select(driver.find_element_by_name("storeDeclare.cityLine")).select_by_value("3线")
Select(driver.find_element_by_name("storeDeclare.cityLine")).select_by_visible_text("3线") sleep(5) driver.quit()
select_by_index # 通过索引定位 select_by_value # 通过value值定位 select_by_visible_text # 通过文本值定位
options # 返回select元素所有的options all_selected_options # 返回select元素中所有已选中的选项 first_selected_options # 返回select元素中选中的第一个选项
deselect_all # 取消全部的已选择项 deselect_by_index # 取消已选中的索引项 deselect_by_value # 取消已选中的value值 deselect_by_visible_text # 取消已选中的文本值
扫码关注腾讯云开发者
领取腾讯云代金券
Copyright © 2013 - 2025 Tencent Cloud. All Rights Reserved. 腾讯云 版权所有
深圳市腾讯计算机系统有限公司 ICP备案/许可证号:粤B2-20090059 深公网安备号 44030502008569
腾讯云计算(北京)有限责任公司 京ICP证150476号 | 京ICP备11018762号 | 京公网安备号11010802020287
Copyright © 2013 - 2025 Tencent Cloud.
All Rights Reserved. 腾讯云 版权所有