|
-
Apr 1st, 2016, 11:32 AM
#1
Thread Starter
Member
[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
-
Apr 1st, 2016, 12:49 PM
#2
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
Tags for this Thread
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|