WebElement: Getting the innertext property dynamically


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
       End If
End Sub

  • Is it possible that your Webelement properties innertest is used to identiofy it, thus when it changes from "Fr. 0.00" the WebElement is no longer valid.

    What about doing something like:

    While  Browser("xxx").Page("xxx").WebElement("xxx").Exist
    newVal = Browser("xxx").Page("xxx").WebElement("html tag:=TD",InnerText:="Fr.*").GetROPRoperty("innerText")

    You might have to change the html tag to match the tag of the WebElement and you might have to use an index if there are multiple currency fields.

    MArk Smith.




  • Hello,

    Thank you for your answer. 

    Actually, the innertext property is indeed used to identify the object but I used a regular expression "Fr\. .*" so it should still be valid.

    I played a little more with the code and I found out that the problem comes from the code being executed inside a sub. If I take the code out of the sub and execute it, it works fine. The code exits the loop as soon as the innertext property changes. 

    I tried to change the sub definition in order to pass the test object by reference like this: 

    Sub TEND_ObjectPropertyValue(byVal transName, ByRef testObject, ByVal objectProperty, byVal objectPropertyValue)

    But it still doesn't work. 

    I feel like I must be missing something really basic here but I don't see it.

  • Here's a simple example that might help:

    Call X(Browser("micClass:=Browser").Page("micClass:=Page"))
    Function X(obj)
    MsgBox x
    End Function

    Mark Smith.

  • 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
           End If

    End Sub

    Check this article for more details.

  • This works like a charm, exactly what I was looking for :-))

    Thanks a lot for your help.