Showing posts with label HP QTP Tutorials. Show all posts
Showing posts with label HP QTP Tutorials. Show all posts

HP Quick Test Professional Shortcut Keys to success

Please find the some of the QTP Short cut keys to success in Automation Frameworks creation.



New - Test CTRL + N
New - Business Component CTRL + SHIFT + N
New - Scripted Component ALT + SHIFT + N
New - Application Area CTRL +Alt + N
Open - Test CTRL + O
Open - Business Component CTRL + SHIFT + O
Record - F3
Run - F5
Stop - F4
Analog Recording - CTRL + SHIFT + F4
Low Level Recording - CTRL + SHIFT + F3
Open - Application Area - CTRL + ALT + O
Object Properties  -CTRL + ENTER
Value Configuration Options  - CTRL + F11 input value
Save - CTRL + S
Export Test to Zip File - CTRL + ALT +S
Output Options - CTRL + F11 output value
Import Test from Zip File - CTRL + ALT + I
Print - CTRL + P
Pause  - PAUSE
Cut - CTRL + X
Copy - CTRL + C
Paste - CTRL + V
Delete - DEL
Step Into - F11
Step Over - F10
Step Out - SHIFT + F11
Insert/Remove Breakpoint F9
Undo CTRL + Z
Clear All Breakpoints CTRL + SHIFT + F9
Redo CTRL + Y (EV only)
Edit - Cut CTRL + X
Rename Action F2
Edit - Copy CTRL + C
Find CTRL + F
Edit - Paste CTRL + V
Replace CTRL + H
Edit - Clear - Contents CTRL + DEL
Go To CTRL + G
Bookmarks CTRL + B
Complete Word CTRL + Space
Argument Info CTRL + SHIFT + SPACE
Apply With To Script CTRL + W
Remove “With” Statements CTRL + SHIFT + W
Edit - Insert CTRL + I
Edit - Delete CTRL + K
Edit - Fill Right CTRL + R
Edit - Fill Down CTRL + D
Edit - Find CTRL + F
Edit - Replace CTRL + H
Checkpoint - Standard F12
Data - Recalc F9
Insert Multi-line Value CTRL + F2 editing cell
Output Value - Standard Output CTRL + F12
Value Activate next/previous sheet CTRL + PAGEUP/ CTRL + PAGEDOWN
Step Generator F7
View Keyword View/Expert View CTRL + TAB
New Step F8
New Step After Block SHIFT + F8
Open context menu SHIFT + F10

How to use vb script for QTP

VBSCRIPT

VB Script is used for HP QTP scripting in order to create Test Scripts.VB Script is a Microsoft language where using for .Net development for Web applications. VB Script is a light weight language ,easy to understand,easy to learn and very easy to prepare QTP Test scripts for QTP framework.



Purpose of VB Script in QTP

1.VB Script coding used in hp QTP Test scripting.
2.VB Script is a Microsoft language.
3.Licensed by a many companies and using for programming Language.

VB Script Data Types

VB Script has only one Data type i.e Variant which is used in vb script.Variant is a type of data type that having different information.Variant used as a Null pointer,Boolean,Byte,Storage purpose..etc
Variable is used as a Array type to store information.We can store different type of data into this variable.Vb Script variable should not exceed 255 characters and must be unique.

Variables

VB Script has different variable to declare values or assigned types using Dim,Public,Private statements.
Dim - Used for all functions with in the script like global declarations
Public - Used for all functions or procedures for all the scripts
Private - Used for only for which scripts it has declared.

Ex: 
'Global Variable Declarations
Dim k,l,m
'Assign value to K
K = Inputype("Please Enter k value")
'Assign value to l
l= InputType("Please Enter l value")
'Addition of two integers
m=l+k
'Display Addition value m
MsgBox(m)

Option Explicit is also a variable to declare variables,if Option Explicit used you should declare variables in Test scripts for all the variables.If used Option Explicit it will provide details if variables are not declare under Dim or Public or Private  statements.

VB Script Arrays

Array is a type of storage container which is used to store  the particular fixed size of  values of a single type.The length for array is established at the time of array is created.Array is starts with number 0 for example below

