views:

36

answers:

2

I navigate the webbrowser in my application with

Private Sub wb_DocumentCompleted(ByVal sender As Object, ByVal e As System.Windows.Forms.WebBrowserDocumentCompletedEventArgs) Handles wb.DocumentCompleted

But I need to navigate to another page after Logging in to the website

How can I wait the first page to be loaded fully then navigate to another page?

+1  A: 

use the webbrowser document completed event:

here is a link

Emerion
+5  A: 

Hi this code peace will help as it did for me

     private void waitTillLoad()
           {
               WebBrowserReadyState loadStatus;
               //wait till beginning of loading next page 
               int waittime = 100000;
               int counter = 0;
               while (true)
               {
                   loadStatus = webBrowser1.ReadyState;
                   Application.DoEvents();

                   if ((counter > waittime) || (loadStatus == WebBrowserReadyState.Uninitialized) || (loadStatus == WebBrowserReadyState.Loading) || (loadStatus == WebBrowserReadyState.Interactive))
                   {
                       break;
                   }
                   counter++;
               }

               //wait till the page get loaded.
               counter = 0;
               while (true)
               {
                   loadStatus = webBrowser1.ReadyState;
                   Application.DoEvents();

                   if (loadStatus == WebBrowserReadyState.Complete)
                   {
                       break;
                   }
                   counter++;

               }
}
Ravi shankar