取决于你的JS和HTML代码的外观。这并不简单。尝试使用WaitUntil...
方法。
比方说,工作后已完成与ID foo
出现新的div元素。要等待使用此代码:
ie.Div("foo").WaitUntilExists();
但有时并非如此简单。比方说,在工作完成后,表格的内容会发生变化,即。旧行被删除,并出现新行。如果是这样的话:
//Get cell reference
var cell = ie.Table("bar").OwnTableRow(Find.First()).OwnTableCell(Find.First());
var cellRef = cell.GetJavascriptElementReference();
//Change text of that cell using javascript. jQuery could be used if it's used on that page
//If you are 100% sure, that something will change, just assign cell.Text to text. If so, you don't even
//need cellRef
var text = "Dummy text or random or whatever";
ie.RunScript(cellRef + ".childNodes[0].nodeValue = '" + text + "'");
//TODO:
//Do something here to fire ajax request
//Wait until table will be updated, ie. wait until first cell will not contains assigned dummy text.
//This could be done in many ways.
ie.Table("bar").WaitUntil(t => t.OwnTableRow(Find.First()).OwnTableCell(Find.First()).Text != text);
//or just:
//cell.WaitUntil(c => c.Text != text), but maybe it will not work in your case
无论如何,这只是一些提示。它几乎总是一个痛苦,所以不要告诉我你的实际代码;)
我做了类似于你概述的内容。完成后向元素添加属性,我等着Watin。 – aknuds1