Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Count number of webelement with specific names
#1
Solved: 11 Years, 3 Months, 3 Weeks ago
Hi all..
I am having Webtable in page ..From that webtable I would like to count number of webelements with name of "PDF" or "XLS".

Code I am using,

Code:
Set Desc_Element = Description.Create()
Desc_Element("micclass").value = "WebElement"
Desc_Element("name").Value = ".*XLS.*"
Set Element= Browser("XXX").Page("XXX").WebTable("XXX").childobjects(Desc_Element )
MsgBox "Number of Elements: " & Element.Count

Now I'm getting Output is :- 5. Bcoz I defined only "XLS" in Description.
But I need the count of webelement object with the name of "PDF" as well as "XLS".
Pls help me to get solution for this.

attaching screenshot.PF


Attached Files Image(s)
   
Reply
#2
Solved: 11 Years, 3 Months, 3 Weeks ago
Try this...

Code:
Set Desc_Element = Description.Create()
Desc_Element("micclass").value = "WebElement"

Set Element= Browser("XXX").Page("XXX").WebTable("XXX").childobjects(Desc_Element )

For i = Lbound(Element) to Ubound(Element)

    objname = Element(i).GetROProperty("name")
    
    If instr(1,objname,"XLS") = 1 Then
        Cnt = Cnt + 1
    End If

    If instr(1,objname,"PDF") = 1 Then
        Cnt = Cnt + 1
    End If

Next

Msgbox "Total No. of Elements : = " & Cnt
Reply
#3
Solved: 11 Years, 3 Months, 3 Weeks ago
@ssvali : The code which you have posted will take much more time to execute and give the count coz it has to compare each element to check for PDF or XLS. Instead of this we can use regular expression which requires less time for execution.

Just update the line

Code:
Desc_Element("name").Value = ".*XLS.*"


with below line

Code:
Desc_Element("name").Value = ".*XLS.*|.*PDF.*"


Hope this will work for you.

Regards,
Ankesh
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  UFT issues with Outsystems dynamically generated Id/names jherron 2 1,346 03-02-2020, 09:33 PM
Last Post: Swishy70
Question How to open IE/Chrome/Firefox with a specific size? DarkestAmadeus 0 2,046 07-19-2018, 05:38 AM
Last Post: DarkestAmadeus
Exclamation WebElement("WebElement").Click is not working sia sharma 7 23,954 09-28-2016, 08:58 PM
Last Post: supputuri
  VB Script to count number of links in a web page. Suma Parimal 4 25,257 07-01-2015, 12:59 PM
Last Post: govind
  Check specific links of a webpage rocky9 1 2,702 06-11-2015, 06:23 PM
Last Post: venkatesh9032

Forum Jump:


Users browsing this thread: 1 Guest(s)