Come let us explore together…

Archive for May, 2010

Extending Code Template feature in TestComplete


We have a feature in TestComplete to store code templates and use it whenever we need while coding with a keyboard short-cut CTRL+ J.

Advantages:

  • Supports all TestComplete script languages
  • Has templates of different statements, declarations from the language
  • Can be accessed with a keyboard short cut
  • Can avoid typing and declaration errors
  • Can speed up the coding
  • Templates can be exported and imported

Apart from these advantages we can add our generic reusable code in to the templates…

Now this is where we can play with TestComplete

Based on the project implementation we may need to repeat same set of code across different script units and modules.

Best example is exception handling,
We need to handle the exception +
We may log the error details in the log file +
We may take the screen shot of the exception/error

The simplest way to handle this scenario is write once in any of the function and copy + paste wherever is needed.

Alternatively when you use Code Template of TestComplete, you can be more innovative and productive.

Steps to follow :

  1. Open the Code Template by selecting Tools -> Option -> Panels folder -> Code Templates
  2. In the right panel, select the language from the drop down you want to add the templates
  3. Now you can see the default templates in the listview for the selected languages
  4. Click Add which will add new entry in listview
  5. Give “Name” and “Description” for the template for the new entry in the listview
  6. In the text area below the listview enter your code
  7. Click “ok” to save the template

Finished !!! You have just now added your own template…

While coding, just enter CTRL + J to get the list of templates available and select your template to be populated inside the code editor.

Points to be noted :

  • The pop-up list of templates on pressing CTRL+J will be based on your language selection in the project. So be careful under which language you are adding the template.
  • Make sure the template is generic so that you can use it globally.
  • Make sure the template is error free though you can modify or delete at later point of time.

Hope there is 101 ways to automate…

Thanks & Regards,
Giri Prasad

TestComplete in 64-bit Machine


Objective :

My aim is to find whether a particular software is installed in the system…

Implementation :

I have a Windows XP machine and my initial code written in TestComplete is able to identify the software by traversing the registry key values.

Then a new scenario arises where I need to run the same function in different environment(Windows Server 2008 box)

Now as you guessed my script fails… 😦

As usual tried with many workaround(WMI, Accessing Control panel-Add or Remove programs) . But no help…

At last extracted the function out of TestComplete and ran it under WindowsScriptHost in the Server 2008.

Surprise !!! It ran and fetched the software details

At this point of time, if anyone guessed what will be the root cause – Congrats ; Others, please follow the post 🙂

My Question is why the script is able to fetch the result in WSH and not from TestComplete ?

I have taken to the AutomatedQA forum and got reply as – “TestComplete and Windows Script Host refer different branches of registry tree in Windows 2008 server“.

In 64-bit machines by default TestComplete refers 32-bit registry and WindowsScriptHost refer 64-bit registry.

The 64-bit machines has two locations for Uninstall branch,
(64-bit registry) :HKLM\Software\Microsoft\Windows\CurrentVersion\Uninstall\
(32-bit registry) :HKLM\Software\Wow6432Node\Microsoft\Windows\CurrentVersion\Uninstall\

To work with the same registry version, we need to use the “Storages.Registry” object in TestComplete that can work with both registry versions.

But Storages object in will not be supported inside “ScriptExtension” in TestComplete 7.2.

So universal solution to this problem is using “WBEM Scripting approach”

Want to explore more ? Follow the link :- http://david.gardiner.net.au/2007/03/listing-installed-applications-on-vista.html

There is always a saying : Stopping three feet from Gold

If you are tired looking for a solution to your problem, just think you are three feet from GOLD.

You will start again and definitely find the solution. 🙂

Hope there are 101 ways to Automate…

Regards,Giri Prasad