The task is to click on a button in the application to select the parameters in the two combo boxes on the site and press the button there.
Here is the code:
HtmlWindow frames = webBrowser1.Document.Window.Frames[0]; var elements = frames.Document.GetElementsByTagName("select"); elements[0].SetAttribute("value", "1"); elements[1].SetAttribute("value", "1"); var elements1 = frames.Document.GetElementsByTagName("input"); elements1[0].InvokeMember("click"); Everything works smoothly, I press the button in the application, everything that needs to be done on the site, very quickly I press a button (by hand) quickly and everything happens on the site. But as soon as I insert the code into the loop, the application immediately hangs after clicking on the button.
The condition for exit from the cycle is 100%. For the test, I tried even through for to put 2-3 passes through the cycle, no more, it still hangs. I suspect that the site does not have time to respond to the code that is in the loop. How can this be prevented? If you use webBrowser1.DocumentCompleted , what will the handler look like? After all, I work in a cycle. If it had to be done once, then without problems, but with a cycle, problems arise.