Home > Net >  Remove IWebElement from IList<IWebElement> based on text in IWebElement
Remove IWebElement from IList<IWebElement> based on text in IWebElement

Time:11-10

I retrieve a list of elements from a page using:

var elements = Driver.FindElements(locator)

I want to remove all the list items in elements that contain a particular text attribute "testing"

I believe it will be something like:

var elements = Driver.FindElements(locator).Remove(...)

CodePudding user response:

You can use RemoveAll with a lambda expression to remove all the elements with matching text

elements.RemoveAll(el => el.Text == "testing");
  • Related