Why I can't perform mouse move using Selenium WebDriver for C# and PageFactory in initialization

I have an link in HTML and I use Page Object pattern to write scripts with Selenium. But I can't perform MouseMove action when object is initialized with pageFactory. So, I have such class:

class BingPage
{
private readonly IWebDriver driver;
public static readonly String BASE_URL = "http://bing.com/";
[FindsBy(How = How.XPath, Using = ".//*[@id='scpt2']/a[text()='Shopping']")]
private IWebElement ShoopingLink;

public BingPage(IWebDriver driver)
{
    this.driver = driver;
    //Page Factory will use Driver to init searchButton and queryEdit objects
    PageFactory.InitElements(driver, this);
}

public void HoverShoppingLink()
{
    Actions builder = new Actions(driver);

    IWebElement elem = driver.FindElement(By.XPath(".//*[@id='scpt2']/a[text()='Shopping']"));
    builder.MoveToElement(elem).Build().Perform();//This will work

    builder.MoveToElement(ShoopingLink).Build().Perform(); //This will fail
}
}

Line marked with comment "This will fail" will throw an exception "Must provide a location for a move action. Parameter name: actionTarget"

But when I manually lookup element - it works. Could someone tell me why?

It is selenium 2.0 for .Net, .Net 4.0 with IE driver.

Answers


Because the proxy object (ProxiedWebElementInterceptor) created for the element doesn't proxy ILocatable, which is what the Actions class requires of its methods. This is a bug in the .NET bindings. It has been fixed in the current sources, and will be available in the next public release (2.21), available soon.


Need Your Help

Rails: How to stop refreshing a page with two objects paginated in it?

javascript jquery ruby-on-rails ajax pagination

I have implemented the will_paginate plug in on RoR project. The will_paginate is done in two objects of the same page, but once any of them gets clicked, the whole page refreshes, and shows the pa...

Set the time on my Android from GPS

android gps-time

There are boatloads of Android apps that set the time on a rooted Android from the GPS data. I even found one with malware in it, according to AVG. Grrr.