Recently we received a request to provide solution on automating Internet Explorer. In the past, I had similar project which utilises .NET’s web browser control. It was horrid and painful experience 😀 Not wanting to repeat the same nightmare, I googled for better tools.
Then I found WatiN (Web Application Testing in .NET). My preliminary trials has been positive. Just check out below code.
using System; using System.Collections.Generic; using System.Linq; using System.Text; using WatiN.Core; namespace IEAutomator { class Program { [STAThread] static void Main(string[] args) { //Open an URL var browser = new IE("http://sodeve.net/wp-admin"); //Find a textbox by its elementID and set its value var txtLogin = browser.TextField("user_login"); txtLogin.Value = "admin"; //Find a password textbox by its elementID and set its value var txtPassword = browser.TextField("user_pass"); txtPassword.Value = "testPass"; //Find the submit button and then click it var btnLogin = browser.Button("wp-submit"); btnLogin.Click(); //Delay to ensure we can see the result in IE Console.ReadLine(); //Close IE browser.Close(); } } }
I hope I can write more about how WatiN helps me to provide the solution required by my Customer.
loading...
About Hardono
Incoming Search
automation, browser, c#, internet explorer