如何使用 Selenium Webdriver 执行鼠标悬停功能?
测试用例就像是说,打开雅虎网站,登录旁边有链接(邮件)。
鼠标悬停时,它将显示工具提示。
当我尝试下面的代码时,鼠标不是悬停在确切的位置,而是悬停在其他地方。我哪里出错了?
另外让我知道如何捕获工具提示?
import org.openqa.selenium.By;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.WebElement;
import org.openqa.selenium.firefox.FirefoxDriver;
import org.openqa.selenium.interactions.Actions;
public class Sample
{
public static void main(String[] args)
{
WebDriver driver=new FirefoxDriver();
driver.get("http://www.yahoo.com");
driver.manage().window().maximize();
try
{
Thread.sleep(5000);
} catch (InterruptedException e)
{
// TODO Auto-generated catch block
e.printStackTrace();
}
WebElement lMail=driver.findElement(By.xpath("//*[@title='Mail']"));
Actions builder=new Actions(driver);
builder.moveToElement(lMail).build().perform();
}
}
Actions actions = new Actions(driver);
actions.moveToElement(element).click().build().perform();
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)