Checkpoints is one of the most important of the many features QTP has in it. Among the many well known checkpoints we have one lesser known and less frequently used checkpoint called Accessibility checkpoint. It is one of the most sought after query in any Automation testing interview rounds during QTP technical questions. In very broad sense we can conclude that accessibility checkpoint is nothing but a 508 standard compliance of any website in terms of its standardization usage of various tags. However let us explore in details as to what this 508 compliance refers to.

HTML 508 Compliance :
(a)A text equivalent for every non-text element shall be provided (e.g., via "alt", "longdesc", or in element content).(b)Equivalent alternatives for any multimedia presentation shall be synchronized with the presentation.

(c) Web pages shall be designed so that all information conveyed with color is also available without color, for example from context or markup.d) Documents shall be organized so they are readable without requiring an associated style sheet.

e) Redundant text links shall be provided for each active region of a server-side image map.

f)Client-side image maps shall be provided instead of server-side image maps except where the regions cannot be defined with an available geometric shape.

g) Row and column headers shall be identified for data tables.

h) Markup shall be used to associate data cells and header cells for data tables that have two or more logical levels of row or column headers.

i) Frames shall be titled with text that facilitates frame identification and navigation.

j)Pages shall be designed to avoid causing the screen to flicker with a frequency greater than 2 Hz and lower than 55 Hz.

k) A text-only page, with equivalent information or functionality, shall be provided to make a web site comply with the provisions of this part, when compliance cannot be accomplished in any other way. The content of the text-only page shall be updated whenever the primary page changes.

l)When pages utilize scripting languages to display content, or to create interface elements, the information provided by the script shall be identified with functional text that can be read by assistive technology.

m)When a web page requires that an applet, plug-in or other application be present on the client system to interpret page content, the page must provide a link to a plug-in or applet that complies with §1194.21(a) through (l).

n)When electronic forms are designed to be completed on-line, the form shall allow people using assistive technology to access the information, field elements, and functionality required for completion and submission of the form, including all directions and cues.

p) When a timed response is required, the user shall be alerted and given sufficient time to indicate more time is required.

q) When software is designed to run on a system that has a keyboard, product functions shall be executable from a keyboard where the function itself or the result of performing a function can be discerned textually.

r)Applications shall not disrupt or disable activated features of other products that are identified as accessibility features, where those features are developed and documented according to industry standards. Applications also shall not disrupt or disable activated features of any operating system that are identified as accessibility features where the application programming interface for those accessibility features has been documented by the manufacturer of the operating system and is available to the product developer.

(s)A well-defined on-screen indication of the current focus shall be provided that moves among interactive interface elements as the input focus changes. The focus shall be programmatically exposed so that assistive technology can track focus and focus changes.

(t)Sufficient information about a user interface element including the identity, operation and state of the element shall be available to assistive technology. When an image represents a program element, the information conveyed by the image must also be available in text.

(u)When bitmap images are used to identify controls, status indicators, or other programmatic elements, the meaning assigned to those images shall be consistent throughout an application's performance.

(v)Textual information shall be provided through operating system functions for displaying text. The minimum information that shall be made available is text content, text input caret location, and text attributes.

(x)When animation is displayed, the information shall be displayable in at least one non-animated presentation mode at the option of the user.

(y)Color coding shall not be used as the only means of conveying information, indicating an action, prompting a response, or distinguishing a visual element.

(z)When a product permits a user to adjust color and contrast settings, a variety of color selections capable of producing a range of contrast levels shall be provided.

a)Software shall not use flashing or blinking text, objects, or other elements having a flash or blink frequency greater than 2 Hz and lower than 55 Hz.( b)When electronic forms are used, the form shall allow people using assistive technology to access the information, field elements, and functionality required for completion and submission of the form, including all directions and cues.

Automation testing using QTP has always been talked upon the most in the testing industry. There are numerous features available within this very toolset, but most of us might not be aware of this very feature whioch has been discussed in this very articles on automation testing using QTP which is Blockinput feature.

These two methods of the SystemUtil class is genuinely used to block the user from entering data through keyboard while the script is in execution mode.
Genuinely for security concerns this utility method is utilised at the best level.

