jeudi 5 janvier 2017

How to fail test if result is not found in a loop c#

I have a for loop in which I look for attributes that match what I have typed in as a parameter. It passes when it is found but when it isn't found, it keeps looping through. I need a way in which to get the test to fail if it isn't found.

foreach (IWebElement link in links)
        {
            string text = link.GetAttribute("alt");
            if (text == transportMode)
            {
                Assert.AreEqual(text, transportMode);
            }
        }

Aucun commentaire:

Enregistrer un commentaire