Uda*_*day 2 java selenium-webdriver
如何使用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();
}
}
Run Code Online (Sandbox Code Playgroud)
Actions actions = new Actions(driver);
actions.moveToElement(element).click().build().perform();
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
22823 次 |
| 最近记录: |