Tuesday, 9 August 2011
Monday, 8 August 2011
How to get the vaues from combobox in QTP?
'Get the count of items from windows combo box
n=Window("Flight Reservation").WinComboBox("Fly From:").GetItemsCount()
For i=0 to n-1
datatable.SetCurrentRow (i)
'Get the items from the windows combobox
val =Window("Flight Reservation").WinComboBox("Fly From:").GetItem(i)
datatable("Flight",dtLocalsheet)=val
Next
datatable.ExportSheet "d:\sam.xls","Action1"
n=Window("Flight Reservation").WinComboBox("Fly From:").GetItemsCount()
For i=0 to n-1
datatable.SetCurrentRow (i)
'Get the items from the windows combobox
val =Window("Flight Reservation").WinComboBox("Fly From:").GetItem(i)
datatable("Flight",dtLocalsheet)=val
Next
datatable.ExportSheet "d:\sam.xls","Action1"
How to use Dynamic Descriptive program in QTP?
We can create objects by passing the property values dynamically to the function and create the objects so that the function can separate from the objects and used on any application
Set myDialog = Description.Create()
myDialog("Text").value = "Login"
mydialog("Enabled").value = "True"
Set Agent = Description.Create()
Agent("Attached text").value="Agent Name:"
Set password = Description.Create()
password("Attached text").value="Password:"
Set btnOK = Description.Create()
btnOK("Text").value = "OK"
call fnDialogLogin(myDialog,Agent,password,btnOk,"Test","mercury")
msgbox "Execution completed"
Function fnDialogLogin(objDialog,objUserid,objPassword,objLogin,strUserid,strPassword)
Dialog(objDialog).winEdit(objUserid).Set strUserid '"test"
Dialog(objDialog).winEdit(objPassword).Setsecure strPassword' "4e3bb8c872c2f2b9b5bdf31a221035f1747d7aac"
Dialog(objDialog).winButton(objLogin).Click
End Function
How to delete cookies in QTP?
Function fnRemoveCookies
uName=Environment.Value("UserName")
Dim oShell
Set oShell=CreateObject("WScript.shell")
oShell.run("cmd /C cd C:\Documents and Settings\" & uName & "\cookies & del *.txt")
Set oshell=nothing
End Function
uName=Environment.Value("UserName")
Dim oShell
Set oShell=CreateObject("WScript.shell")
oShell.run("cmd /C cd C:\Documents and Settings\" & uName & "\cookies & del *.txt")
Set oshell=nothing
End Function
how to create excel file and add sheets to it in QTP?
Set suitExcelobj= CreateObject("Excel.Application")
Set myFSO = CreateObject("Scripting.filesystemobject")
If myFSO.FileExists("C:\Testdata.xls") Then
msgbox "file found"
Set suitExcelWorkbook=suitExcelobj.Workbooks.Open("C:\Testdata.xls")
Else
msgbox "file not found"
Set suitExcelWorkbook=suitExcelobj.Workbooks.Add()
suitExcelWorkbook.saveas("C:\Testdata.xls")
End If
Set suitExcelWorkSheet=suitExcelWorkbook.Worksheets(1)
suitExcelWorkSheet.name="Scenario1"
suitExcelWorkbook.close()
set suitExcelWorkbook=nothing
Set suitExcelobj=nothing
Set myFSO = CreateObject("Scripting.filesystemobject")
If myFSO.FileExists("C:\Testdata.xls") Then
msgbox "file found"
Set suitExcelWorkbook=suitExcelobj.Workbooks.Open("C:\Testdata.xls")
Else
msgbox "file not found"
Set suitExcelWorkbook=suitExcelobj.Workbooks.Add()
suitExcelWorkbook.saveas("C:\Testdata.xls")
End If
Set suitExcelWorkSheet=suitExcelWorkbook.Worksheets(1)
suitExcelWorkSheet.name="Scenario1"
suitExcelWorkbook.close()
set suitExcelWorkbook=nothing
Set suitExcelobj=nothing
Wednesday, 6 July 2011
What are Virtual objects and how to work with them in QTP?
Virtual Objects:
Mapping unrecognized object to a standard object is called as Virtual object. This can be done as follows
Navigation:
Tools Menu -->Virtual Objects --> New Virtual Object -->Click Next -->Select Standard class to Map --> Click next -->Click on Mark Object -->Mark the object using cursor -->Click Next -->Click Next -->Enter Name of the Object and collection -->Click Finish
Enable Virtual Objects to recognize during recording:
Go to Tools Menu --> Click Options -->Click General --> uncheck “Disable Virtual objects during recording” -->Click Apply --> Click “OK”
Mapping unrecognized object to a standard object is called as Virtual object. This can be done as follows
Navigation:
Tools Menu -->Virtual Objects --> New Virtual Object -->Click Next -->Select Standard class to Map --> Click next -->Click on Mark Object -->Mark the object using cursor -->Click Next -->Click Next -->Enter Name of the Object and collection -->Click Finish
Enable Virtual Objects to recognize during recording:
Go to Tools Menu --> Click Options -->Click General --> uncheck “Disable Virtual objects during recording” -->Click Apply --> Click “OK”
Thursday, 31 March 2011
How to work with Actions in QTP
Ways of creating the Actions:
1. Creating the Action During Recording
2. Creating the actions after recording
Navigation:
Go to insert menu à Select “Call to New Action” à Enter Action Name à Description à check the check box “Reusable Action” to make the action reusable à select location as At End of test or after current step. (Generally we will use the first option)
External Actions: A reusable action “xyz” created in test X, called into Test Y then, that ‘XYZ[testX]” is external action to “Test Y”, which cannot be edited. It is read only in “Test Y”.
Call to Copy Of Actions:
If an action is called using “Insert à Call To Copy of action”, the entire action will be copied to the current test along with its resources. The advantage is it can be modified according to your current test requirements. But, it increases the utilisation of memory. Use whenever necessary.
These modifications applicable to current test only.
Eg:
Action_Login created as reusable in testX
Called copy of Action_Login in to TestY - à COPY Action_Login or you can modify to Action_Login
You modify the Action_Login of TestY. This modification does not affect Action_login of TestX.
But, IF you call “Action_Login of TestY into TeSTA, then in TestA, you will get the Action_Login of TestY along with its modifications.
Split Actions:
An action can be split in Two Actions at a time.
Navigation for Split Action:
1. Enter new line from where the action to be split
2. Right Click à Select Actions à click Split Action à Select “Independent of Each Other” or “Nested Actions”
3. Enter Names for Action 1 and action 2
what are the different types of actions in QTP?
Actions:
A test can be divided in to multiple logical units called as Actions. This helps in easy maintenance.
Types of Actions:
1. Reusable Actions – These can be used by any of the test. It can re-use within the test it created and also in the other tests.
2. Non – Reusable Actions – can’t be reused even in the test it is created.
Tuesday, 29 March 2011
Get cell data from Excel File
'Create Excel Application object
Set suitExcelobj= CreateObject("Excel.Application")
'Open the Excel Work book
Set suitExcelWorkbook=suitExcelobj.Workbooks.Open(suitEXCELPath)
'Open a particular sheet
Set suitExcelWorkSheet=suitExcelobj.WorkSheets("Scenario1")
'Activate the sheet
suitExcelWorkSheet.Activate
'Set the alerts to False
suitExcelobj.DisplayAlerts = false
If Err.Number>0 Then
msgbox "Error in the Suite Excel"
ExitRun(0)
end if
'Get the total row count
RowsCount =suitExcelobj.ActiveSheet.UsedRange.Rows.Count
'Get the values from the excel application
x= suitExcelobj.Cells(1,2).Value
How to work with Excel files using QTP?
Using the following code a given excel sheet can be opened
Set suitExcelobj= CreateObject("Excel.Application")
Set suitExcelWorkbook=suitExcelobj.Workbooks.Open("C:\Testdata.xls)
Set suitExcelWorkSheet=suitExcelobj.WorkSheets("Scenario1")
Subscribe to:
Posts (Atom)