Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Gathering certain child objects
#1
Not Solved
I have narrowed down the code I need to grab only the child objects from the webpage that I want, by using three filters. I just found out that I need to narrow it down a bit more.

I only want the objects that DO NOT have "LCP" in the "innertext".

Here is the code that I am using:

=========================================================

Code:
Dim oDesc 'Description Object
Dim colObject 'Object Collection

Set oDesc = Description.Create
oDesc("micclass").Value = "WebElement"
oDesc("html tag").Value = "SPAN"
oDesc("x").Value = 180
oDesc("text").Value <> "LCP.*"
oDesc("text").regularExpression = True
=======================================================

But it is erroring on this line:
Code:
oDesc("text").Value <> "LCP.*"

I think it doesn't like me using the "<>" to designate NOT EQUAL there. What other syntax can I use?

I can't just use what the innertext does equal because this changes. But I do know that I don't want it to have LCP in the beginning of the object's name.

Thanks!
SBsteven
Also should I be using "text" or "innertext"?

SBsteven
Reply
#2
Not Solved
I just found out that I MUST use "innertext" for this.

I ran another test on one of the child objects I did want and it works correctly, but I want to rule certain child objects out.

Here is the line of code I used when I do know the child object's name:

oDesc("innertext").Value = "CSR"

That works fine, but that name can change. I just don't want any child object's that begin with LCP.

SBteven
Reply
#3
Not Solved
(Just had some help over at the HP Forums)

Here is the NEW code I am now using:
===========================================

Code:
Dim oDesc 'Description Object
Dim colObject 'Object Collection

Set oDesc = Description.Create
oDesc("micclass").Value = "WebElement"
oDesc("html tag").Value = "SPAN"
oDesc("x").Value = 180
oDesc("innertext").Value = ".*[^LCP]"

Set colObject = Browser("micClass:=Browser").Page("micClass:=Page").ChildObjects( oDesc )

'Retrieve the count
iCount = colObject.Count

msgbox iCount
'Count is now coming back with "2", which is correct

============================================

But now I have another question.

I was just told by a team member to NOT use the x value as a filter, but instead use the instr function.

I could just iterate through the child objects using an index and exclude them if their innertext contains LCP and I could do that with the instr function.

Problem is I don't know much about instr functions. I will do some searching on the web, unless someone here would like to give me a head start on it.

Thanks,
SBsteven
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  SwfTreeview - Color validation for child item YogeshCallappa 0 2,295 11-10-2016, 04:55 PM
Last Post: YogeshCallappa
  Driver Script to control child scripts sumanhyd 1 3,191 07-26-2016, 07:06 PM
Last Post: Ankesh
  UFT 12.50 unable to recognize child objects from a Dialog Class in Firefox jesusisaac 1 3,812 08-20-2015, 11:39 PM
Last Post: ADITI1992
  Child object shwetakondekar 0 2,141 07-01-2015, 03:28 PM
Last Post: shwetakondekar
  How to write a script for fly out menus (Parent - Child - Sub Child) rajkumarsm 3 4,733 09-02-2014, 10:01 AM
Last Post: vinod123

Forum Jump:


Users browsing this thread: 4 Guest(s)