Wait load webpage until element is present I am new to c# and its concepts, so i am sorry if this question is kind of dumb. I try to do some automatation using the winforms webbrowser control. I'm looking for a method that loads a web page until a web item is found. to wait for the web page to load, I use line "Wait(30)" "Wait(30)" this is an obvious expectation and this is not optimal. I just need a synchronous download: Find web item if the web item is missing on the page then wait 1 second, if the web item is found finish downloading a web page.
private void Wait(int number) { DateTime time = DateTime.Now; do { Application.DoEvents(); } while (time.AddSeconds(number) > DateTime.Now); } private void CheckFindElement1() { try { Wait(30); var mlm = web_Browser.Document.GetElementById("id1"); } catch (Exception) { Wait(1); CheckFindElement1(); } }
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)