selenium webdriver模拟键盘鼠标事件
上一篇 /
下一篇 2015-08-07 14:32:07
/ 个人分类:selenium
我们在使用selenium webdriver进行
自动化测试时,经常会用到模拟键盘鼠标的事件。我们可以用webdriver中的Actions.
Actions action = new Actions(all.driver);
WebElement element1=all.driver.findElement(By.linkText("系统管理"));
action.moveToElement(element1).build().perform();
2 键盘按键模拟
WebElement ele = all.driver.findElement(By.xpath("//input[@ng-model='orgTree_searchStr']"));
ele.clear();
ele.sendKeys("长沙市");
Actions action = new Actions(all.driver);
action.sendKeys(ele,Keys.ENTER);
3 拖拽
Actions actions = new Actions(all.driver);
actions.clickAndHold(zhuzhou).moveToElement(hengyang,10,1).release().build().perform();
4 键盘鼠标组合
WebElement del1 = all.driver.findElement(By.xpath("//ul[@id='orgTree']/li/ul/li/a[@title='长沙市']"));
WebElement del2 = all.driver.findElement(By.xpath("//ul[@id='orgTree']/li/ul/li/a[@title='株洲市']"));
Actions actions = new Actions(all.driver);
actions.click(del1).keyDown(Keys.CONTROL).click(del2).keyUp(Keys.CONTROL).build().perform();
收藏
举报
TAG:
键盘鼠标模拟