0

I want to move the mouse in a certain position (0,0). After a previous click action I need in fact to move away the mouse from that position, as it's interfering with the next action I need to do.

I've found following Java code which is a perfect starting point but I'm not able to translate it into VBA and to adapt to my need.

Actions action = new Actions(webdriver);
WebElement we = webdriver.findElement(By.xpath("html/body/div[13]/ul/li[4]/a"));
action.moveToElement(we).moveToElement(webdriver.findElement(By.xpath("/expression-here"))).click().build().perform();

Sources:

How to perform mouseover function in Selenium WebDriver using Java?

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

Andrew
  • 89
  • 1
  • 12
  • Do you want to move to an element or a co-ordinate? – QHarr Mar 22 '21 at 10:13
  • @QHarr, I could find a (Java) example which move to an element, but my need is to move to a coordinate – Andrew Mar 22 '21 at 11:03
  • 1
    Co-ordinates will vary according to screen resolution unless you want a scrollTo on a weboage. Are you sure it is not sufficient to move to a different element then carry on with program? – QHarr Mar 22 '21 at 11:54

1 Answers1

2

I solved it this way:

Set el = driver.FindElementByXPath("//head")
driver.Actions.MoveToElement(el).Perform

As per @QHarr comment I didn't move to a coordinate but to an element: "head". This way my next selenium step is not disturbed by mouse position, which previously triggered a "mousehover" event.

Andrew
  • 89
  • 1
  • 12