Automation
testing using QTP has always been talked upon the most in the testing
industry. There are numerous features available within this very
toolset, but most of us might not be aware of this very feature which
has been discussed in this very articles on automation testing using QTP
which is functions created in Vbscript , and is very useful in code customization to meet our automation testing requirements , as it reduces the script maintenance effort..

1) How to add a constant number in a datatable?
This is more to do with MS excel then QTP!! but useful to know because at times it becomes frustrating to the novices.
Just append ' to the number, this trick somehow is related to the simple concept applied in excel, however that we can deal separately.
Ex: if you wish to enter 1234567 in datatable then write it as '1234567
2) How can i check if a parameter exists in DataTable or not?
The best way would be to use the below code:
on error resume next
val=DataTable("ParamName",

dtGlobalSheet)
if err.number<> 0 then
'Parameter does not exist
else
'Parameter exists
end if

3) Does QuickTest Professional support Internet Explorer 7.0?
QuickTest Professional 9.1
QuickTest Professional 9.1 supports Microsoft Internet Explorer 7.0 Beta 3. Internet Explorer version 7.0 is now certified to work and to be tested with QuickTest Professional version 9.1.
QuickTest Professional 9.0
QuickTest Professional 9.0 supports Internet Explorer 7.0 Beta 2.
QuickTest Professional 8.2 and below
QuickTest Professional 8.2 and below do not include support for Internet Explorer 7.0.
Does QuickTest Professional support Firefox?
QuickTest Professional 9.1 and 9.2
QuickTest Professional 9.1 provides replay support for Mozilla Firefox 1.5 and Mozilla Firefox 2.0 Alpha 3 (Alpha-level support for Bon Echo 2.0a3).
Notes:
QuickTest Professional 9.1 will not record on FireFox. You can record a test on Microsoft Internet Explorer and run it on any other supported browser, such as FireFox.
The .Object property for web objects is not supported in FireFox.
QuickTest Professional 9.0
QuickTest Professional 9.0 provides replay support for Mozilla FireFox 1.5.
Notes:
QuickTest Professional 9.0 will not record on FireFox. You can record a test on Microsoft Internet Explorer and run it on any other supported browser, such as FireFox.
The .Object property for web objects is not supported in FireFox.
QuickTest Professional 8.2 and below
QuickTest Professional 8.2 and below do not have support for Firefox.

4) What is the lservrc file in QTP?
The lservrc file contains the license codes that have been installed
The lservrc file contains the license codes that have been installed. Whenever a new license is created, the license code is automatically added to this file. The lservrc file is a text file, with no extension.
File Location:
1) For a Concurrent (Floating) license installation:

Debug Run
1. Step Into
Choose Debug > Step Into, click the Step Into button, or press F11 to run only the current line of the active test or component. If the current line of the active test or component calls another action or a function, the called action/function is displayed in the QuickTest window, and the test or component pauses at the first line of the called action/function.
2. Step Out
Choose Debug > Step Out or click the Step Out button, or press SHIFT+F11 only after using Step Into to enter a action or a user-defined function. Step Out runs to the end of the called action or user-defined function, then returns to the calling action and pauses the run session.
3. Step Over
Choose Debug > Step Over or click the Step Over button, or press F10 to run only the current step in the active test or component. When the current step calls another action or a user-defined function, the called action or function is executed in its entirety, but the called action script is not displayed in the QuickTest window.
'Example of How to use functions.

' The function returns the value of a single item of an executed query.
' Note that a db_execute_query for (arg1) must called before this function
' curRecordSet - variable , contain record set , that contain all values that retrieved from DB by query execution
' rowIndex - the row index number (zero based)
' colIndex - the column index number (zero based) or the column name.
' returned values
' -1 - requested field index more than exists in record set
Function db_get_field_value( curRecordSet , rowIndex , colIndex )
dim curRow
curRecordSet.MoveFirst
count_fields = curRecordSet.fields.count-1
If ( TypeName(colIndex)<> "String" ) and ( count_fields < colIndex ) then
db_get_field_value = -1 'requested field index more than exists in recordset
Else
curRecordSet.Move rowIndex
db_get_field_value = curRecordSet.fields(colIndex).Value
End If
End Function

' db_set_field_value

