I am coding in C# using WindowsForms. I am trying to iterate through a list of ID's that changes the url of a webbrowser control.
ClientID is an List<int> ClientID = new List<int>();
And filled with around 10-15 different numbers.
The foreach goes too quickly for the webbrowser control, and because of that the ErrorDiv is always null. The site isn't able to load, thus I am not able to check for the div with the specified class. If this class does exist, the foreach has to contiue with the next Client.
foreach (int Client in ClientID)
{
if(webBrowser1.ReadyState == WebBrowserReadyState.Complete)
{
webBrowser1.Navigate(URLconsult + "/" + Client);
}
var ErrorDiv = webBrowser1.Document
.GetElementsByTagName("div")
.Cast<HtmlElement>()
.FirstOrDefault(m => m.GetAttribute("className") == "incompleteConsultNotification");
Console.WriteLine(webBrowser1.Document.GetElementsByTagName("div").Cast<HtmlElement>().FirstOrDefault(m => m.GetAttribute("className") == "incompleteConsultNotification"));
//if (ErrorDiv == null)
//{
// Console.WriteLine("Normal");
//}
//else
//{
// Error.Add(Client);
// continue;
//}
}
The HTML div I try to target:
<div class="incompleteConsultNotification">
This form is incomplete. Please add the following:
<ul>
<li> option 1</li>
<li> option 2</li>
</ul>
</div>