Asp.net 在WatiN中,如何等待回发完成
在WatiN,我怎样才能等到回发完成 例如:Asp.net 在WatiN中,如何等待回发完成,asp.net,watin,Asp.net,Watin,在WatiN,我怎样才能等到回发完成 例如: // Postback response modifies update panel elsewhere on page browser.Text("id").TypeText("asd"); // WatiN doesn't wait until postback is completed (what code should I replace it with?). browser.WaitUntilComplete(); 你可以检查IE是否
// Postback response modifies update panel elsewhere on page
browser.Text("id").TypeText("asd");
// WatiN doesn't wait until postback is completed (what code should I replace it with?).
browser.WaitUntilComplete();
你可以检查IE是否忙而不是完成
while (((SHDocVw.InternetExplorerClass)(_ie.InternetExplorer)).Busy)
{
System.Threading.Thread.Sleep(2000);
}
WaitUntilComplete无法识别ajax调用。请参阅本文(在WaitForAsyncPostBackToComplete上搜索),了解如何注入一些代码以使其工作正常: 嗯,,
Jeroen如前所述,WaitForComplete对于加载页面来说很好,但对于Ajax调用不起作用 这里有一个非常简单的解决方案,适用于我希望出现特定元素的情况。。。也许。。。最终。它只是循环,直到页面上存在elementID,或在20秒后超时:
DateTime _startWait = DateTime.Now;
while (_startWait.AddMilliseconds(20000) > DateTime.Now && !WatiNbrowser.Elements.Exists(elementID))
{
System.Threading.Thread.Sleep(200);
Application.DoEvents();
}
非常感谢。这正是我后来发现的。奇怪的是,我在搜索的前三天没有找到这篇文章。很遗憾,我不能将两个答案标记为正确,但我会记住你的技巧,以备将来使用+1我有点怀疑,但这在Ajax中是完美的!谢谢你的提示!:-)既然您处于STA线程中,为什么要调用
Application.DoEvents()
?这确实是多余的。这是我第一次启动C#时的一些旧代码,我不太清楚。