I have following codes.
I have myCollection variable that contains all the Web elements. I am using two paths using XPath and or('|') operator because I need different things from the objects that these two different paths gives.
From the elements from the first path(//div[@role='region' and //@my-label] ), I want to get Text properties.
From the elements from the second path(//button[@role='butto
n' and //@my-label]), I want to get the values of 'my-label' attributes. (the Text properties for this elements are "")
After that, I want to put all these too myList<string>.
Obviously I am getting errors on my Linq query(at Select statement).
What's should I do to accomplish this?
public IReadOnlyCollection<IWebElement> myCollection => _driver.FindElements(By.XPath("//div[@role='region' and //@my-label] | //button[@role='button' and //@my-label]"));
var myList = new List<string>();
myList = myCollection
.Select(a => a.Text or a => a.GetAttribute("my-label").ToString())
.Reverse() // Newest item first