I am filling a web form, which has an built-in preloader animation (which does not impact the browser states) in it, and I am trying to make my script wait for it to be gone, and only then proceed with filling the fields.
Currently I am using this code:
Do
Set el = Nothing
On Error Resume Next
Set el = objIE.document.getElementsByClassName("preloader__loader")(0)
On Error GoTo 0
DoEvents
Sleep 2000
Loop While Not (el Is Nothing)
objIE.document.getElementsByName("button_submit")(0).Click
Not sure why, but still, sometimes this code is not working properly and the Submit button (button_submit) is not pressed.
I would like to avoid wait sentences as much as I can, as they are unreliable in times the page is loading slowly.
Are there any better ways for script to wait for a particular elements (in this case "preloader__loader") to disappear?
Thank you in advance.