Come let us explore together…

Posts tagged ‘Script Extension’

Data handling support in TestComplete – Part 3


Using Data Storages:

When I say “Data storages” here, it’s the data sources like Excel, CSV, ADO table or simple text files which lie outside Test complete. Yes. We can have our data (test data/ expected data) independent of our Test complete projects. Also Test Complete supports good interfaces to get/set these data stored else where in the system.

Mostly when we need to build a robust Test automation framework or asking for a data driven approach, the answer might be just separate the data and the code (scripts) which uses it.

Few advantages when choosing this approach are:

  1. Dependability is less which eases the development and upgrades.
  2. Since data is kept outside of any automation scripts/tools, even novice users who have minimum implementation knowledge can manipulate the data easily.
  3. Just pile up the data as new test cases are written for same implementation.

Test Complete provides DDT object which has methods and properties to connect to a data source, read data, assign back the results and iterate through the collection or rows and columns.

I have written a post https://automate101.wordpress.com/2010/07/27/data-driven-testing-with-testcomplete-part-2/ which explains the DDT object and sample scripts to fetch data from data sources.

a) Scope

Since these data sources lie outside TestComplete we can access them in from of the scripts and even across multiple projects. For example, single excel workbook can hold data in separate worksheets for different projects.

b) Easy Accessible:

The previously discussed (Project variables/Stores) data storage options require the help of Test Complete editor to view or edit the data stores in them. But this option doesn’t require Test Complete to be opened. Provides easy viewable options if excel or ADO table are used. Supports multiple connections to the data source and have manipulation of data inside scripts can be done with few statements

c) Adapting to changes

The scripts will be robust enough until we are modifying the schema of the data storages. Any point of time we can change the data source itself ie., data from excel sheets can be migrated to Ado tables with just minor changes in the driver scripts. Because the DDT object provides similar approach (methods and properties) for all the supported data storages.

Using Storages Object

Using “Storages” object we can manipulate data from special or complex storages like INI, XML, BINARY and REGISTRY files. As you know we cannot directly access these files like text files and require good methods for the same.

Our implementation may have requirements to store data using these file types. Also more complex, system/configuration related data or hierarchical data can only be stored in these types of files. If you are committed to use these data sources, Test Complete supports you with object called “Storages”. This is an add-on support and you need to make sure whether your tool has it. Just navigate to “File -> Install extension” dialog and verify where it is checked as shown below.

 

Storages add-on as extension in TestComplete

To use this feature in Test Complete, store the data in any of the formats like INI, XML, BINARY and REGISTRY and save the file. Inside the scripts use Storages object and its methods to manipulate data. Below you can find a sample JScript to read data from an INI file and displays them in test log.

function ReadINI()
{
 var objSection = Storages.INI("D:\\Employee.ini");
 Log.Message("Total Sections : " + objSection.SectionCount);
 var section;
 for(var idx=0; idx
 {
 section = objSection.GetSubSectionByIndex(idx);

 Log.Message("Section : " + section.Name + " has :-");

 for(var idy=0; idy
 {
 Log.Message("*** " + section.GetOptionName(idy) + " = " + section.GetOptionByIndex(idy));
 }
 }
}

Similarly using corresponding drivers we can use XML, Registry and Binary files.

a) Scope

Storages object cannot be used inside Script Extensions. Inside test complete you can access this object anywhere in the script. Also you can open the file, store them in “FileSection” object and pass as parameter to different functions.

b) Easy Accessible:

One advantage of using this object is we can manipulate complex and hierarchical file structures. Also the “FileSection” and “Section” objects gets the file similar to the physical view. For example the when we open a registry file, it returns as sections which in turn has options, thus enabling us to view the exact view of the file data.

c) Adapting to changes

The files can be stored independent of project. The Storages object uses similar kind of methods for all the 4 supported types. These two features helps us to change data and its corresponding code independent to each other.

