首页 > 编程语言 > 详细

webdriver---API---(java版)

时间:2017-02-14 20:37:00      阅读:224      评论:0      收藏:0      [点我收藏+]

操作单选框、复选框

<html>
<body>
     <form>
                <input type="checkbox" name="fruit" value="berry"/>草莓</input>
                 <br />
                  <input type="checkbox" name="fruit" value="watermelon"/>西瓜</input>
                   <br />
                  <input type="checkbox" name="fruit" value="orange"/>橘子</input>
     </form>
</body>
</html>
WebElement radioOption=driver.findElement(By.xpath("//input[@value=‘berry‘]"));
      if(!radioOption.isSelected()){
          radioOption.click();
      }
      List<WebElement>fruits=driver.findElements(By.name("fruit"));
      for(WebElement fruit : fruits){
          if(fruit.getAttribute("value").equals("watermelon")){
              if(!fruit.isSelected()){
                  fruit.click();
                  Assert.assertTrue(fruit.isSelected());
                  break;
              }
          }
      }

 

webdriver---API---(java版)

原文:http://www.cnblogs.com/wangyinxu/p/6399065.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!