如何在Selenium Webdriver中移动光标

Nic*_*ahn 6 webdriver selenium-webdriver

编辑:

好吧,我已经通过jquery小部件检查了代码及其渲染.

结束

我试图将光标移动到<a \>,但问题是,直到我在所选图像上物理移动鼠标指针时才会渲染元素.

如何移动鼠标悬停<a \>以选择/单击?

FF version 20
Selenium WebDriver version: 2.31.2.0
Run Code Online (Sandbox Code Playgroud)

目前的代码

 Actions actions = new Actions(driver);

 int locationX = Convert.ToInt32(ratingElementDiv[i].Location.X);
 int locationY = ratingElementDiv[i].Location.Y;

 actions.MoveToElement(WaitForElement(By.CssSelector(starElement)), locationX, locationY).Click().Perform();
Run Code Online (Sandbox Code Playgroud)

我没有看到任何行动发生...任何帮助?

e1c*_*che 8

行动由3个步骤组成.

  • 组态
Actions builder = new Actions(driver); 
Point location ratingElementDiv[i].getLocation(); 
builder.MoveToElement(WaitForElement(By.CssSelector(starElement)), location.X, location.Y).click();
Run Code Online (Sandbox Code Playgroud)

(我不确定点击)

  • 得到行动
Action selectLink = builder.build();
Run Code Online (Sandbox Code Playgroud)
  • 执行
selectLink.perform();
Run Code Online (Sandbox Code Playgroud)

试试这个并告诉我你是否还有问题.