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