编辑框的操作:
形如:〈input id=.....
.clear() --清除编辑框里的文字
.send_keys('xxx') -输入内容
.get_attribute('value') --获取编辑框里的内容
.get_attribute('type')获取文本框的类型
.text
单选框的操作:
形如:<input id="xx" type="radio">
.is_selected() 返回True或False
.click()
复选框:
形如: type = "checkbox"
.click()
.is_selected方法来获取选择的状态
复选框有两种:Select类
形如:
<select name="select">
<option value="zhangsan">aaa</option>
...
</select>
1. 可多选
2. 只能选一个
<select multiple> --可多选
<select> -只可以选一个
Selenium为Select类单独提供了库
方法:deselect_all 全部去勾选
方法:select_by_visible_text --根据显现在控件上的文字去选择
from selenium.webdriver.support.ui import Select
select = Select(driver.find_element())
select.deselect_all() #取消选中
select.select_by_visible_text('aaa') #根据选项文字去选择
select.select_by_index(0) #根据index选择,index从0开始
select.select_by_value("zhangsan") #根据value选择
Button按钮
形如: type = "button"
.click()
.isEnabled 代表检查这个按钮是不是可用的。