' The function changes the value of a field according to a search criteria.
' We search for a certain row according to a column name and the desired vale, then we change a value in that row according
' to a desired columns
' curConnection - the session name (string)
' tableName - name of the table , where value should be retrieved
' colFind - the column we search the criteria in
' colFindValue - the value we search in the column
' colChange - the column were we want to change the value
' colChangeValue - the new value ' returned values

' curConnection - variable , contains a recordset , that contains all the values to be retrieved from DB by query execution
' tableName - name of the table , where value should be retrieved from
' values - array that contains values to be entered in a new row to the table.
' Note: the function must receive values for all the columns in the table!
' returned values
' -1 - the number of values to be entered to the table doesn't fit the number of columns
' 1 - execution of the query succeed and the data was entered to the table
Function db_add_row(curConnection, tableName , byRef values)
dim i
dim updateSQL
dim myrs1
updateSQL = "INSERT INTO " & tableName & " VALUES ("
arrLen = UBound (values) - LBound (values) + 1
set myrs1=db_execute_query( curConnection , SQL )
myrs1.MoveFirst
count_fields = myrs1.fields.count
' check if numbers of values fit the numbers of columns
If arrLen <> count_fields then
db_add_row = -1
Else
For i = 0 to arrLen-1
updateSQL = updateSQL & values (i)
If i <> arrLen-1 then
updateSQL = updateSQL & ","
End If
Next
updateSQL = updateSQL & ")"
set myrs1 = db_execute_query( curConnection , updateSQL )
db_add_row = 1
End If
End Function

Automation testing using QTP has always been talked upon the most in the testing industry. There are numerous features available within this very toolset, but most of us might not be aware of this very feature which has been discussed in this very articles on automation testing using QTP which is functions created in Vbscript , and is very useful in code customization to meet our automation testing requirements , as it reduces the script maintenance effort.

1. Can I change the Active Screen which is shown on every new test?

You can change the Active Screen to any valid HTML page. The page can be located either locally or on the network.

For example, if you want your entire organization to view the same Active Screen when opening QuickTest Professional, open the NewTest.inf file located in QuickTest Professional\dat\SnapShots folder and add the following line:

FileName1= "any full path to an HTML file"

For example:
FileName1=\mercury\public\MainPage.html

2. How do I create an action template?

If you want to include one or more statements in every new action in your test, you can create an action template. For example, if you always enter your name as the author of an action, you can add this comment line to your action template. An action template applies only to actions created on your computer.

To create an action template, create a text file containing the comments, function calls, and other statements that you want to include in your action template. The text file must be in the structure and format used in the Expert View.

Save the text file as ActionTemplate.mst in your QuickTest Professional\dat folder. All new actions you create contain the script lines from the action template.

3. How can I configure the report to show only errors by default?

You can configure the report to show only errors by default by adding the following section to the QTReport.ini file in your QuickTest Professional\bin folder.

[FilterDialog]

ReportAppDefaultFilter=1 # for error only

ReportAppDefaultFilter=3 # shows all messages (default)

4. How do I use environment variables?

QuickTest supports using environment variables. Environment variables can be either system variables or user-defined variables.

You can define the user-defined variables in an external file QuickTest reads when it is launched.

5. I have a Microsoft Access database that contains data I would like to use in my test. How do I do this?

The Expert View enables you to access databases using ADO and ODBC. Below is a sample test that searches for books written by an author in the "Authors" table of the database.

A manual wait (think time) can be added to a QuickTest Professional test using the following command:

Call Wait()

7. How do I make the test prompt the user for input while it is running?

The VBScript InputBox function enables you to display a dialog box that prompts the user for input and then continues running the test. You can use the value that was entered by the user later in the test. For more information on the InputBox function, refer to the VBScript Reference.

The following example shows the InputBox function used to prompt the user for a password.

You can configure the report to show only errors by default by adding the following section to the QTReport.ini file in your QuickTest Professional\bin folder.

[FilterDialog]

ReportAppDefaultFilter=1 # for error only

ReportAppDefaultFilter=3 # shows all messages (default)

9. How can I remove test result files from old tests?

You can use the Test Results Deletion Tool to view a list of all the test results in a specific location in your file system or in a Quality Center project. You can then delete any test results that you no longer require.

