1

My app needs to click a button on a page x number of times (user defined). The page works like this: After you click a button, the page reloads with the same yes/no buttons. Using my code, the app goes crazy and starts clicking way too fast and then crashes. What can I do so it waits until the page reloads?

int toGet = Convert.ToInt32(numberOfTimes.Text);
int got = 0;

while (got < toGet)
{
    while (webBrowser1.ReadyState != WebBrowserReadyState.Complete) Application.DoEvents();
    webBrowser1.Document.GetElementById("votea").InvokeMember("click");
    got++;
}
famousgarkin
  • 13,687
  • 5
  • 58
  • 74
No One
  • 11
  • 1

1 Answers1

1

Add a delay, e.g. 500ms, between the clicks inside your while loop by using setTimeout() function

Vish
  • 4,508
  • 10
  • 42
  • 74