1.select下拉选择定位
select类只能定位select类
导入的select包:from selenium.webdriver.support.select import Select
定位元素是select标签:
定位的方法:
-
select_by_index() 根据option的索引来定位
-
select_by_value() 根据option属性value值来定位
-
select_by_visible_text() 根据option显示的文本来定位
-
例:
2.警告框处理
alert:
- text——返回文字信息
- dismiss()——取消对话框
- accept()——接受对话框
先获取警告框:driver.switch_to.alert
后调用alert方法:
- driver.switch_to.alert.text
- driver.switch_to.alert.dismiss() <