Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to move cursor in Selenium Webdriver

EDIT:

okay, i have checked the code and its rendering out by a jquery widget.

END

I am trying to move the cursor to <a \>, but the problem is that the element is not rendered until i move mouse pointer physically on selected image.

How can i move to the mouse to hover over <a \> to select/click?

FF version 20
Selenium WebDriver version: 2.31.2.0

Current code

 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();

i dont see any action happening... any help?

like image 522
Nick Kahn Avatar asked Apr 04 '13 00:04

Nick Kahn


2 Answers

Action is composed by 3 steps.

  • configuration
Actions builder = new Actions(driver); 
Point location ratingElementDiv[i].getLocation(); 
builder.MoveToElement(WaitForElement(By.CssSelector(starElement)), location.X, location.Y).click();

(i'm not sure about the click)

  • get the action
Action selectLink = builder.build();
  • execution
selectLink.perform();

try this and tell me if you still have some problem.

like image 85
e1che Avatar answered Sep 28 '22 01:09

e1che


This link will help you. It explain both keyboard and mouse event.

http://www.guru99.com/keyboard-mouse-events-files-webdriver.html

like image 23
bugCracker Avatar answered Sep 28 '22 00:09

bugCracker