Thursday, July 26, 2012

Inserting Excel formula into QTP Datatable

As we know we can write formula's using vb script directly in to excel, but here I am trying to insert excel formula's in datatable. Usually we use datatable to ease our scripting but inserting excel formula's will throw error on exporing the datatable, Let us consider the following script

datatable.Value("A",2) = "2"
datatable.SetCurrentRow(2)
datatable.Value("A",2) = "3"
datatable.SetCurrentRow(3)
datatable.Value("A",2) = "=(A2+A3)"
datatable.SetCurrentRow(4)
datatable.Value("A",2) = "=HYPERLINK(""C:\Documents and Settings\1419084\My Documents\IP_Config.bmp""|""Click to see Image"")"
datatable.ExportSheet "C:\Documents and Settings\1419084\Desktop\FI_Overview\2.xls","Action1"


In above script I'm trying to insert two formula's one is addition and other is hyperlink. While running the script throws following error on datatable export.

Though the formula is captured on datatable but it's throwing error, after stopping the run we can able to see the datatable with formula in results. Despite it throws general error while exporting the datatable.
Here I'm inserting single quote(') before the formula to handle this problem, after executing the test open the Excel and remove the single quote(') using format painter to recover the formula. This method reduced a lot of time for me while capturing screen shots.


Wednesday, July 18, 2012

QTP Repository for easy understanding


QTP Repository is used to store objects that can be reference Testing Applications during Automation test runs.





Property of the objects can be predefined in QTP as follows
1. Mandatory Property
2. Assistive Property
3. Ordinal Identifier

Mandatory Property
QTP priorities mandatory properties defined in the Object Identification section for particular object.
Refer Images above and below where these below properties highlighted in mandatory section.
  Html tag, name and type

Assistive Property
QTP uses Assistive property when mandatory property of the object matches more than one object being saved in OR.
Refer the below Image for better understanding. In Webpage Cache link appears more than a time so QTP refers for Assistive property.


  
 
Ordinal Identifier
QTP refers Ordinal when the above mentioned properties are not sufficient to identify the object being saved in OR. Here we can specify object Index, Location and Creation Time as property.