When we execute a large number of test cases, say 50-100  in Batch Execution using TestComplete, sometimes TestComplete does not recognize the objects. But if the same object is highlighted manually, it gets highlighted.

It’s weired, isn’t it? But Yes, it do happen in reality. This is due to the reason that, the object mapping stored in TestComplete for objects is not able to match it with the object state at the run time.

To overcome this issue,TestComplete provides us different methods which can be used to refresh the object state.

  • Refresh method
  • RefreshMappingInfo Method

Refresh method

By using this method, the tree hierarchy of the application under test gets updated(refreshed) along with all the windows and child objects present in the application.

Syntax:

TestedObj.Refresh

Where

TestedObj : Reference to the object that is present in Application under test.

Result: None

RefreshMappingInfo Method

When we map the object of Application under test for first time using NameMapping or Aliases, TestComplete searches for the object in the object tree and stores a reference to this object. At the run time TestComplete uses the stored reference to forward the method calls to the mapped object. If the object is recreated, the reference becomes invalid. In such case RefreshMapping method is used to update the reference to the underlying object.

Syntax:

TestedObj.RefreshMappingInfo

Where

TestedObj : Reference to the object that is present in Application under test.

Result: None

To understand it better, lets take a scenario where a notepad is mapped using its caption name(Untitled.txt). When we open a file in the notepad, its caption changed to the file name. for example “Automate-360.txt”. Now when you will try to write some text into the file at runtime, it wont allow you do say as it does not identify the object which got changed at runtime when you opened another file into the notepad. In order to use the same mapped object to write something in this new file we can use the RefreshMappingInfo method.The code for the same could be as below:

' Specifies the object that corresponds to the Untitled window
Set AliasObj = Aliases.notepad.wndNotepad
' Specifies command-line parameters for the Notepad application
TestedApps.notepad.Params.SimpleParams.CommandLineParameters = "C:\Temp\Automated-360.txt"

' Launches Notepad and opens the MyFile file in it
TestedApps.notepad.Run()

' Refreshes mapping information
Aliases.RefreshMappingInfo
' Enters text in the file
AliasObj.Keys("Automated-360")

' Closes Notepad without saving the changes
TestedApps.notepad.Close
Aliases.notepad.dlgNotepad.btnNo.Click()

Incorporating these methods in your automation scripts will help you in smooth batch execution of the testcases in TestComplete.

Happy Learning!!!!!

let us know your feedback, questions, suggestion via the comments below.

See also  How Test Complete Handles Unexpected Windows

8 COMMENTS

  1. Hi Anurag,

    I am having tough time in recognizing the child objects of an expandable tree structure. When I use object spy for a child object(after expansion) it’s taking the parent object properties for the whole structure.That means it’s treating whole structure as a single entity(only parent properties are identified).When recording the script it’s taking co-ordinates value to recognize the child objects.Please help me with that. The structure you can visualise as in QC.

    • Hi All,

      any one have solutions for this issue. please post ..

      issue:
      Tech:Java .
      Desktop application ,
      Domain: Banking
      when we click on desktop application’s button (eg: transaction history). application open new window in web, the web window is have dynamic values developed in javascript..web window’s child objects are not identifiable by object spy.. need to verify those dynamic values

      Thanks

  2. Hi Manish,

    I am not able to get the exact issue you are facing.But i think you are not able to create aliases for child objects.Please follow the below step to create aliases for child object.

    1)Go to tools—>options
    2)Click on general tab
    3)Check “Create aliases for child objects”
    4)Click on OK button.

    Let me know if this helps you..

    • any one have solutions for this issue. please post ..

      issue:
      Tech:Java .
      Desktop application ,
      Domain: Banking
      when we click on desktop application’s button (eg: transaction history). application open new window in web, the web window is have dynamic values developed in javascript..web window’s child objects are not identifiable by object spy.. need to verify those dynamic values

      Thanks

  3. Hi Anurag,

    I am also facing same issue as Manish is facing. Child objects are not recognized by testComplete. Only parents objects are recogniszed. When recording the script it’s taking co-ordinates value to recognize the child objects. Checkbox “Create aliases for child objects” is already checked. Still not able to recognize the objects.
    I am using Java script .Is there any way to recognize the child object using Java script.
    Can you pl help.

LEAVE A REPLY

Please enter your comment!
Please enter your name here

This site uses Akismet to reduce spam. Learn how your comment data is processed.