[Selenium]如何通过Selenium实现Ctrl+click,即按住Ctrl的同时进行单击操作

在自动化测试的过程中,经常会出现这样的场景:

按住Ctrl的同时,进行单击操作,已达到多选的目的

Actions a = new Actions(driver);
a.keyDown(Keys.CONTROL).perform();
for(int i = 0;i<quantity;i++){
      WebElement securityEl = securitiesList.get(i);
      SeleniumUtil.scrollIntoView(driver, securityEl);
      securityEl.click();
 }
a.keyUp(Keys.CONTROL).perform();

 

posted on 2014-07-07 16:51  张缤分  阅读(1619)  评论(0编辑  收藏  举报

导航