The Test Results Deletion Tool enables you to sort the test results by name, date, size, and so forth, so that you can easily identify the results you want to delete.

If TimeOut is 0, it behaves just like a normal message box. If TimeOut is greater than 0, the dialog box disappears after the specified number of seconds.

17. Using Microsoft Word Spell Check

The following code shows a function for checking the number of spelling and grammar errors in a string. This function is also used to check the accuracy of a specific property in all the objects of a given application.

'''''''''''''''''''''''''''''''''''''
' An example of usage:
' Go over all the static objects in the Login window of the Flight Application
' and for each object check the text for spelling and grammatical errors
'''''''''''''''''''''''''''''''''''''

' Go over all the links in the page and report all the ones that fail the spellcheck
Set Desc = Description.Create()
Desc("nativeclass").Value = "Static"
Set Obj = Dialog("nativeclass:=#32770", "text:=Login")
' Invoke the Flight Application before calling the function
CheckAllObjects Obj, Desc, "text"

18. Using Microsoft Outlook to Send Email

The code below illustrates two methods for sending email using the VBScript code in QuickTest Professional, and two different COM objects.

Automation testing using QTP has always been talked upon the most in the testing industry. There are numerous features available within this very toolset, but most of us might not be aware of this very feature which has been discussed in this very articles on automation testing using QTP which is functions created in Vbscript , and is very useful in code customization to meet our automation testing requirements , as it reduces the script maintenance effort..

' If no browser open, open browser and navigate to required URL
If Not Browser("CreationTime:=0").Exist Then
Call launch(startURL)
Else

' Get the URL of the current open browser
currentURL=Browser("CreationTime:=0").GetROProperty("OpenURL")
' If not correct URL navigate to required URL
If Not currentURL = "www.google.com" Then
Call launch(startURL)
End If
End If

To enable special event handling, use the Web Event Recording Configuration utility.
1. Go to Tools -> Web Event Recording Configuration.
2. Click .
3. Expand the Standard Objects branch.
4. Select the object you want to configure.
5. Go to Event -> Add -> ondblclick. The event will be added to the list on the right.
6. Select "If Handler" in the Listen column.
7. Select "Enabled" in the Record column.
8. Click to close the dialogs.

1) Create Test parameters in QTP (via file>Settings>Parameters) [These are the parameters that you see in QC, on the automated tab of the Configuration page in the Test Instance Propertirs.]

2) Create action parameters (Action Properties> Parameters)

3)Link action & test parameters together. To do this, go into Action Call Properties>Parameters. You'll see your action parameters here. Click in the Value column for a parameter and press the Configure Value button. This will open up the Value Configuration Options dialogue. In the parameter drop down list, select Test/action parameter and then, from the following Test parameters; Parameter drop down list, select the Test parameter that you want to link to your Action parameter.

Automation testing using QTP has always been talked upon the most in the testing industry. There are numerous features available within this very toolset, but most of us might not be aware of this very feature which has been discussed in this very articles on automation testing using QTP which is functions created in Vbscript , and is very useful in code customization to meet our automation testing requirements , as it reduces the script maintenance effort.

1. Getting Number from String

Function extract_number(msg)
Dim re, matches, item, result
Set re = New RegExp
re.pattern = "[A-Za-z -.]*(\d+).*"
Set matches = re.Execute(msg)
If matches.Count > 0 Then
Set item = matches(0)
If item.SubMatches.Count > 0 Then
result = item.SubMatches(0)
Else
result = -1
End If
Else
result = -1
End If
extract_number = resultEnd Function

Public Function dtGetColCount (sSheetName)
On Error Resume Next
Do
i = i + 1
sColName = DataTable.GetSheet(sSheetName).GetParameter(i).Name
Loop While 0 = Err.Number
'GetParameter throws an error when using an index that is out of bounds ...
'We can use this functionality to ASSUME that it's an unused column.
'We've come to the end of our USED columns
dtGetColCount = i - 1
On Error GoTo 0End Function

Automation testing using QTP has always been talked upon the most in the testing industry. There are numerous features available within this very toolset, but most of us might not be aware of this very feature which has been discussed in this very articles on automation testing using QTP which is functions created in Vbscript , and is very useful in code customization to meet our automation testing requirements , as it reduces the script maintenance effort.

1. Action Template

