取決於你的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