1. 程式人生 > >selenium+ java 下拉框—— 方法使用

selenium+ java 下拉框—— 方法使用

<select>選擇方法:

selectByIndex() //通過下拉列表中選項的索引選中三項,在Java中索引從0開始;
selectByValue() //操作option標籤中屬性值。
selectByVisibleText()//引數為option的text值
getOptions() //返回select標籤中的所有選項,返回型別是list集合,可以遍歷操作所有選項

取消方法
deselectByIndex(index)
deselectByValue(value)
deselectByVisibleText(text)
deselectAll()


非<select> 

層級定位:如果遇到多層frame的情況,需要層級定位,
如果有三層frame:為frame1,frame2,frame3:
想要進入3,必須先進入1,再進入2,才能進入3;
如果呼叫driver.switchTo().defaultContent():
則會直接跳轉回頂層frame,即最外層的body部分。