In java I use code like this to grab a list of WebElements with the same identifier:
@FindBy(how = How.CLASS_NAME, using = "name")
private List<WebElement> names;
Now, I’m using c# and I’m trying to do the same thing using:
[FindsBy(How = How.ClassName, Using = "name")]
private List<IWebElement> names;
However, this gives the exception:
System.ArgumentException: Object of type
‘Castle.Proxies.IWrapsElementProxy_1’ cannot be converted to type
‘System.Collections.Generic.List`1[OpenQA.Selenium.IWebElement]’.
I’ve tried FindAllBy and FindBys, however those do not seem to be valid. Is there anyway I can do this besides
names = getDriver().findElements(By.ClassNames("..."))?
As of 2.29.0 of the .NET bindings, this is now no longer true. The
FindsByattribute now will find individual elements or collections of elements. Note that the collection field or property decorated by theFindsByattribute must be of typeIWebElementorIList<IWebElement>in order to be populated by thePageFactory. Any other type will throw an exception.