Micro Focus QTP (UFT) Forums
Count number of WebElement with certain property - Printable Version

+- Micro Focus QTP (UFT) Forums (https://www.learnqtp.com/forums)
+-- Forum: Micro Focus UFT (earlier known as QTP) (https://www.learnqtp.com/forums/Forum-Micro-Focus-UFT-earlier-known-as-QTP)
+--- Forum: VB Scripting/Descriptive Programming (https://www.learnqtp.com/forums/Forum-VB-Scripting-Descriptive-Programming)
+--- Thread: Count number of WebElement with certain property (/Thread-Count-number-of-WebElement-with-certain-property)



Count number of WebElement with certain property - hari1024 - 01-13-2012

Hello,
I have this piece of code with different index values for WebElement("class:=errmsg errmsgDetails").

[i]
Code:
Dim errormsg1
Set errormsg1=Browser("IHG").Page("Home").WebElement("class:=errmsg errmsgDetails")

If  errormsg1.Exist Then
    msg=errormsg1.GetROProperty("innertext")
    msgbox(msg)
End If
[/i]


How do I capture elements with same property on the screen and then would like to run a loop to capture inner text.

For example rightnow in this case there are two occurences when I add index:=0 or index:=1 I , the getROProperty part works fine.


RE: Count number of WebElement with certain property - vIns - 01-13-2012

Hi,
to get the count

Code:
Set myElement = Description.Create
myElement("micclass").value = "WebElement"
myElement("class").Value = "errmsg errmsgDetails"
msgbox Browser("IHG").Page("Home").ChildObjects(myElement).Count

below statement will return all the webelements with the properties. it s a collection. so u can loop to get the property values for each object[/code]
Code:
Browser("IHG").Page("Home").ChildObjects(myElement)