Apr 3, 2018 02:52 AM
(This post was last modified: Apr 3, 2018 02:53 AM by ThatAlbinoFrog.)
Hey!
Simple question, is there any way I can get a webbrowser to wait until an element is present? I'm not an amazing coder, so here's my best example of what I'm trying to do -
The problem with this is that the element doesn't have an ID, so when I'm trying to do something like click it, I have to do something like this -
I've tried using documentcompleted, but the element loads in after the page, meaning I have to scroll down to load it in. Currently a timer works but if other people use this program with proxies or slower internet, the timer would have to be different.
I apologise if this is worded poorly, I'm new to this :)
Thanks!
Simple question, is there any way I can get a webbrowser to wait until an element is present? I'm not an amazing coder, so here's my best example of what I'm trying to do -
Code
Do While PageLoaded = False
Dim OObject As Object
OObject = WebBrowser1.Document.GetElementById("Element-That-I-Need-Loaded")
If (OObject Is Nothing) Then
Pageloaded = False
Else
PageLoaded = True
End If
LoopThe problem with this is that the element doesn't have an ID, so when I'm trying to do something like click it, I have to do something like this -
Code
For Each altelm As HtmlElement In WebBrowser1.Document.GetElementsByTagName("SPAN")
If altelm.GetAttribute("classname").ToString = "Classname-of-Element-I-Need-Loaded" Then
altelm.Focus()
altelm.InvokeMember("click")
End IfI've tried using documentcompleted, but the element loads in after the page, meaning I have to scroll down to load it in. Currently a timer works but if other people use this program with proxies or slower internet, the timer would have to be different.
I apologise if this is worded poorly, I'm new to this :)
Thanks!


