好的,我在这里遗漏了一些东西。我的断言失败了,但看看本地人,我的值(value)和返回匹配。厌倦了看这个。我错过了什么?
代码:
List<String> item = new List<string>();
// grab the cells that contain the popsockets you want to sort
IReadOnlyList<IWebElement> cells = Driver.FindElements_byXpath("//h2[@class='link']/a");
// loop through the popsockets and assign the price into the ArrayList
foreach (IWebElement cell in cells)
{
item.Add(cell.Text);
Assert.IsTrue(item.Contains(value));
}
本地人:
最佳答案
您是在列表本身而不是列表中的项目上调用 .contains()
。所以它正在寻找对值的引用而不是单词。
Assert.IsTrue(item.Any(itm => itm.Contains(value)));
关于c# - Selenium C# 断言失败但有效,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/57948036/