Wednesday, May 20, 2015

Print a file Through QTP


 TargetFolder ="C:\New folder"
Set objShell = CreateObject("Shell.Application")
Set objFolder = objShell.Namespace(TargetFolder)
Set colItems = objFolder.Items
msgbox colitems.Count
For Each objItem in colItems
msgbox objitem
    objItem.InvokeVerbEx("Print")
Next

Get the Printers list which are added in the system

 strComputer = "."

Set objWMIService = GetObject("winmgmts:\\" & strComputer & "\root\cimv2")

'Find the Default printer name with below statement
'Set colPrinters =  objWMIService.ExecQuery("Select * from Win32_Printer Where Default = TRUE")
Set colPrinters =  objWMIService.ExecQuery("Select * from Win32_Printer")
For Each objPrinter in colPrinters
    strOldDefault = objPrinter.Name
    msgbox strOldDefault

Next
' Make printer default with below statement
   ' strOldDefault = Replace(strOldDefault, "\", "\\")

Wednesday, February 6, 2013

Handle Download Bar in IE9

Below code helpful whenever do you want to download and save from any web application which is opened in IE9

Set DeviceReplay = CreateObject("Mercury.DeviceReplay") Browser("creationtime:=0").WinObject("nativeclass:=DirectUIHWND","regexpwndclass:=DirectUIHWND", "index:=0").highlight
 ' Right-click on Save button drop down down arrow in Download Bar
 Browser("creationtime:=0").WinObject("nativeclass:=DirectUIHWND","regexpwndclass:=DirectUIHWND", "index:=0").Clickontext "Save",,,,,true,micRightBtn,true

 'Save drop down list get focus by pressing 'down arrow'

 DeviceReplay.PressKey 208 ' 'down arrow' key Presses
   'Press the 'a' key to activate the drop-down button and then activate the Save As command. DeviceReplay.PressKey 30 ' 'a' key Presses
   Set DeviceReplay = Nothing
 'Enter the File path

 Browser("creationTime:=0").Dialog("Save As").WinEdit("Edit").Set "C:\Exportfile.xls"
 ' click on Save button
 Browser("creationTime:=0").Dialog("Save As").WinButton("Save").Click

See the more details in below HP support website

Unified-Functional-Testing/QTP-11-can-t-recognize-the-download-bar-of-IE9

Tuesday, January 8, 2013

HP UFT Demo Download or HP QTP 11.5 download and installation


Please refer the below Link for HP UFT 11.5 demo software download and installation.
http://www.qtponlinetrainings.com/p/hp-uft.html/
with above link download HP QTP 11.5 or HP Unified Functional Testing tool software
.
See the HP UFT New Features in below link
http://www.qtponlinetrainings.com/p/hp-uft-115-new-features.html/
.

Thursday, June 14, 2012

Store the test results stepwise in excel file.

Whenever do you want to store each step results in excel file or datatable sheet follow below steps.
1. Add sheet in the datatable with required columns , here I am using “Result” as Sheet name and column names are ActionName, StepName, StepDescription, StepResult. For this created function.
2. Created one more function for test step results storage and reporter event results. Call this function wherever do you want to store step results in excel file or datatable.
3. At the end of the test add the datatable.Export “ file path” Statement.

'Call the Function for Addsheet in the data table
Fnaddsheet

' call the function for step result store in the data table sheet
' Enter Event Status in Digits (0-Pass , 1- Fail, 2- Done, 3- Warning
fnReproter 0,"step first","Passed","passed details"
fnReproter 1,"step first","Passed","passed details"
fnReproter 2,"step first","Passed","passed details"
fnReproter 3,"step first","Passed","passed details"


'Column names in the Result sheet ActionName, StepName, StepDescription, StepResult
Function fnAddSheet
Datatable.AddSheet "Result"
Datatable.GetSheet("Result").AddParameter "ActionName",""
Datatable.GetSheet("Result").AddParameter "StepName",""
Datatable.GetSheet("Result").AddParameter "StepDescription",""
Datatable.GetSheet("Result").AddParameter "StepResult",""
' Do you want to import your own sheet then use below statement
' Datatable.ImportSheet "C:\Result.xls",1,"Result"
End Function

Function fnReproter(strEventStatus,StepName,StepResult,StepDetails)

Reporter.ReportEvent strEventStatus, StepName & " :- " & StepResult, StepDetails
' ActionName, StepName, StepDescription, StepResult
intRowCnt=Datatable.GetSheet("Result").GetRowCount
Reporter.ReportEvent micDone,"Result sheet row count",introwcnt
Datatable.GetSheet("Result").SetCurrentRow (intRowcnt+1)
Datatable.Value("ActionName","Result")=Environment.Value("ActionName")
Datatable.Value("StepName","Result")= StepName
Datatable.Value("StepDescription","Result")=StepDetails
Datatable.Value("StepResult","Result")= StepResult

End Function

.

Friday, May 25, 2012