At one of my test cases, if based on some configurations, determined values on a table should not be displayed.
I've made a code to show up a message if a predicted value not appears, as following:
public void AssertRecord(string recordExpected)
{
try
{
Assert.AreEqual(recordExpected, RecordGridCell.GetGridCellAtPosition1BasedOnAnyValue(recordExpected));
}
catch (Exception)
{
Console.WriteLine(recordExpected + " not found.");
}
}
By the way, the function above GetGridCellAtPosition1BasedOnAnyValue is here:
public static string GetGridCellAtPosition1BasedOnAnyValue(this IWebElement table, string value)
{
UtilFunctions.WaitForLoadingBar();
IList<IWebElement> tableRow = table.FindElements(By.XPath(".//tr//td[text()='" + value + "']//ancestor::tr//td[1]"));
return tableRow.First().GetAttribute("innerHTML");
}
So, with the code I got today, I get an output saying, for example, "Chocolate Bar not found.". If the value exists, it throws nothing.
My problem is: if is there any value on the table that shouldn't be there and that can't be predicted, it will not be reported.
I need help to find a way to be reported if there's any value on the table that shouldn't be there.