WebElement: Getting the innertext property dynamically

Hello,

I'm having a problem with a little piece of code and I don't understand why.

What I'm trying to do is the following: I have a page where I need to calculate the amount of an offer. When we first get to the page, the innertext property of the field is Fr. 0.00. There are several fields to fill out and at the end, we need to click on a button to calculate the amount. It takes a few seconds for the field to be updated and I have a while loop that waits until the innertext property of the field is different from Fr. 0.00

This is part of the code I have. The problem is that it does not detect the change in the innertext property. If I run the code when innertext = "Fr. 0.00", the while loop is correctly executed and if I run it when innertext <> "Fr. 0.00", it does not enter the while loop. But if the innertext property changes while the code is inside the while loop, it does not exit the loop, which is what I want to happen of course. What am I doing wrong?

Thank you.

TEND_ObjectPropertyValue "TEST", Browser("xxx").Page("xxx").WebElement("xxx")"innertext""Fr. 0.00"

Sub TEND_ObjectPropertyValue(transName, testObject, objectProperty, objectPropertyValue)
    
   While UCase(Trim(CStr(testObject.getROProperty(objectProperty)))) = UCase(Trim(CStr(objectPropertyValue)))
       If DateDiff("s", perf_timer_starttime, now) > perf_timer_timeoutsec Then
           ExitTest
       End If
    Wend
    
End Sub

Parents
  • Verified Answer

    Since the Object is refreshed after your first operation, you should use the RefreshObject method as given below.

    Sub TEND_ObjectPropertyValue(transName, testObject, objectProperty, objectPropertyValue)
        
       While UCase(Trim(CStr(testObject.getROProperty(objectProperty)))) = UCase(Trim(CStr(objectPropertyValue)))
           If DateDiff("s", perf_timer_starttime, now) > perf_timer_timeoutsec Then
               ExitTest
           End If

           testObject.RefreshObject
        Wend
        
    End Sub

    Check this article for more details.

Reply
  • Verified Answer

    Since the Object is refreshed after your first operation, you should use the RefreshObject method as given below.

    Sub TEND_ObjectPropertyValue(transName, testObject, objectProperty, objectPropertyValue)
        
       While UCase(Trim(CStr(testObject.getROProperty(objectProperty)))) = UCase(Trim(CStr(objectPropertyValue)))
           If DateDiff("s", perf_timer_starttime, now) > perf_timer_timeoutsec Then
               ExitTest
           End If

           testObject.RefreshObject
        Wend
        
    End Sub

    Check this article for more details.

Children