您的位置:首页 > 其它

selenium的webdriverAPI使用操作多项选择框内容_10_3.docx

2017-03-04 22:32 579 查看
selenium的webdriverAPI使用操作多项选择框内容_10_3.docx
@Test

public void f() {

      WebElementweb=driver.findElement(By.id("multiSelect"));

      Selectselect=new Select(web);

      select.selectByIndex(0);

      System.out.println(select.getFirstSelectedOption().toString());

      select.selectByIndex(1);

      select.selectByIndex(2);

      //取消多项选择的第二选择项

      select.deselectByIndex(1);

      //取消多项选择的所有已选择项

      //select.deselectAll();

      //遍历多项选择项并输出每一项的文本内容

      for(WebElementw:select.getOptions()){

           System.out.println(w.getText());

      }

}
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: