Wednesday, June 24, 2009

QTP Blog

  • posted by rajivkumarnandvani at Working with QTP - 2 days ago
    Here are some links for QTP certification: http://h10017.www1.hp.com/certification/ — Contains details about the program ftp://ftp.hp.com/pub/hpcp/epgs/HP0-M16_EPG.pdf — Exam Preparation Guide. This conta...
  • posted by rajivkumarnandvani at Working with QTP - 3 days ago
    Hi All, Now I am going to describle the undocumented feature of QTP that is ClickONText method . Some time we require the object text location ( x ,y position ) in window so that we can click that object...
  • posted by rajivkumarnandvani at Working with QTP - 1 week ago
    Hi All, Some time we requre keyboard event in Automation so we can use Send key method rem ********************************************** rem create shell object set WshShell = CreateObject(”WScript.Shell”...
  • posted by rajivkumarnandvani at Working with QTP - 5 weeks ago
    Function WindowsUnZip(sUnzipFileName, sUnzipDestination) Set oUnzipFSO = CreateObject(”Scripting.FileSystemObject”) If Not oUnzipFSO.FolderExists(sUnzipDestination) Then oUnzipFSO.CreateFolder(sUnzipDesti...
  • posted by rajivkumarnandvani at Working with QTP - 5 weeks ago
    REM This function get the label message text from Web page whose class ErrorMessage OR InformationMessage REM Input objParent := Object Name of from which rquired the Message like Page or Frame REM Out...
  • posted by rajivkumarnandvani at Working with QTP - 5 weeks ago
    Hi All, Some time we required that Only OLD open Browser Window( Only for IE) will remain Open and rest of all shall be closed during QTP scripting. Here is the Function which will close the all open Brows...
  • posted by rajivkumarnandvani at Working with QTP - 5 weeks ago
    Hi All, Some time we required that Only Latest open Browser Window( Only for IE) will remain Open and rest of all shall be closed during QTP scripting. Here is the Function which will close the all open Br...
  • posted by rajivkumarnandvani at Working with QTP - 5 weeks ago
    Change the following registry settings.. HKEY_LOCAL_MACHINE\SOFTWARE\Mercury Interactive\QuickTest Professional\MicTest Locate the key “SkipEnvironmentChecks” By Default the value will be “0″ Change the va...
  • posted by rajivkumarnandvani at Working with QTP - 5 weeks ago
    Some Time QTP not recognize the application object during seond run it Or it run first time successfully then QTP give an error cannot identified the application Window object properties does not match wit...
  • posted by rajivkumarnandvani at Working with QTP - 5 weeks ago
    If you have worked on QTP for some time you might have encountered errors like “General Run Error” which does not give any details regarding the error and testers often resort to using hit-and-try method t...
  • posted by rajivkumarnandvani at Working with QTP - 5 weeks ago
    1. Go to menu Tools->options following Window will appear If check box not checked then it will shown in Display Add-in Manager on startup checkbox Close the QTP and again open the QTP Application. Now on ...
  • posted by rajivkumarnandvani at Working with QTP - 5 weeks ago
    Make sure your application must be open after opening the QTP tool; otherwise QTP does not record the application. So always open QTP first and after this open the Application. Check Record and Run Options...

Sunday, May 3, 2009

Delete Cookies and Temprary internet files VB QTP

rem ********************************

rem delete cookies

call fn_DeletesubFolderAndFiles(”C:\DOCUME~1\%USERNAME%\Cookies”)

rem *********************************

rem rem delete Temporary internet files

call fn_DeletesubFolderAndFiles(”C:\DOCUME~1\%USERNAME%\Locals~1\Tempor~1″)

rem ***********************************

REM *************************************************************************

REM Function fn_DeletesubFolderAndFiles(path)

Rem this Function delete the files & subfolder under the specified path

REM Input spath := Files path or parent Folder path

REM Output(ReturnType) := None

REM Note := IF file Protected then it will not delete without giving Error

REM Created: 17/April/2009 Rajiv Kumar Nandvani ## Changed:MM/DD/YYYY

REM *************************************************************************

Public Function fn_DeletesubFolderAndFiles(spath)

on Error Resume Next

rem Create File System object

set objFileSystem = CreateObject(”Scripting.FileSystemObject“)

rem Create Window Shel object

Set objWshShell = CreateObject(WScript.Shell“)

Rem get Folderpath under which file present

Set objoFolder = objFileSystem.GetFolder(objWshShell.ExpandEnvironmentStrings(spath))

rem get count the files under the folder and loop run for delete the files

For Each oFile In objoFolder.files

On Error Resume Next

objFileSystem.DeleteFile oFile

Err.clear

Next

rem get count the subfolders under the folder and loop run for delete the subfolders

For Each oSubFolder In objoFolder.SubFolders

On Error Resume Next

objFileSystem.DeleteFolder oSubFolder

Err.clear

Next

rem clear the object

set objFileSystem = nothing

set objWshShell = nothing

set objoFolder = nothing

Err.clear

End function

Close All open Browser QTP VB

‘ This function Close All open Browser
REM *************************************************************************

REM this function close All open browser

Public Function fn_CloseAllBrowser()
While Browser(”CreationTime:=0″).Exist
Browser(”CreationTime:=0″).Close
Wend
End Function

REM *************************************************************************ss

Close Application Process QTP

REM This function kill the given process exe through task manager
rem example call fn_CloseApplication(”EXCEL.EXE”)

Public Function fn_CloseApplication( byval sApplicationExe)
Dim strComputer
Dim objWMIService
Dim colProcesses
Dim objProcess
strComputer = “.”
Set objWMIService = GetObject(”winmgmts:\\” & strComputer & “\root\cimv2″)

Set colProcesses = objWMIService.ExecQuery (”Select * from Win32_Process Where Name = ‘”&sApplicationExe&”‘”)
For Each objProcess in colProcesses
objProcess.Terminate()
Next
Set objWMIService = Nothing
Set colProcesses=Nothing
End Function

Get current DATETIME through VB QTP/Create unique file or folder

Some Time we want create a folder Or File with unique name then we current date time value for creating the file or folder that we can use this method for create the file OR folder as decribed here

REM this function return the current date time in text format

REM Function fn_GetDateTimeText() This function return currentdatetime in Text format
REM this will remove the specail charactor from currentdatetime & replace with _ underscore
REM Input := None
REM Output(ReturnType) := return currentdatetime in Text format

Public Function fn_GetDateTimeText

Dim sDateTime
sDateTime = now
sDateTime =replace(sDateTime,”:”,”_”)
sDateTime =replace(sDateTime,”>”,”_”)
sDateTime =replace(sDateTime,”<”,”_”)
sDateTime =replace(sDateTime,”/”,”_”)
sDateTime =replace(sDateTime,”|”,”_”)
sDateTime =replace(sDateTime,”\”,”_”)
sDateTime =replace(sDateTime,”*”,”_”)
sDateTime =replace(sDateTime,”"”",”_”)
sDateTime =replace(sDateTime,”#”,”")
fn_GetDateTimeText =sDateTime
End Function

dim sGetCurrentDateTime

sGetCurrentDateTime = fn_GetDateTimeText()

Set objFSO =CreateObject(”Scripting.FileSystemObject”)

rem create text file

objFSO.CreateTextFile(“c:/” & sGetCurrentDateTime & “.txt” , True)

rem create folder

objFSO.CreateFolder(“c:/” & sGetCurrentDateTime & “.txt” , True)

Check XML File Valid OR Not VB QTP

REM ************************************************
Rem This Function Check XML File Valid OR not if File not valid XML then return False Else True
REM Function fn_CheckXMLValid( sXMLfilepath)
REM Input sXMLfilepath := XMLfilepath
REM Output(ReturnType) := True or False
REM Created: 21/April/2009 Rajiv Kumar Nandvani ## Changed:MM/DD/YYYY

REM *************************************************************************

Public Function fn_CheckXMLValid(byval sXMLfilepath)
rem create XML object
Set xmlDoc = CreateObject( “Microsoft.XMLDOM” )
xmlDoc.Async = “False”
Rem load XML File
xmlDoc.Load( sXMLfilepath )
If xmlDoc.parseError.errorCode<>0 Then
fn_CheckXMLValid=False
else
fn_CheckXMLValid=True
End If
Set xmlDoc = nothing

End Function

REM ************************************************

Get Column Address Excel VB / Find Column

Some Time we have to Check that particular column Exist or Not abd required the column address
rem this function return the column address of your Excel sheet
rem input parameter xlFilePath := xls file path || FindColumn =column value which need to be check

dim sXLpath , FindColumn ,getColumnAddress
sXLpath =”C:\RajivKumarNandvani.xls” rem define xls file path
FindColumn =”Rajiv” rem check rajiv in column exist or not
getColumnAddress = FindColumnAddress(sXLpath ,FindColumn )
msgbox getColumnAddress
Public function FindColumnAddress(Byval xlFilePath ,byval FindColumn )

Set ObjAppExcel = CreateObject(”Excel.Application”)
rem Disable alerts
ObjAppExcel.DisplayAlerts = False
rem Add a workbook to the Excel App
ObjAppExcel.Workbooks.open(xlFilePath)
‘Get the object of the first sheet in the workbook
Set objectSheet = ObjAppExcel.Sheets(”Sheet1″)
rem count used Column in sheet
nColumnCount =objectSheet.UsedRange.Columns.Count
rem get the last column address
c =replace(objectSheet.Cells(1,nColumnCount).address,”$”,”")
rem define the range from A1 to last column address and filnd the value in range
set objValueFind = objectSheet.Range(”A1:”&c).Find(FindColumn)
If not objValueFind is nothing Then
FindColumnAddress =replace(objValueFind.address,”$”,”")
FindColumnAddress =replace(FindColumnAddress,”1″,”")
Exit function

End If
rem if not found then return the Empty
FindColumnAddress =”NOT FOUND”

Set objValueFind =nothing
Set objectSheet =nothing
Set ObjAppExcel =nothing
End Function