(十三)定位下拉菜單select

<html>
<head>
  <meta http-equiv="content-type" content="text/html;charset=utf-8" />
  <title>Checkbox</title>
</head>
<body>
  <h3>select</h3>                        
  <select id="selType">
      <option value="0">請選擇</option>
       <option value="1">原創</option>
       <option value="2">轉載</option>
       <option value="4">翻譯</option>
  </select>
</body>
</html>

可以通過索引、值、文本定位選項: 

import org.openqa.selenium.support.ui.Select;

 driver.get("file:///C:/Users/administrator/Desktop/select.html");
 new Select(driver.findElement(By.id("selType"))).selectByIndex(3);
 new Select(driver.findElement(By.id("selType"))).selectByValue("4");
 new Select(driver.findElement(By.id("selType"))).selectByVisibleText("翻譯");;
		 

 

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章