Hope there are 101 ways to Automate !!!
Thanks & Regards,
Giri Prasad

What is new in TestComplete 8 ? – Part 2


DDT enhancements

Data Driven testing is well supported in this version of TestComplete. The enhancement ‘Data-Driven loop’ is mainly useful for Keyword-driven testing. Usually keyword-driven test can be done with minimum programming/coding knowledge. This ‘Data-Driven loop’ feature still makes it easier to implement without much of technical knowledge.

If your keyword-driven test has repeated actions and differ only with test data, then you can opt for this feature.

To turn the repeated code as a loop with different data, simply select the set of actions (test steps or sub-actions) which you want to turn in to loop and right-click to get the pop up menu. Select ‘Make Data Loop’ option to get the data source configuration wizard.

Selecting or creating data source, configuring how and which data to be read, binding with test steps and much more can be done through this wizard itself.

Based on the data source (Excel, CSV, DB table), the configuring and data selection process (wizard options) will differ. But this wizard will be very useful and can use with minimum programming knowledge.

The good part is after specifying the data source file; it will be visualized inside the wizard itself.

  • You can view the data in worksheets in case of Excel worksheet
  • Comma separated values in case of CSV.
  • Content of tables in case of DB tables

 

This wizard will reduce the typo errors, data source connection problems, test data range specification etc.,

Note: In the script based automation we can reap the above DDT advantages using its built-in drivers, methods and properties.

https://automate101.wordpress.com/2010/07/27/data-driven-testing-with-testcomplete-part-2/

Network suite enhancements

 

Networksuite has a good number of improvements in TestComplete 8. Among these I like automatic logging/Reboot on remote machines and visualizing the remote desktop screens.

Now you can write a script to login/reboot and remote machines which you treat as client and start test suites there.

Also the remote machines desktop screen can be viewed inside the network suite panel. This allows us to track the execution without manually log-in into those systems.

I have to really explore more on this feature because it is said that GUI tests run via the Remote Desktop do not fail if the Remote Desktop is minimized or closed during the test run. Need to know exact difference between TestComplete 7.52 and 8.

TestLog enhancements

 

If you have used test Visualizer while recoding the scripts, it will replay with synchronization to the recorded images while playing back.

We can view the actual image and expected images in the test log once the test were completed. These log items will show as an image comparison where we can analyze the image to find the root cause if it has the failure.

ImageComparion in Testlog
Comparison of Expected and Actual screen shot

 

Now the test logs can be exported as bugs to JIRA, OnTime and Software Planner. This feature minimizes the bug logging and tracking of it.

As we have methods and properties to access test log items using script, this version has new “LogItem.Status” property to determine its status of specified LogItem. These set of methods and properties will be useful when you want to parse the execution log and prepare/document the data that is interested for you.

Script Extension enhancements

1. The next version of WMI (1.1) scripts are added to Script Extensions to support most likely used functions. A total of 10 new functions were added in this version.
2. The bug reporting mechanism to JIRA, OnTime and Software Planner were implemented as script extensions

Still exception handling mechanism can be improved in Script Extension. Also more objects like Registry, Stores etc., can be given access inside script extensions.

Others

In the Toolbar -> options menu item, we can configure the TestComplete options.

• ‘Images’ and ‘When referring to an non-existence object’ items are moved from General list.

• ‘Debug Services’ option was removed

• New option “Java Bridge” is added to map the JVM (for supporting java classes)

• Under “Recording” option, the option to ‘Record text input into simple editors as’ will allow us to use “SetText” or “Keys” function. Also you can set to record only user action on TestedApps application and skip other actions.

• The option “Visualizer” is removed in this version.

• We can configure the sorting of categories displayed in object browser using the option Panels -> Object Browser -> Categories sorting

You can directly send error reports to AutomatedQA support using “Help -> Contact support team” menu option, which will open the new support form of TestComplete.

If you come across any differences/ enhancements in TestComplete 8, please share here…

 

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