Cooldudescrib
Cooldudescrib

Reputation: 91

Compile Error Converting Output from FindElements to List of IWebElements

I want to list the elements from part of a webpage. I am using the following statement to get the elements.

List<IWebElement> allElements = driver.FindElements(By.XPath("some path"));

But I’m getting the following compile error. Cannot implicitly convert type 'System.Collections.ObjectModel.ReadOnlyCollection' to 'System.Collections.Generic.List'

Can someone help me out?

Upvotes: 1

Views: 1529

Answers (2)

Sadik Ali
Sadik Ali

Reputation: 1205

use

ReadOnlyCollection<IWebElement> list = driver.FindElements(By.XPath("")); 

More detaik: Click

or

 IList<IWebElement> list = driver.FindElements(By.XPath("")); 

Upvotes: 3

Mrunal Gosar
Mrunal Gosar

Reputation: 4683

Its IList<IWebElement> list = driver.FindElements(By.XPath("")); Where IList is taken from System.Collections.Generic.IList<OpenQA.Selenium.IWebElement>

Upvotes: 2

Related Questions