Forum Discussion

ckim's avatar
ckim
Occasional Contributor
11 years ago

Scripting without Aliases

Hey All,



I'm currently testing an application where I can record scripts and the name mapping will work. However, when I quit the application and try to rerun the scripts I recorded, most of them produce the "Ambiguous recognition of the tested object" warning which then leads to the "Object does not exist" error. I read in a separate thread (http://smartbear.com/forums/f74/t90568/what-is-the-best-approach-for-scripting-with-na/) that you can find objects dynamically by using Find, FindChild, etc. with object properties. This seems like what I'm looking for because I'm pretty sure that everytime I close and reopen my application the properties of various objects change and in turn breaks the name mapping of my test project. Could someone help clarify how the Find methods work in getting objects during testing? 



Thank You,

Chris
  • Hi Chris,

     


    To see the full object tree, make sure Show Tested Applications Only is disabled and Show All User Processes is enabled and in the Object Browser toolbar:




    Please refer to the "Object Browser Toolbar" article for details.


    Also, I recommend that you read the "About Object Browser" article and those related to learn how to explore your tested application.

  • TanyaYatskovska's avatar
    TanyaYatskovska
    SmartBear Alumni (Retired)
    Hi Chris,

     


    Sure. You can find the full path to the object in the Object Browser here:




     

  • gid_216's avatar
    gid_216
    Frequent Contributor
    Hi,



    Find method will take 4 parameters i.e. Property name, Property value, Depth, Refresh. First two are mandatory and the other two are optional.



    PropertyName is the property based on which value the object need to be found.

    PropertyValue is the value for the property of object specified as first parameter.

    Depth represents the depth of the object tree. It is a zero based index starting from the object itself i.e if depth is zero, it will search in test object, if one then also search in immediate child objects.Default value for this parameter is 1.

    Refresh is a boolean parameter. If true, it will refresh the namemapping info. Default value is True.



    Syntax : TestObject.Find(Parameters)



    For more information you can visit

    Find Method 

    FindAll Method 

    FindChild Method 

    FindAllChildren Method 



  • TanyaYatskovska's avatar
    TanyaYatskovska
    SmartBear Alumni (Retired)
    Hi Chris,

     


    To see the full object tree, make sure Show Tested Applications Only is disabled and Show All User Processes is enabled and in the Object Browser toolbar:




    Please refer to the "Object Browser Toolbar" article for details.


    Also, I recommend that you read the "About Object Browser" article and those related to learn how to explore your tested application.

  • TanyaYatskovska's avatar
    TanyaYatskovska
    SmartBear Alumni (Retired)
    Hi Chris,

     


    Could you please answer the following questions:


    Does the tabbedPaneobject appear during the test? Or, is this panel always visible when executing the test?


     


    If it opens during the test execution, you will need to use the approach described in the "Waiting for an Object, Process or Window Activation" article to work with the object.


     

  • TanyaYatskovska's avatar
    TanyaYatskovska
    SmartBear Alumni (Retired)
    Hi Chris,

     


    TestComplete may not have enough time to recognize the window that has been just opened during the test run. The Wait methods will make TestComplete wait until the object is fully loaded and ready for test. Give it a try.

  • ckim's avatar
    ckim
    Occasional Contributor
    Hey Deepak,



    Thank you for helping me understand that a little better. The problem I'm having now is that I don't know how to look at the objects properties. They aren't in the name mapping repository unless they get mapped there (which usually hasn't worked for me) and nothing is showing up in my object browser except for the top level "Sys" process. I have had limited success with FindChild in my project thus far though and would appreciate any further insight you or anyone could give me.



    Best,

    Chris
  • ckim's avatar
    ckim
    Occasional Contributor
    Hey Tanya,



    So can I access objects and their different properties by using their full name in my script?



    Best,

    Chris
  • ckim's avatar
    ckim
    Occasional Contributor
    Hey Tanya,



    So I'm having some trouble with using full names in my test scripts. I have a line in my code that is producing an error:




    var textArea = Sys.Process("java").SwingObject("Form").SwingObject("JRootPane", "", 0).SwingObject("null.layeredPane").SwingObject("null.contentPane").SwingObject("tabbedPane").SwingObject("Form").

    SwingObject("holderPanel").SwingObject("Form").SwingObject("jScrollPane1").SwingObject("JViewport", "", 0).SwingObject("textArea");


     




    But for some reason it produces an error saying "Unable to find the object SwingObject("tabbedPane")". I thought that I would be able to use an object's full name that I found from the object browser and reference it in my script like the above line. Is there something I misunderstood and/or could you give me some advice on how to continue from here? I really appreciate all the help!



    Best,

    Chris

  • ckim's avatar
    ckim
    Occasional Contributor
    Hey Tanya,



    I ran the script today and for some reason I got a different error. Today it said that it was "Unable to find the object SwingObject("textArea")". Do you have any idea why the error would be different when I did not change any of the script? But to answer your question, both the tabbedPane and textArea objects appear on the screen during test execution.



    So from what I understand, I need to use one of the WaitNNN methods in my script because a swing object is not active when it gets called. Am I way off or is that the general idea? If that's correct when would I use the WaitNNN method in my script? 



    Thank You,

    Chris