我看到你链接到 C# sdk,所以我会用 C# 回答。
WaitUntil执行提供的布尔方法,直到它返回true。因此,如果您实现自己的方法:
private bool funcToRun(IBrowser arg)
{
// imeplement whatever logic you want here
return true;
}
然后你可以调用WaitUntil如下:browser.WaitUntil(funcToRun);
当然,请确保您funcToRun将正确的测试对象(您实际调用的对象)作为参数.WaitUntil。
由于您可以访问funcToRun方法中的测试对象,因此您可以等到任何您想要的逻辑。这是另一个使用箭头函数的示例,它不等待按钮到.Exist(),而是等待Buttons数组具有16元素。:
// Create a description for the Toolbar.
var toolBar = window.Describe<IToolBar>(new ToolBarDescription
{
NativeClass = "SwingSet2$ToggleButtonToolBar"
});
// There are 16 buttons in the toolbar. Use the WaitUntil method to wait until all 16 buttons are loaded.
// This ensures that any button we press was loaded. If not loaded, the test fails.
toolBar.WaitUntil(tb => (tb.Buttons.Count == 16));