Posted by Albert Gareev on Dec 29, 2009
Parent page: Service Functions – XML (QTP, VBScript) Answers 1. How to count all direct children? Set objColl = objParent.ChildElements() intCount = objColl.Count 2. How to count all direct children, specific name tag? Set objColl = objParent.ChildElementsByPath("./wanted") intCount = objColl.Count 3. How to count all descendants? Set objColl = objParent.ChildElementsByPath("descendant::*") intCount = objColl.Count ...
Posted by Albert Gareev on Dec 21, 2009
All related posts: Reference Page – GP/QTP Automation Answer According to the documentation, there are no loop operators defined in Microsoft Dynamics Great Plains Dexterity Macros. However, the macro language provides other commands to workaround the issues in the most required cases. Workarounds 1. Capture values of GUI fields (in a loop) Use DumpFieldBegin…DumpFieldEnd commands. 2. Window synchronization [...] ...
Posted by Albert Gareev on Dec 16, 2009
Parent page: Service Functions – System (QTP, VBScript) How to create a unique subfolder Description A subfolder is created based on the name pattern and a date-time stamp, e.g. “AccountSearch 2009-10-14 17-18-03″. You can add extra steps and form the code as a function that returns full path of the newly created subfolder. sName – name pattern sFullPath [...] ...
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 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 Oct 17, 2009
Parent page: Service Functions – Excel (QTP, VBScript) Description Check the file exists – Create an instance of Excel by using COM – open (load) file Dim XLHandle, XLBook Public Function OpenWorkbook(ByVal sFileName) Dim FSO, boolRC Set FSO = CreateObject("Scripting.FileSystemObject") boolRC = FSO.FileExists(sFileName) Set FSO = Nothing If Not boolRC Then OpenWorkbook = FALSE Exit [...] ...
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 May 27, 2009
Original date: N/A The post has been mostly recompiled from the comments. Displaying Text File comparison results in an embedded report. Refer to Text File Compare functions used to see how XML file is generated. Sample requirements to show comparison results stored in XML as a web-page (HTML). 1. Show file stats saved in xml file. [...] ...
Posted by Albert Gareev on May 24, 2009
Original date: 16 Dec 2008, 1:14pm Service function Public Function AssociateParameters(ByVal strParams) Dim objDictionary, Values, strPair, Pair Dim intCount, i strParams = Replace(strParams, "\,", Chr(176)) strParams = Replace(strParams, "\=", Chr(187)) Values = Split(strParams, ",") intCount = UBound(Values) Set objDictionary = CreateObject("Scripting.Dictionary") For i=0 To ...
Posted by Albert Gareev on May 23, 2009
Original date: 5 Dec 2008, 1:23pm Parent page: Service Functions – Excel (QTP, VBScript) 'Assumptions: 'Excel file exists 'Workbook is open (XLBook) 'Sheet exists Set objUsedRange = XLBook.Worksheets(sSheetIndex).UsedRange() Set objSheetColNameMap = CreateObject("Scripting.Dictionary") For Iter = 1 To objUsedRange.Columns.Count sCellText = objUsedRange.Cells(1,Iter) If sCellText <> "" Then ...
Posted by Albert Gareev on Dec 23, 2007
How to select multiple items in custom list Description Select each item with “Control” key (Ctrl on keyboard). public function _list_select_multy(in list, in items) { auto rc, count, i, k; auto dvItem[]; count = split(items, dvItem, ","); if (count < 1) { return(E_GENERAL_ERROR); } rc = list_select_item(list, str_trim(dvItem[1])); if (rc != E_OK) { [...] ...
Posted by Albert Gareev on Dec 21, 2007
How to input parameters for WinRunner scripts Description In order to use a customizable dialog, you need to declare data fields and data handler that will populate them as per your needs/rules. # create_custom_dialog specific fields static _env_str, _case_str, _input_str; # public function _on_param_dlg(in env_str, in case_str, in input_str) { _env_str = env_str; _case_str = [...] ...