0
從華廷網站:華廷:MsHtmlBrowser不會的TypeText
// Open a new Internet Explorer window and
// goto the google website.
IE ie = new IE("http://www.google.com");
// Find the search text field and type Watin in it.
ie.TextField(Find.ByName("q")).TypeText("WatiN");
// Click the Google search button.
ie.Button(Find.ByValue("Google Search")).Click();
// Uncomment the following line if you want to close
// Internet Explorer and the console window immediately.
//ie.Close();
上述樣品的工作就好了。然而,因爲我不想打開一個瀏覽器窗口,我修改了上面的代碼使用MsHtmlBrowser:
// goto the google website.
var ie = new MsHtmlBrowser();
ie.GoTo("http://www.google.com");
// Find the search text field and type Watin in it.
ie.TextField(Find.ByName("q")).TypeText("WatiN");
// Click the Google search button.
ie.Button(Find.ByValue("Google Search")).Click();
的的TypeText線拋出異常。任何想法有什麼不對?
什麼是例外?它沒有找到TextField,從而引用空指針? – 2010-01-21 17:47:13