Depuis le site Web Watin:Watin: MsHtmlBrowser ne 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();
L'exemple ci-dessus fonctionne très bien. Toutefois, étant donné que je ne veux pas ouvrir une fenêtre de navigateur, je modifié le code ci-dessus pour utiliser 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();
La ligne de TypeText est de lancer une exception. Une idée de ce qui ne va pas?
Quelle est l'exception? Ne trouve-t-il pas le TextField, et donc référençant un pointeur nul? –