The title mostly explains my question, my IEnumerable<AppiumWebElement>
does not have a .Where
method, and I'm hoping to learn why.
I have a method that returns an IEnumerable<AppiumWebElement>
, as follows:
public IEnumerable<AppiumWebElement> GetLayers()
{
var items = PaneOrView.FindElementsByClassName("TreeViewItem");
List<AppiumWebElement> layers = new List<AppiumWebElement>();
foreach(AppiumWebElement item in items)
{
string automationId = item.AutomationId();
if (automationId != null && automationId.Contains("Layer"))
{
layers.Add(item);
}
}
return layers.AsEnumerable();
}
When I check whether .Where
is present on the return item in this method (using code completion), I get a full list of methods I would expect to see from an IEnumerable
.
However, when I later use this method from another namespace, for example like this:
var test = Contents.GetLayers();
The result in test
doesn't contain .Where
or any of the other methods I would expect to see from an IEnumerable
. Any idea why?
Thanks for any pointers!
Where()
and other methods in Linq
are extension methods that you are using. You need to import System.Linq
:
using System.Linq;