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)
We can move mouse pointer to a specific location or element in Selenium webdriver(C#) using the Actions class. We have to first create an object of this class. Next to move an element we have to apply the MoveToElement method and pass the element locator as a parameter to this method.
dragAndDropBy(source, xOffset, yOffset): Click-and-hold at the location of the source element, moves by a given offset. moveByOffset(x-offset, y-offset): Moves the mouse from its current position (or 0,0) by the given offset. moveToElement(toElement): Moves the mouse to the middle of the element.
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With