Posted by Albert Gareev on Dec 15, 2009
Parent page: Service Functions – System (QTP, VBScript) How to duplicate an existing file (If you want to access the file but it’s locked) Description sFileName – name of the file to duplicate sNewName – name of created file (generated automatically), pass-back argument. Uses UniqueFilename function to generate a name for the duplicate file. Public Function DuplicateFile(ByVal [...] ...
Posted by Albert Gareev on Dec 14, 2009
Parent page: Service Functions – System (QTP, VBScript) How to generate a unique file name if the file name already exists in the given folder (That often happens, if you need to create a series of files or duplicate an existing file) Description sFileName – the “original” file name or file name template sFolderName – parent folder [...] ...
Posted by Albert Gareev on Nov 19, 2009
Even though automated testing scripts are intended to communicate with application under test there are cases when communication with tester is required. With QTP, we can use either built-in MsgBox / InputBox functions or link standard Windows dialogs through COM. MsgBox Use this function to report information (like value of a variable) during debugging or [...] ...
Posted by Albert Gareev on Oct 25, 2009
Parent page: Service Functions – System (QTP, VBScript) Use FileSystemObject.GetFile method to obtain a File object. Argument should be a full path string. Set FSO = CreateObject(“Scripting.FileSystemObject”) Check if the file exists first. When to use it? There is a variety of utility tasks related to it: get parent folder, create another file in the same folder, create another [...] ...
Posted by Albert Gareev on Oct 24, 2009
Parent page: Service Functions – System (QTP, VBScript) Use FileSystemObject.FileExists method. Argument should be a full path string. When to use it? Always before trying to access the file (delete, rename, or read from). Does file format matter? No. It could be text file, excel spreadsheet, bitmap, binary file, – anything. Just make sure you [...] ...
Posted by Albert Gareev on Aug 05, 2009
In the code examples I present I often refer to routine functions. In my framework I have specialized libraries to call from. In my blog I maintain the similar structure. Creating Custom Dialog DotNetFactory interface functions – create custom dialog Creating DotNetFactory GUI Objects DotNetFactory interface functions (1) – Create Button DotNetFactory interface functions (2) – Create Label DotNetFactory [...] ...
Posted by Albert Gareev on Jun 18, 2009
Parent page: Service Functions – DotNetFactory (QTP, VBScript) Used resources Service Functions – String (QTP, VBScript) Implementing optional and default parameters Create TextBox along with the Prompt Label and place on the GUI Form Public Function PlaceTextBox(ByRef objForm, ByVal objParameter) Dim sPrompt Dim intLeft, intTop Dim objTextBox, objLabel 'Verify parameters If TypeName (objParameter) <> ...
Posted by Albert Gareev on Jun 17, 2009
Parent page: Service Functions – DotNetFactory (QTP, VBScript) Creating .NET objects from VBScript/QTP You can create a basic Form and assign required properties within one line by calling the function below. The function has one mandatory parameter (which though is initialized by default if empty) and a set of optional parameters provided in the Dictionary object. [...] ...
Posted by Albert Gareev on Jun 16, 2009
Parent page: Service Functions – DotNetFactory (QTP, VBScript) Creating .NET objects from VBScript/QTP You can create a ComboBox (Dropdown Listbox/InputBox Object) and assign required properties within one line by calling the function below. The function has one mandatory parameter (list of available selection items – packed in the Dictionary object) and a set of optional parameters [...] ...
Posted by Albert Gareev on Jun 15, 2009
Parent page: Service Functions – DotNetFactory (QTP, VBScript) Creating .NET objects from VBScript/QTP You can create a CheckBox and assign required properties within one line by calling the function below. The function has one mandatory parameter (which though is initialized by default if empty) and a set of optional parameters provided in the Dictionary object. Currently [...] ...
Posted by Albert Gareev on Jun 14, 2009
Parent page: Service Functions – DotNetFactory (QTP, VBScript) Creating .NET objects from VBScript/QTP You can create a TextBox (single-line Text Input object) and assign required properties within one line by calling the function below. The function has only optional parameters provided in the Dictionary object. Currently supported optional parameters: TextBox Width and Height. TextBox Coordinates – [...] ...
Posted by Albert Gareev on Jun 13, 2009
Parent page: Service Functions – DotNetFactory (QTP, VBScript) Creating .NET objects from VBScript/QTP You can create a label and assign required properties within one line by calling the function below. The function has one mandatory parameter (which though is initialized by default if empty) and a set of optional parameters provided in the Dictionary object. Currently [...] ...
Posted by Albert Gareev on Jun 12, 2009
Parent page: Service Functions – DotNetFactory (QTP, VBScript) Creating .NET objects from VBScript/QTP You can create a button and assign required properties within one line by calling the function below. The function has one mandatory parameter (which though is initialized by default if empty) and a set of optional parameters provided in the Dictionary object. Currently [...] ...
Posted by Albert Gareev on Mar 23, 2008
Parent page: Service Functions – Math (QTP, VBScript) Check whether an item is in set Public Function isItemInSet(ByVal stSet, ByVal sItem, ByVal sSetSeparator) Dim dvArray If sItem = "" Then isItemInSet = False Exit Function End If dvArray = Set2Array(stSet, sSetSeparator) isItemInSet = isItemInArray(dvArray) End Function ...
Posted by Albert Gareev on Mar 22, 2008
Parent page: Service Functions – Math (QTP, VBScript) Check whether a set consists of numeric values Public Function isSetNumeric(ByVal stSet, ByVal sSetSeparator) Dim dvArray dvArray = Set2Array(stSet, sSetSeparator) isSetNumeric = isArrayNumeric(dvArray) End Function Check whether a set consists of date/time values Public Function isSetDate(ByVal stSet, ByVal sSetSeparator) Dim dvArray [...] ...
Posted by Albert Gareev on Mar 20, 2008
Parent page: Service Functions – Math (QTP, VBScript) Convert set to typed array Public Function Set2TypedArray(ByVal stSet, ByVal sSetSeparator, ByVal sFormat) Dim Iter, dvArray If sSetSeparator = "" Then sSetSeparator = chrSetSeparator End If stSet = Replace(stSet, "\,", Chr(176)) stSet = Replace(stSet, "\ ", Chr(187)) dvArray = Split(stSet, sSetSeparator) [...] ...
Posted by Albert Gareev on Feb 19, 2008
Parent page: Service Functions – Math (QTP, VBScript) Convert array to set Public Function Array2Set(ByVal dvArray, ByVal sSetSeparator) Dim Iter Dim stResult If Not isArray(dvArray) Then Array2Set = "" Exit Function End If If UBound(dvArray) = -1Then Array2Set = "" Exit Function End If [...] ...
Posted by Albert Gareev on Feb 17, 2008
Parent page: Service Functions – Math (QTP, VBScript) Check whether an item is in array Public Function isItemInArray(ByVal dvArray, ByVal sItem) Dim Iter If sItem = "" Then isItemInArray = False Exit Function End If If Not isArray(dvArray) Then isItemInArray = False Exit Function [...] ...
Posted by Albert Gareev on Feb 15, 2008
Parent page: Service Functions – Math (QTP, VBScript) Check whether an array consists of numeric values Public Function isArrayNumeric(ByVal dvArray) Dim Iter If Not isArray(dvArray) Then isArrayNumeric = False Exit Function End If If UBound(dvArray) = -1 Then isArrayNumeric = False Exit Function End If [...] ...
Posted by Albert Gareev on Jan 20, 2008
In the code examples I present I often refer to routine functions. In my framework I have specialized libraries to call from. In my blog I maintain the similar structure. Array Functions Sort Data Array Sort Typed Data Array Check Array Type Check Item in Array Convert Array to Set Set Functions Convert Set to Array [...] ...