vic
vic

Reputation: 227

How to Verify if item from one list exists in any of another 2 lists

I have a Method like below .

public void Method(List<string> testingValues, IList<IWebElement> Element, IList<IWebElement> Element2)
{
    // verify if testing values available in element or element2 list
}

How can i write the code which will verify values from testingvalues exists into list Element or Element2 ?

Upvotes: 0

Views: 318

Answers (1)

Christos
Christos

Reputation: 53958

You could try something like this:

public bool Method(List<string> testingValues, IList<IWebElement> Element, IList<IWebElement> Element2)
{
     return testingValues.All(item => Element.Any(x => x.Text==item)
                                    ||Element2.Any(y => y.Text==item));
}

This method will return true, if all the values that are in testingValues are contained in either the Element or Element2. Otherwise, it will return false.

Upvotes: 1

Related Questions