user4985 user4985 - 3 months ago 27
C# Question

Action class not accepting selenium driver as variable

I'm looking to scroll a webpage to view in selenium.
The example codes I got from online are as follows:

var element = driver.FindElement(By.id("element-id"));
Actions actions = new Actions(driver);
actions.MoveToElement(element);
actions.Perform();


Yet when i utilize it this way:

IWebElement element = driverFF.FindElement(By.Id("qr_reply"));

Action actions = new Action(driverFF);
actions.MoveToElement(element);
actions.Perform();


I get thrown a "Method name expected." error at the second line.

Any help will be greatly appreciated.

Answer

Actually you are using wrong class, As you see in the example code it should be Actions with OpenQA.Selenium.Interactions Namespace instead of Action as below :-

using OpenQA.Selenium;
using OpenQA.Selenium.Interactions;

Actions actions = new Actions(driverFF);
actions.MoveToElement(element);
actions.Perform();
Comments