对一些js控件,鼠标悬停的时候出发下拉层的实现

1.使用Action

 public void moveToElement(WebDriver driver, By locator) {
Actions builder = new Actions(driver);
builder.moveToElement(driver.findElement(locator)).perform(); }

2.使用SendKeys

 public void moveToElement(WebDriver driver, By locator) {
driver.findElement(locator).sendKeys(Keys.DOWN);
}
05-16 16:32