SPONSORS:






User Tag List

Thanks Thanks:  0
Likes Likes:  0
Dislikes Dislikes:  0
Results 1 to 5 of 5
  1. #1
    Junior Member
    Join Date
    Dec 2010
    Posts
    8
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Total Downloaded
    0

    use regular expression in description object

    Hi all,

    I hope you can help me. I'm using QTP 9.5 and here is what i'm trying to do.

    In IE6 i'm trying to find a webelement with a description object.
    <font class="small">Code:</font><hr /><pre>
    Set oDesc = Description.Create()
    oDesc("micclass").value = "WebElement"
    oDesc("html tag").value = "DIV"
    oDesc("innertext").value = "name"

    Set objChildObject = obj.ChildObjects(oDesc)
    nrChildObjects = objChildObject.Count()
    </pre><hr />

    This works fine, but hidden objects are also on the page. I only want to find the object which <font class="small">Code:</font><hr /><pre>oDesc("x").value</pre><hr /> greater than 0.

    The idea was to use regular expressions, like this:
    <font class="small">Code:</font><hr /><pre>oDesc("x").value = "[1-9][0-9]*"</pre><hr />
    So <font class="small">Code:</font><hr /><pre>oDesc("x").value</pre><hr /> value doesn't start with a 0. This doesn't work. nrChildobjects remains 0.

    Can someone tell me what to do or what i'm doing wrong?

    Thank you!

  2. #2
    Advanced Member Anshoo Arora's Avatar
    Join Date
    Oct 2007
    Location
    New Delhi, India
    Posts
    635
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Total Downloaded
    0

    Re: use regular expression in description object

    What you've done is correct theoretically, but coordinates cannot accept any sort of regex characters. These can only be constant integers.
    Regards,

    Anshoo Arora
    Relevant Codes

  3. #3
    Junior Member
    Join Date
    Dec 2010
    Posts
    8
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Total Downloaded
    0

    Re: use regular expression in description object

    thank you for your reply.

    is there anyway to solve this problem?

  4. #4
    Advanced Member Anshoo Arora's Avatar
    Join Date
    Oct 2007
    Location
    New Delhi, India
    Posts
    635
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Total Downloaded
    0

    Re: use regular expression in description object

    Workaround by omitting objects with x=0:

    <font class="small">Code:</font><hr /><pre>
    Set oDesc = Description.Create()
    oDesc("micclass").value = "WebElement"
    oDesc("html tag").value = "DIV"
    oDesc("innertext").value = "name"

    Set objChildObject = obj.ChildObjects(oDesc)
    nrChildObjects = objChildObject.Count()

    For ix = 0 to nrChildObjects - 1
    If Not objChildObject(ix).GetROProperty("x") = 0 Then
    'do something on the visible object
    End If
    Next
    </pre><hr />

    Workaround by using the above concept + creating your own collection:

    <font class="small">Code:</font><hr /><pre>
    ReDim arrObjects(-1)
    iy = 0

    Set oDesc = Description.Create()
    oDesc("micclass").value = "WebElement"
    oDesc("html tag").value = "DIV"
    oDesc("innertext").value = "name"

    Set objChildObject = obj.ChildObjects(oDesc)
    nrChildObjects = objChildObject.Count()

    For ix = 0 to nrChildObjects - 1
    If Not objChildObject(ix).GetROProperty("x") = 0 Then
    ReDim Preserve arrObjects(iy)
    Set arrObjects(iy) = objChildObject(ix)

    iy = iy + 1
    End If
    Next

    For ix = LBound(arrObjects) To UBound(arrObjects)
    Print arrObjects(ix).GetROProperty("x")
    Next
    </pre><hr />

    You can also create a RecordSet or Dictionary object for the above collection.
    Regards,

    Anshoo Arora
    Relevant Codes

  5. #5
    Junior Member
    Join Date
    Dec 2010
    Posts
    8
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Total Downloaded
    0

    Re: use regular expression in description object

    Thank you so much AnshooArora! Works great!

    I didn't know it's possible to put an object into an array. Now i do know :-)

    one question: why are you doing redim arrObjects(-1)?

 

 

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Search Engine Optimisation provided by DragonByte SEO v2.0.36 (Pro) - vBulletin Mods & Addons Copyright © 2016 DragonByte Technologies Ltd.
Resources saved on this page: MySQL 11.54%
vBulletin Optimisation provided by vB Optimise v2.6.4 (Pro) - vBulletin Mods & Addons Copyright © 2016 DragonByte Technologies Ltd.
User Alert System provided by Advanced User Tagging v3.2.8 (Pro) - vBulletin Mods & Addons Copyright © 2016 DragonByte Technologies Ltd.
vBNominate (Lite) - vBulletin Mods & Addons Copyright © 2016 DragonByte Technologies Ltd.
Feedback Buttons provided by Advanced Post Thanks / Like (Pro) - vBulletin Mods & Addons Copyright © 2016 DragonByte Technologies Ltd.
Username Changing provided by Username Change (Free) - vBulletin Mods & Addons Copyright © 2016 DragonByte Technologies Ltd.
BetaSoft Inc.
Digital Point modules: Sphinx-based search
All times are GMT -8. The time now is 07:49 PM.

Copyright BetaSoft Inc.