![](/img/trans.png)
[英]Mouse hover action is not working in selenium webdriver for demo website
[英]mouse hover action in selenium WebDriver
我想知道如何在selenium Web Driver中执行鼠标悬停操作。
鼠标悬停操作需要在选项卡上执行。 它需要悬停然后需要单击选项卡。 我怎么能使用JavaScript executor和java来做到这一点。
Javascript执行程序应该是使用Selenium执行任何操作的最后手段。 Selenium提供了一个Action类,您可以使用它来执行鼠标/键盘操作。 对于您的场景,
Actions builder = new Actions(driver);
Action hoverAndClick = builder.moveToElement(webElement).click(webElement).build();
hoverAndClick.perform();
这是一个例子:
Actions act = new Actions(driver);
WebElement parentMenu = driver.findElement(By.xpath("Xpath"));
//Move to the element
act.moveToElement(parentMenu).build().perform()
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.