SPONSORS:






User Tag List

Thanks Thanks:  0
Likes Likes:  0
Dislikes Dislikes:  0
Results 1 to 10 of 10
  1. #1
    Member
    Join Date
    Dec 2006
    Posts
    50
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Total Downloaded
    0

    Descriptive Programming - Using regularexpression

    QTP Version: 9.0
    Addins Loaded: ActiveX, Visual Basic, Web
    Application Protocol Testing: IE 6

    Any non-standard controls involved: Not that I'm aware of

    Problem details: Trying to identify an image through regular expression using descriptive programming.

    What searches you have tried: Searched the web, this forum on help using regular expression with DP

    Solutions you have tried:

    K well I have a web page that uses the same image n times to run different jobs. The only differences in the objects are the url and href properties which are both identical values. The urls change based on the job number and a user number. The job number is a given but the user number will not be known. I'm trying to use regular expression with DP to identify and click on the image.

    my code

    Set wiObj_Desc = Description.Create
    wiObj_Desc("url").value=".*task=runnow&job_id= 19.*"
    wiObj_Desc("url").regularexpression=true
    Browser("Browser").Page("Page").Image(wiObj_Desc). highlight
    Set wiObj_Desc = Nothing


    I've tried escaping the =,&,and _ as well and the image still is not found.

    Any suggestions are appreciated.

  2. #2
    Moderator
    Join Date
    Jul 2005
    Location
    Delhi
    Posts
    15,575
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    7 Thread(s)
    Total Downloaded
    0

    Re: Descriptive Programming - Using regularexpression

    wiObj_Desc("href").value=".*task=runnow&job_id =19.*"

  3. #3
    SQA Knight
    Join Date
    Jul 1999
    Location
    Grand Rapids, MI
    Posts
    3,727
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Total Downloaded
    0

    Re: Descriptive Programming - Using regularexpress

    In addition to Tarun's suggestion, I don't think you need to set the regEx property, as per QTP 9.2 Help:

    Note: By default, the value of all Property objects added to a Properties collection are treated as regular expressions.

    This though probably causes no problems, but...

  4. #4
    Member
    Join Date
    Dec 2006
    Posts
    50
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Total Downloaded
    0

    Re: Descriptive Programming - Using regularexpress

    Tarun,

    I should have mentioned that I also tried using the href property. Wasn't sure if you mean to use it instead of or in addition to so I tried both. Replacing url with href didn't work and using both to identify the object did not work as well. Any other ideas?

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

    Re: Descriptive Programming - Using regularexpress

    [ QUOTE ]
    In addition to Tarun's suggestion, I don't think you need to set the regEx property, as per QTP 9.2 Help:

    Note: By default, the value of all Property objects added to a Properties collection are treated as regular expressions.

    This though probably causes no problems, but...

    [/ QUOTE ]

    Yep, I've tried that as well. Not much difference. I read Tarun's word doc on his site and it suggested setting the regularexpression equal to the pattern which I figured was a typo as the value should be a boolean, but out of desperation I tried it anyway with the expected error the result. [img]/images/graemlins/frown.gif[/img]

  6. #6
    Moderator
    Join Date
    Jul 2005
    Location
    Delhi
    Posts
    15,575
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    7 Thread(s)
    Total Downloaded
    0

    Re: Descriptive Programming - Using regularexpress

    Try this

    Set wiObj_Desc = Description.Create
    wiObj_Desc("href").value=".*task=runnow&job_id =19.*"
    wiObj_Desc("url").regularexpression=true
    Browser("Browser").Page("Page").WebElement(wiObj_D esc).highlight
    Set wiObj_Desc = Nothing

  7. #7
    Member
    Join Date
    Dec 2006
    Posts
    50
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Total Downloaded
    0

    Re: Descriptive Programming - Using regularexpress

    kk. I'm an idiot. Been working all along. Was working WEEKS ago when I tried, gave up and tried identifying it using parent stuff. The issue? Of course the issue was that it matched more than one image: job 199, 19645 etc. SOWELL.

    I had to make the following line change:
    wiObj_Desc("href").value=".*task=runnow&job_id =19&.*"

    Thanks for the suggestions though. Greatly appreciated.

  8. #8
    SQA Knight
    Join Date
    Jul 1999
    Location
    Grand Rapids, MI
    Posts
    3,727
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Total Downloaded
    0

    Re: Descriptive Programming - Using regularexpress

    Thommes,

    Now I am confused--or more correctly the idiot!

    Your solution is:

    wiObj_Desc("href").value=".*task=runnow&job_id =19&.*"

    which differs from the failed expression:

    wiObj_Desc("href").value=".*task=runnow&job_id =19.*"

    by adding the single char,'&', after the job_id=19

    After carefully reading the RegEx table in the QTP Help the '&' is not listed as a special char. So how did your subtle change solve the problem you describe in your last posting?

    -Thanks, Terry Horwath

  9. #9
    Advanced Member
    Join Date
    Mar 2007
    Location
    Salt Lake City, UT, USA
    Posts
    606
    Post Thanks / Like
    Mentioned
    1 Post(s)
    Tagged
    0 Thread(s)
    Total Downloaded
    0

    Re: Descriptive Programming - Using regularexpress

    Heh, Terry, I was wondering the same thing. I lept to the conclusion that the & is part of the actual URL of the object he's looking for, but not part of the other URLs.

    I'm hoping that's his answer, or otherwise I'm surprised as well.
    "The last 10% of any software project will take 90% of the budgeted time. The first 90% will take the other 90%"

  10. #10
    Member
    Join Date
    Dec 2006
    Posts
    50
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Total Downloaded
    0

    Re: Descriptive Programming - Using regularexpress

    [ QUOTE ]
    Heh, Terry, I was wondering the same thing. I lept to the conclusion that the & is part of the actual URL of the object he's looking for, but not part of the other URLs.

    I'm hoping that's his answer, or otherwise I'm surprised as well.

    [/ QUOTE ]

    Yep that's pretty close to the situation. There are additional parameters after the job_num. So adding the & limited the pattern to only include job 19.

    ex.

    wiObj_Desc("href").value=".*task=runnow&job_id =19.*"

    matches
    ...job_router_exe.asp?task=runnow&job_id=19&am p;...
    ...job_router_exe.asp?task=runnow&job_id=199&a mp;...

    but

    wiObj_Desc("href").value=".*task=runnow&job_id =19&.*"

    will only match
    ...job_router_exe.asp?task=runnow&job_id=19&am p;...

 

 

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 06:05 AM.

Copyright BetaSoft Inc.