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

来源:互联网 发布:直播软件apk 编辑:程序博客网 时间:2024/06/07 23:19

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());

      }

}

0 0