Wait until specific value appears in selenium excel vba

前端 未结 2 549
名媛妹妹
名媛妹妹 2021-01-26 21:24

I have an element with this html

<
2条回答
  •  耶瑟儿~
    2021-01-26 22:24

    I would re-write this as you risk an infinite loop. Make it a timed loop and add in a DoEvents.

    Dim result As String, testElement As Object, t As Date
    Const MAX_WAIT_SEC As Long = 10 '<==adjust time here
    t = Timer
    Do
        DoEvents
        On Error Resume Next
        Set testElement = .FindElementById("ContentPlaceHolder1_Label2")
        result = testElement.Text
        If Timer - t > MAX_WAIT_SEC Then Exit Do
        On Error GoTo 0
    Loop While result <> "تم حفظ التعديل بنجاح"
    

提交回复
热议问题