AND AFTER FIRE THE HTML ELEMENT GO TO THE RESPECTIVE PAGE.
class Program
{
private static bool completed = false;
private static WebBrowser wb;
[STAThread]
static void Main(string[] args)
{
wb = new WebBrowser();
wb.DocumentCompleted += new WebBrowserDocumentCompletedEventHandler(wb_DocumentCompleted);
//wb.Navigate("http://www.erecsdharge.com");
wb.Navigate(@"http://www.abc.com/default.aspx");
while (!completed)
{
Application.DoEvents();
Thread.Sleep(100);
}
Console.Write("\n\nDone with it!\n\n");
Console.ReadLine();
}
static void wb_DocumentCompleted(object sender, WebBrowserDocumentCompletedEventArgs e)
{
try
{
if (!completed)
{
Console.WriteLine(wb.Document.Body.InnerHtml);
HtmlDocument doc = wb.Document;
HtmlElement username = doc.GetElementById("CphPageMiddle_txtUserID");
HtmlElement password = doc.GetElementById("CphPageMiddle_txtPassword");
// HtmlElement submit = doc.get("btnLogin");
username.SetAttribute("value", "ID");
password.SetAttribute("value", "PWD");
// submit.InvokeMember("click");
//after click on login button return to main page by navigate to the main page here.....
wb = new WebBrowser();
wb.DocumentCompleted += new WebBrowserDocumentCompletedEventHandler(wb_DocumentCompletedlanding);
wb.Navigate(@"http://www.abc.com/mainpage.aspx");
if (wb.Url.ToString().IndexOf("LandingPage.aspx") > -1)
{
completed = false;
while(!completed)
{
Application.DoEvents();
Thread.Sleep(100);
}
}
Console.WriteLine();
completed = true;
}
}
catch(Exception ex)
{
throw ex;
}
}
static void wb_DocumentCompletedlanding(object sender, WebBrowserDocumentCompletedEventArgs e)
{
try
{
if (!completed)
{
Console.WriteLine(wb.Document.Body.InnerHtml);
}
}
catch (Exception ex)
{
throw ex;
}
}
}