I have an element with this html
I have tried this solution and it worked well for me This was with the help of Ziggus' suggestion
Do Until .FindElementById("ContentPlaceHolder1_Label2").Text = "تم حفظ التعديل بنجاح"
Application.Wait Now() + TimeValue("00:00:01")
Loop
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 <> "تم حفظ التعديل بنجاح"