SPONSORS:






User Tag List

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

    finding VBObjects

    I have a VB 6.0 app that creates a bunch VBObjects with similar names during the course of the test process. For example Process("myApp").VBObject("frmMyForm"), Process("myApp").VBObject("frmMyForm_1"),... Process("myApp").VBObject("frmMyForm_99"). To properly test the application I would have to close the app between tests to ensure that when the frmMyForm object is called there is only one Process("myApp").VBObject("frmMyForm") that gets selected.

    I don't seem to find a good way to loop thru the controls and dynamically select the latest control...meaning VBObject("frmMyForm_99").

    Any ideas?

    Thank you for your help in this matter.

  2. #2
    Moderator tristaanogre's Avatar
    Join Date
    Mar 2006
    Location
    Pennsylvania, USA
    Posts
    1,792
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Total Downloaded
    0

    Re: finding VBObjects

    The optimal solution, if you're the developer or if you have a good relationship with your developer, is to write your application code to make sure that each creation of the VBObject has a unique, predictable name. The numbering you're seeing is TestComplete keeping the different forms seperate. If you can make sure that frmMyForm_1 always has that name, then you can always refer to it that way.

    That said, there is a way that you can do what you want without changing application code. You can find child objects by specific properties. If you can identify a specific property of each of those form instances that uniquely identifies it, you can use that property to find your form. There's a help topic on it but the title eludes me at the moment.
    -Robert Martin
    Automated Testing Evangelists
    TestComplete "expert"
    Definition expert - noun - Unknown drip under pressure

  3. #3
    Junior Member
    Join Date
    Feb 2008
    Posts
    5
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Total Downloaded
    0

    Re: finding VBObjects

    It is an existing application so maybe in the next version since I am the "new" developer, I will try to make the change, if I am nice to myself. ;o)

    However I have another problem. I created a function that loops thru all the child vbobjects and returns the last object. However, I am unable to get the last instance of the object, only the one created prior to the last one.

    a. last instance myVBObject_23

    b. Call w1.MainMenu.Click("Open|New Individual Item|Antes Exam")

    BuiltIn.Delay(10 * CustomWaitTime) ' script stops for 5sec.


    WinHandle = FindControl("frmPersonSearch") 'WinHandle should be "myVBObject_24" but returned value is "myVBObject_23"

    Here is the code to find all the vbobjects:

    Set p2 = Sys.WaitProcess( Project.Variables.AppName, 10 * CustomWaitTime )

    Do
    if 0 < inStr( 1, p2.Child(i).Name, ControlName, 0 ) Then
    myControls = myControls & p2.Child(i).Name & ","
    End If
    i = i + 1
    Loop Until i >= p2.ChildCount

    Set p2 = Nothing

    arrControls = Split(myControls, ",")

    I think I tried everything, including increasing the delay or wait time and I cannot get the last object created. I can see it in the Object Browser but cannot list it via my script.

    What am I missing? Any help will be appreciated.

  4. #4
    Senior Member
    Join Date
    Aug 2006
    Posts
    1,920
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Total Downloaded
    0

    Re: finding VBObjects

    Hi,

    I suggest that you try using the FindAll method to do this (see the "FindAll Method" help topic):

    <font class="small">Code:</font><hr /><pre>...
    Set p2 = Sys.WaitProcess( Project.Variables.AppName, 10 * CustomWaitTime )

    objArray = p2.FindAll("Name", "*frmMyForm_*")
    Set last = objArray(UBound(objArray))
    ...</pre><hr />

    Does this help?
    Jared - AQA Support

 

 

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 10.71%
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 03:50 AM.

Copyright BetaSoft Inc.