If you need any default Template to be loaded whenever you create a new Action, just follow these steps.

Design the template with all the statements and comments in a text file.

Save the text file as "ActionTemplate.mst" to the "QuickTest Installation Folder" under \dat folder.

Start QTP and whenever you create new Actions, you can find the template by default.

File system handling using Vbscript in QTP is another example of AOM model that is utilized to suit our needs to write logs especially to generate the customized result files. Scripting.Filesystem object is the claas which is utilized to cater to the needs of the object creation and hence its property access.

How to Create a new text file ?

How to Check if a specific file exist ?

How to write data to a file ?

How to Read line from file ?

How to Read Entire Text file ?

How to Close an open file ?

How to Open a specified file and returns an object that can be used to read from, write to, or append to the file ?

Excel handling using QTP is one of the most required utility that any QTP programmer need to be expert at . In the next few sections we shall be handling several excel handling codes that one can re-utilize as per his/her needs:

How to Create a new Excel Object with a default new Workbook ?

How to Close a open Excel Object ?

How to save a workbook according to the workbookIdentifier?

How to set the given 'value' in the cell ?

How to returns the cell's value according to its row column and sheet ?

How to get returned an Excel Sheet according to the sheetIdentifier ?

How to insert a new worksheet into the active workbook ?

How to renames a worksheet's name ?

How to remove a worksheet from a workbook ?

How to create a new workbook in the excel application ?

How to open a previously saved Excel workbook and add it to the Application ?

How to set one of the workbooks in the application as Active workbook ?

'The SaveWorkbook method will save a workbook according to the workbookIdentifier

'The method will overwrite the previously saved file under the given path
'objExcelApp - a reference to the Excel Application
'workbookIdentifier - The name or number of the requested workbook
'path - the location to which the workbook should be saved
'Return "OK" on success and "Bad Workbook Identifier" on failure
Function SaveWorkbook(ObjExcelApp, workbookIdentifier, path) 'As String
Dim workbook 'As Excel.workbook
On Error Resume Next
Set workbook = ObjExcelApp.Workbooks(workbookIdentifier)
On Error GoTo 0
If Not workbook Is Nothing Then
If path = "" Or path = workbook.FullName Or path = workbook.Name Then
workbook.Save
Else
Set objFso = CreateObject("Scripting.FileSystemObject")
'if the path has no file extension then add the 'xls' extension
If InStr(path, ".") = 0 Then
path = path & ".xls"
End If
On Error Resume Next
objFso.DeleteFile path
Set objFso = Nothing
Err = 0
On Error GoTo 0
workbook.SaveAs path
End If
SaveWorkbook = "OK"
Else
SaveWorkbook = "Bad Workbook Identifier"
End IfEnd Function

'The SetCellValue method sets the given 'value' in the cell which is identified by

'its row column and parent Excel sheet
'objExcelSheet - the excel sheet that is the parent of the requested cell
'row - the cell's row in the objExcelSheet
'column - the cell's column in the objExcelSheet
'value - the value to be set in the cell
Sub SetCellValue(objExcelSheet, row, column, value)
On Error Resume Next
objExcelSheet.Cells(row, column) = value
On Error GoTo 0End Sub

'The GetCellValue returns the cell's value according to its row column and sheet

'The GetSheet method returns an Excel Sheet according to the sheetIdentifier

'ObjExcelApp - the Excel application which is the parent of the requested sheet
'sheetIdentifier - the name or the number of the requested Excel sheet
'return Nothing on failure
Function GetSheet(ObjExcelApp, sheetIdentifier) 'As Excel.worksheet
On Error Resume Next
Set GetSheet = ObjExcelApp.Worksheets.Item(sheetIdentifier)
On Error GoTo 0End Function

'The InsertNewWorksheet method inserts an new worksheet into the active workbook or

