【发布时间】:2015-11-25 08:22:47
【问题描述】:
我是 Selenium 的新手,并尝试使用 Actions 类将鼠标悬停在站点中链接的配置文件图标上,以打开出现在配置文件图像鼠标悬停上的菜单。
下面是我的代码,当它到达这些行时,错误来了:Unable to locate element..
这发生在顶部栏上的所有可用图标(消息/标志图标等)上。
代码:
public class LinkedIn {
WebDriver driver = new FirefoxDriver();
@BeforeTest
public void setUp() throws Exception {
String baseUrl = "http://www.linkedin.com/";
driver.get(baseUrl);
}
@Test
public void login() throws InterruptedException
{
WebElement login = driver.findElement(By.id("login-email"));
login.sendKeys("*****@gmail.com");
WebElement pwd = driver.findElement(By.id("login-password"));
pwd.sendKeys("*****");
WebElement in = driver.findElement(By.name("submit"));
in.click();
Thread.sleep(10000);
}
@Test
public void profile() {
// here it gives error to me : Unable to locate element
Actions action = new Actions(driver);
WebElement profile = driver.findElement(By.xpath("//*[@id='img-defer-id-1-25469']"));
action.moveToElement(profile).build().perform();
driver.quit();
}
}
【问题讨论】:
标签: java selenium-webdriver mouseover