C# how to wait for a webpage to finish loading before continuing

后端 未结 11 1219
暖寄归人
暖寄归人 2020-11-27 03:33

I\'m trying to create a program to clone multiple bugs at a time through the web interface of our defect tracking system. How can I wait before a page is completely loaded

相关标签:
11条回答
  • 2020-11-27 03:57

    This code was very helpful for me. Maybe it could be for you also

    wb.Navigate(url);
    while(wb.ReadyState != WebBrowserReadyState.Complete)
    {
         Application.DoEvents();
    }
    MessageBox.Show("Loaded");
    
    0 讨论(0)
  • 2020-11-27 04:00

    Task method worked for me, except Browser.Task.IsCompleted has to be changed to PageLoaded.Task.IsCompleted.

    Sorry I didnt add comment, that is because I need higher reputation to add comments.

    0 讨论(0)
  • 2020-11-27 04:02

    Have a go at Selenium (http://seleniumhq.org) or WatiN (http://watin.sourceforge.net) to save yourself some work.

    0 讨论(0)
  • 2020-11-27 04:03

    Assuming the "commit" element represents a standard Form submit button then you can attach an event handler to the WebBrowsers Navigated event.

    0 讨论(0)
  • 2020-11-27 04:03
    while (true)
            {//ie is the WebBrowser object
                if (ie.ReadyState == tagREADYSTATE.READYSTATE_COMPLETE)
                {
                    break;
                }
                Thread.Sleep(500);
            }
    

    I used this way to wait untill the page loads.

    0 讨论(0)
提交回复
热议问题