Selenium Webdriver (VBA): Explicit Wait Selenium Webdriver (VBA): Explicit Wait selenium selenium

Selenium Webdriver (VBA): Explicit Wait


You might try looping until the element has been set correctly with a time out to ensure you can't go into an infinite loop. The danger with the accepted answer is there is no way to escape the loop if not found.

Dim t As Date, ele As Objectt = TimerDo    DoEvents    On Error Resume Next    Set ele = .FindElementById("element")    On Error GoTo 0    If Timer - t = 10 Then Exit Do '<==To avoid infinite loopLoop While ele Is Nothing

Note: User @florentbr wrote a js wait clickable function to be executed via Selenium Basic. Example in this SO answer.


The selenium plugin for VBA is unofficial and doesn't support this feature.

You can work around this by using onError to retry the action that is producing an error until it succeeds or times out:

Sub test    OnError GoTo Retry        webDriver.findElementById("element")    Exit Sub    Dim i as integer    :Retry        webDriver.Wait(500)        i = i + 1        if i = 20 then onerror go to 0    Resumeend sub


In vba you can use Implicit wait "driver.Timeouts.ImplicitWait = 10 'Timeunits 'seconds" it will wait maximum limit if the element is found before the set time it will process further.