断言即使实际和预期匹配失败

时间:2019-07-09 17:16:58

标签: c# selenium assert specflow

我的代码如下-

string Nodata = _driver.FindElement(By.XPath("//*@id='gridView_EMPLOYEE_DXEmptyRow']/td[1]")).GetAttribute("innerHTML");

Assert.AreEqual("No data to display", Nodata.Trim());

插入失败并显示消息

Message: Assert.AreEqual failed. Expected:<No data to display>. Actual:<<div>
                No data to display
            </div>>.

See the screenshot below

1 个答案:

答案 0 :(得分:0)

一种更简单的方法是使用<div>标签进行检查(请注意空格)

  Assert.AreEqual("<div>No data to display</div>", Nodata.Trim());