Yes, this does seem like a very common question and trust me, I looked for a solution to this for quite a while now. It's about a WinForms-WebBrowser.
This right below doesn't seem to work because the page I'm loading seems to keep executing javascript, so it never completes (don't know if my assumption is right, but it definitely is never set to complete).
browser.DocumentCompleted += (sender, e) =>
{
if (browser.ReadyState != WebBrowserReadyState.Complete)
return;
//browser is done loading
};
elementToClick.InvokeMember("click");
This approach doesn't work either for whatever reason, literally no idea why.
browser.DocumentCompleted += (sender, e) =>
{
if (e.Url.AbsolutePath != (sender as WebBrowser).Url.AbsolutePath)
return;
//browser is done loading
};
elementToClick.InvokeMember("click");
This should end up as a function such as PageLoad(), which I call after navigating to different browserdocuments. So Application.Doevents() is not an option as I need to wait until the new document is loaded before continuing. And neither is Thread.Sleep(x), because it needs to resume the code right when it's finished (speed matters here). Thread.Sleep(x) in a while-loop will completely stop my browser from loading.
Are there any different approaches? If there's information missing, please let me know.