'MoveToElement - RemoteWebDriver threw an exception of type 'System.InvalidOperationException'

I'm using code below for move to element, but actionExecutor returns an exception.

IWebElement element = driver.FindElement(By.LinkText(link_text));
Actions ac = new Actions(driver);
ac.MoveToElement(element);
ac.Build().Perform();

enter image description here

I received comment that "This is not a valid endpoint for w3c, and is no longer supported by Chrome." https://github.com/SeleniumHQ/selenium/issues/10344

Any suggestions on how to solve the problem with the MoveToElement method, please?



Solution 1:[1]

Before you move to the element you must check if you actually found it:

IWebElement element = driver.FindElement(By.
LinkText(link_text));
if (element!=null) {
   Actions ac = new Actions(driver);
   ac.MoveToElement(element);
   ac.Perform();
}

Note that you can remove the Build() call, as you are doing only a single action and not more.

If the element you found is indeed null, try to find it by Xpath or CSS and not by LinkText.

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Tal Angel