可能重复:
Is there a proved mouseOver workaround for FirefoxDriver in Selenium2?
我希望能够使用Java Selenium2 API将鼠标悬停在WebElement上。那可能吗?我正在使用目前的测试版3。
答案 0 :(得分:25)
这将对您有所帮助:
WebElement elems=driver.findElement(By.linkText("Custom Development"));//Menu Item
WebElement elems1=driver.findElement(By.xpath("//li[@id='item-465']/a"));//Menu
Actions builder = new Actions(driver);
Actions hoverOverRegistrar = builder.moveToElement(elems1);
hoverOverRegistrar.perform();
elems.click();//at last Menu Item Click