cannotcompute
cannotcompute

Reputation: 397

Moving mouse (move_to) in ruby Selenium

I`m trying to emulate mouse movement with Selenium WebDriver 2.4 in Ruby

Should I see the mouse moving on my screen if I run the test? I'm confused.

I have tried many different ways Sample code:

require 'selenium-webdriver'
driver = Selenium::WebDriver.for :firefox
driver.navigate.to 'http://www.google.com'
element = driver.find_element(:id, 'gbqfba')

then I've tried

driver.action.move_to(element).perform
driver.mouse.move_to(element)

And also Watir's hover method.

Best way I've found so far is Watir's fire_event 'onmouseover' But still not moving the mouse :)

After searching on SO and elsewhere, I can't seem to get anything to work for moving the mouse in WebDriver.

Whass going on? Is it possible to actually move the mouse cursor on screen (when the webdriver browser window is in view)

Upvotes: 6

Views: 9308

Answers (1)

ddavison
ddavison

Reputation: 29032

The answer is No You will not visually see your mouse move. Selenium interacts with the page internally which means it will not use your desktop mouse.

If you are afraid it's not working, then maybe you are operating with the wrong element because driver.action.move_to(element).perform is valid.

Upvotes: 5

Related Questions