如何断言一个页面在事件发生后发生了多个更改?
我要断言的行为例子:
我想断言,所有这些事情都是在我点击按钮后发生的。我真的需要写相同的方法吗?每个方法都要在每一个更改上断言?
发布于 2015-07-21 18:27:10
为什么需要为每个断言编写更多的方法?您只需使用一个方法来检查元素是否可见,并为每个元素调用一次。
private boolean IsElementVisible(By by)
{
try
{
return driver.FindElement(by).IsDisplayed();
}
catch(NoSuchElementException e)
{
return false;
}
}
private List<By> VerifyElementVisibility(
List<By> expectedVisibile, List<By> expectedInvisible)
{
List<By> failedExpectations = new List<By>();
for (By by in expectedVisible)
{
if(!IsElementVisible(by)
{
failedExpectations.Add(by);
}
}
for (By by in expectedInvisible)
{
if(IsElementVisible(by)
{
failedExpectations.Add(by);
}
}
return failedExpectations;
}
List<By> failedExpectations = VerifyElementVisiblity(visibleElements, invisibleElements);
Assert.IsTrue(failedExpectations.Count == 0,
failedExpectations.Count.ToString() + " elements did not meet expectations");https://stackoverflow.com/questions/31546650
复制相似问题