在我正在处理的场景中,需要等待,直到出现预期的条件,如值,值具有预期的文本或状态,或者直到更复杂的规则有效,例如:
Wait.Until(x => x.UserName.Value.Get() != string.Empty)在给定Selenium wait.until方法的情况下,Atata框架中是否有等效的功能?
我已经看到waiting有很多属性,比如Until、WaitFor、WaitForElement,但这些都是针对简单场景的。我需要更复杂的规则类似的功能。如何使用Atata实现这一点?
发布于 2018-02-16 03:54:44
为此,您可以使用组件的Should.*扩展方法。
page.SomeSpan.Should.Equal("smth"); // Checks for text in some <span> element.默认情况下,重试可能需要长达5秒的时间,直到条件执行,即使在验证开始时控件的元素不存在。只有在超时且不满足条件后才会引发异常。
page.SomeSpan.Should.Within(30).StartWith("smth"); // Wait for condition within 30 seconds.
page.SomeSpan.Should.AtOnce.Contain("smth"); // Without retries, quickly checks and throws if condition doesn't match.
page.SomeSpan.Should.Not.BeNullOrEmpty(); // Wait for any value in <span>.您还可以将Should扩展方法用于控件列表和数据属性:
page.SomeTable.Rows.Should.Not.BeEmpty();
page.SomeTable.Rows.Count.Should.BeGreaterOrEqual(1);以此类推。您可以检查Atata.IDataVerificationProviderExtensions和Atata.IUIComponentVerificationProviderExtensions类中的其他方法。对于否定检查,只需在“应该”后面添加"Not“:Should.Not.*。还有用于自定义条件的Should.Satisfy()方法。
https://stackoverflow.com/questions/48812187
复制相似问题