0

I have the below code and I want to know how to make the code wait for the WebBrowser to load the next page after activating the submit button:

        WebBrowser wb = new WebBrowser();
        wb.ScrollBarsEnabled = false;
        wb.ScriptErrorsSuppressed = false;
        wb.Navigate(baseUrl+uri);
        while (wb.ReadyState != WebBrowserReadyState.Complete) { Application.DoEvents(); }
        var docTitle1 = wb.DocumentTitle;
        foreach (HtmlElement form in wb.Document.Forms)
            form.InvokeMember("submit");
        Stream dataStream = wb.DocumentStream;
        StreamReader reader = new StreamReader(dataStream);
        string responseFromServer = reader.ReadToEnd();
        Console.WriteLine(responseFromServer);

I can hear the click sound when it activates the submit but I hear it when it is already at the end of the code. If I put a break in place, I can see that the wb object has the data for the previous page.

Thanks!

0 Answers0