Ex: 
a[3] means 
a[0],a[1],a[2],a[3]
a[0] = 1
a[1]= 2
a[2] = 3
a[3] = 4

Two Types of Arrays

1.Static Array
2.Dynamic Array

Static Array:
In this Static Array we can mention size of the array while declaring the array.For Example

Dim Value[3]
Value[0] = 1
Value[1] = 2
Value[2] = 3
Value[3] = 4


Dynamic Array

In this type of Array we can change the array size at the type of Test script and we can resize the array size in Dynamic Array.

Ex: Dim a()

Suppose if we want to resize the specified array we can use ReDim statement to resize the dynamic array size.

ReDim a(5) 

HP QTP Data Table Methods

HP Quick Test Professional Data Table Methods


They are number of QTP Data Table methods to create Data Driven Framework ,below are the details.

1. Add Sheet
2. Delete Sheet
3. GetSheetCount
4. GetRowCount
5. GetSheet
6. Value
7. SetCurretRow
8. SetNextRow
9. SetPrevRow
10.Import /Import Sheet
11.Export /Export Sheet



Please find the details below

Add Sheet:

This method is used add new sheet to the run time data table
Syntax: DataTable.AddSheet("Sheet Name")

Delete:

This method is used to Delete one sheet using this method
Syntax: DataTable.DeleteSheet("Sheet Name")
Example : DataTable.DeleteSheet("Test_Cases")

GetSheetCount:

This method is used to Count number of sheets in Run time Data Table.
Syntax: DataTable.GetSheetCount

GetRowCount:

This method is used to count number of rows in the first excel sheet of the run time data table.
Syntax: DataTable.GetRowCount

GetSheet:

This method is used to get specified excel sheet from run time data table.
Syntax: DataTable.GetSheet("Sheet Name") or DataTable.GetSheet("SheetID")

Example : 
Sheet 1- 1
Sheet 2 - 2

DataTable.GetSheet(1)

Value:

This method is used to set or get value of cell data in specified the current row of the run time data table.
To Get Data
Syntax:

Variable Name = DataTable.Value(Parameter_Name,Sheet Name) or

Variable Name = DataTable(Parameter_Name,Sheet Name)

To Set Data
Syntax: DataTable.Value(Parameter Name,SheetName) = Value/Variable

DataTable(ParameterName,SheetName) = Value/Variable

Ex:
Uname = DataTable.Value("Username","rajeshk")
Pwd = DataTable.Value("Password","xxxxxxxxxx")

Browser("Gmail Login").Page("Gmail Login").WebEdit("Username").Set Uname
Browser("Gmail Login").Page("Gmail Login").WebEdit("Password").Set Pwd

SetCurrentRow:

This method is used to set specified row as current row in the run time data table.
Syntax: DataTable.SetCurrentRow(RowNumber)
Ex: Username = "Rajesh"
DataTable.SetCurrentRow(3)
DataTable.Value(3) = Username

SetNextRow:

This method is used to set the row after the current row as New Row in the Run time DataTable.
Syntax: DataTable.SetNextRow

SetPrevRow:

This method is used to set specified row as before the current row as new current row in Run time data table.
Syntax: DataTable.SetPrevRow

Import:

This method is used to import Excel file -Number of sheets to the run time Data table.
Syntax: DataTable.Import "Path of the Excel file"
DataTable.Import "E:\Automation\HP QTP\Testing.xls"

ImportSheet

This method is used to import specified excel sheet into Run time data table.
Syntax: DataTable.ImportSheet "Path of Excel file","Source Sheet","Destination Sheet"

Example:
DataTable.AddSheet "Test_Cases_App"

DataTable.ImportSheet "E:\Automation\HP QTP\Testing.xls","Test_Cases","Test_Cases_App"

Export:

This method is used Export Excel file in to specified location from another location
Syntax: DataTable.Export "Path of Excel file"

Export Sheet:

This method is used to export specified sheet into specified location
Syntax: DataTable.ExportSheet "Path of File","Sheet Name/Source Sheet"

DataTable.ExportSheet "E:\Automation\HP QTP","AutomationTesting.xls"