'the workbook identified by the workbookIdentifier, the new worksheet will get a default
'name if the sheetName parameter is empty, otherwise the sheet will have the sheetName
'as a name.
'Return - the new sheet as an Object
'ObjExcelApp - the excel application object into which the new worksheet should be added
'workbookIdentifier - an optional identifier of the worksheet into which the new worksheet should be added
'sheetName - the optional name of the new worksheet.
Function InsertNewWorksheet(ObjExcelApp, workbookIdentifier, sheetName) 'As Excel.worksheet
Dim workbook 'As Excel.workbook
Dim worksheet 'As Excel.worksheet
'In case that the workbookIdentifier is empty we will work on the active workbook
If workbookIdentifier = "" Then
Set workbook = ObjExcelApp.ActiveWorkbook
Else
On Error Resume Next
Err = 0
Set workbook = ObjExcelApp.Workbooks(workbookIdentifier)
If Err <> 0 Then
Set InsertNewWorksheet = Nothing
Err = 0
Exit Function
End If
On Error GoTo 0
End If
sheetCount = workbook.Sheets.Count
workbook.Sheets.Add , sheetCount
Set worksheet = workbook.Sheets(sheetCount + 1)
'In case that the sheetName is not empty set the new sheet's name to sheetName
If sheetName <> "" Then
worksheet.Name = sheetName
End If
Set InsertNewWorksheet = worksheetEnd Function

'The CreateNewWorkbook method creates a new workbook in the excel application

'ObjExcelApp - the Excel application to which an new Excel workbook will be addedFunction CreateNewWorkbook(ObjExcelApp)
Set NewWorkbook = ObjExcelApp.Workbooks.Add()
Set CreateNewWorkbook = NewWorkbookEnd Function

'The OpenWorkbook method opens a previously saved Excel workbook and adds it to the Application

'objExcelApp - the Excel Application the workbook will be added to
'path - the path of the workbook that will be opened
'return Nothing on failure
Function OpenWorkbook(ObjExcelApp, path)
On Error Resume Next
Set NewWorkbook = ObjExcelApp.Workbooks.Open(path)
Set OpenWorkbook = NewWorkbook
On Error GoTo 0End Function

'The ActivateWorkbook method sets one of the workbooks in the application as Active workbook

'ObjExcelApp - the workbook's parent excel Application
'workbookIdentifier - the name or the number of the workbookSub ActivateWorkbook(ObjExcelApp, workbookIdentifier)
On Error Resume Next
ObjExcelApp.Workbooks(workbookIdentifier).Activate
On Error GoTo 0End Sub

'The CloseWorkbook method closes an open workbook

'ObjExcelApp - the parent Excel application of the workbook
'workbookIdentifier - the name or the number of the workbookSub CloseWorkbook(ObjExcelApp, workbookIdentifier) On Error Resume Next
ObjExcelApp.Workbooks(workbookIdentifier).Close
On Error GoTo 0End Sub

'The CompareSheets method compares between two sheets.

'if there is a difference between the two sheets then the value in the second sheet
'will be changed to red and contain the string:
'"Compare conflict - Value was 'Value2', Expected value is 'value2'"
'sheet1, sheet2 - the excel sheets to be compared
'startColumn - the column to start comparing in the two sheets
'numberOfColumns - the number of columns to be compared
'startRow - the row to start comparing in the two sheets
'numberOfRows - the number of rows to be comparedFunction CompareSheets(sheet1, sheet2, startColumn, numberOfColumns, startRow, numberOfRows, trimed) 'As Boolean
Dim returnVal 'As Boolean
returnVal = True
'In case that one of the sheets doesn't exists, don't continue the process
If sheet1 Is Nothing Or sheet2 Is Nothing Then
CompareSheets = False
Exit Function
End If
'loop through the table and fill values into the two worksheets
For r = startRow to (startRow + (numberOfRows - 1))
For c = startColumn to (startColumn + (numberOfColumns - 1))
Value1 = sheet1.Cells(r, c)
Value2 = sheet2.Cells(r, c)
'if 'trimed' equels True then used would like to ignore blank spaces
If trimed Then
Value1 = Trim(Value1)
Value2 = Trim(Value2)
End If
'in case that the values of a cell are not equel in the two worksheets
'create an indicator that the values are not equel and set return value
'to False
If Value1 <> Value2 Then
Dim cell 'As Excel.Range
sheet2.Cells(r, c) = "Compare conflict - Value was '" & Value2 & "', Expected value is '" & Value1 & "'."
Set cell = sheet2.Cells(r, c)
cell.Font.Color = vbRed
returnVal = False
End If
Next
Next
CompareSheets = returnValEnd Function