[RESOLVED] If text has been found in WebBrowser1 then GoTo... , if hasn't then continue queue
Hi everyone,
I want my program to check if "<div class="error_box"> Please try later. </div>" element has been found in WebBrowser1, if it has been found then "GoTo eend", if hasn't been found then "Application.DoEvents()".
This is my script, but it doesn't work as I desired:
Code:
If WebBrowser1.Document.GetElementById("error_box").InnerText Then
GoTo eend
Else
Application.DoEvents()
End If
Thanks for help, I give reputation as always :)
Re: If text has been found in WebBrowser1 then GoTo... , if hasn't then continue queu
Hi,
Use Html.GetAttribute() instead of GetElementById() to check the classname attribute. See sample code provided by MSDN documentation.
MSDN
HtmlElement.GetAttribute Method (String)
VB.NET Code:
If (WebBrowser1.Document IsNot Nothing) Then
Dim Elems As HtmlElementCollection
Dim WebOC as WebBrowser = WebBrowser1
Elems = WebOC.Document.GetElementsByTagName("div")
For Each elem As HtmlElement In Elems
Dim NameStr As String = elem.GetAttribute("className")
If ((NameStr IsNot Nothing) And (NameStr.Length <> 0)) Then
If NameStr.ToLower().Equals("error_box") Then
GoTo eend
Else
'Application.DoEvents()
End If
End If
Next
End If
Regards,
- kgc