Selenium - MoveToElement() with transparent proxy

Viewed 903

I have element

public ArticlePage()
{
    PageFactory.InitElements(Browser.driver, this)
}

[FindsBy(How = How.Id, Using = "someId")]
private IWebElement btnTitleView { get; set; }

and action

Actions action = new Actions(Browser.driver);
action.MoveToElement(btnTitleView).Perform();

But when i try to run it, i will get error

'System.Reflection.TargetException' Object does not match target type.

I tried to locate this element by Browser.driver.FindElement(By.Id("someId")) and then it is working correctly. So, it is present and displayed.
Is it possible to use transparent proxy to perform Actions? Is there any other way to perform MoveToElement() like action on transparent proxy?

2 Answers

One way how to get around this is to use IList<IWebElement> and than use foreach or LINQ to manipulate the element. So you can use:

[FindsBy(How = How.Id, Using = "someId")]
private IList<IWebElement btnTitleView { get; set; }
...

Actions action = new Actions(Browser.driver);
action.MoveToElement(btnTitleView.First()).Perform();

or

foreach (var element in btnTitleView)
{
   Actions action = new Actions(Browser.driver);
   action.MoveToElement(element).Perform();
}
Related