preload

How to wrap text line (QTP, VBScript)

Posted by Albert Gareev on Feb 25, 2010
0
Parent page: Service Functions – String (QTP, VBScript) Question The question was asked here. Hi Albert! Can you email me a QTP function that wraps line of text without breaking words? Thank you!  Answer Proper text alignment is important. The whole layout of CSS block or HTML table could be broken if a text line [...] ...

How to trim words inside a text line (QTP, VBScript)

Posted by Albert Gareev on Feb 22, 2010
0
Parent page: Service Functions – String (QTP, VBScript) Question The question was asked here. What QTP function i can use to trim inside string? For e.g. “text text text text” – i want only 1 space between. Answer I believe the sample string provided in the question originally contained multiple space characters inside but was [...] ...

How to find-replace empty cells (Excel, QTP, VBScript)

Posted by Albert Gareev on Jan 29, 2010
0
Parent page: Service Functions – Excel (QTP, VBScript) Answers Description Connect to Excel through COM - Open workbook - Open worksheet – Loop through data range – close and save the workbook. Note.  In the example below script finds empty cells and assigns zero  to them. Make sure you targeted the worksheet that you need. You can find it [...] ...

How to find Excel worksheet by name (QTP, VBScript)

Posted by Albert Gareev on Jan 27, 2010
0
Parent page: Service Functions – Excel (QTP, VBScript) Answers Description Connect to Excel through COM - Open workbook - Loop through worksheets – close and save the workbook. 1. If you know Excel Worksheet name and pretty sure it exists Set XLHandle =  CreateObject("Excel.Application") XLHandle.DisplayAlerts = False     Set XLBook = XLHandle.WorkBooks.Open("c:\temp\1.xls") On Error Resume Next Set objWorksheet ...

How to add (create) Excel macro from QTP

Posted by Albert Gareev on Jan 21, 2010
0
Parent page: Service Functions – Excel (QTP, VBScript) Answers Description Connect to Excel through COM - Open workbook - Retrieve Code Module object - Add new macro string - close and save the workbook. Notes. For this example let’s assume our target Workbook is stored as “C:\Temp\1.xls”, and our target Code Module is named “Module1″. QTP/VBScript source code Set XLHandle =  ...

How to enlist Excel VBA macros (QTP, VBScript)

Posted by Albert Gareev on Jan 20, 2010
1
Parent page: Service Functions – Excel (QTP, VBScript) Answers Description Connect to Excel through COM - Open workbook - Retrieve Code Module object - Retrieve Code Block string - Parse the string – close and save the workbook. Notes. For this example let’s assume our target Workbook is stored as “C:\Temp\1.xls”, and our target Code Module is named “Module1″, and we’re looking for ...

How to exchange parameters with Excel VBA function ...

Posted by Albert Gareev on Jan 15, 2010
0
Parent page: Service Functions – Excel (QTP, VBScript) Answers 1. To pass-in parameters to an Excel VBA function A function must be public and belong to a Macro Module. QTP/VBScript source code Set XLHandle =  CreateObject("Excel.Application") XLHandle.DisplayAlerts = False     Set XLBook = XLHandle.WorkBooks.Open("c:\temp\1.xls") On Error Resume Next Call XLHandle.Run("ArgFunction", 5) boolRC = Err.Number ...

How to call Excel VBA function from QTP

Posted by Albert Gareev on Jan 14, 2010
0
Parent page: Service Functions – Excel (QTP, VBScript) Answers Description Connect to Excel through COM - Open workbook - Invoke the function - Catch error - close and save the workbook. Notes. Macro (Sub or Function) must be public and belong to a Macro Module. Set XLHandle =  CreateObject("Excel.Application") XLHandle.DisplayAlerts = False     Set XLBook = XLHandle.WorkBooks.Open("c:\temp\1.xls") On Error ...

Service Functions – Excel (QTP, TestComplete, ...

Posted by Albert Gareev on Jan 12, 2010
0
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. Functions Excel File Worksheet compare (QTP, VBScript) How to check if Excel Workbook is locked A little automation for VBScript OOP (1) A little automation for [...] ...

How to update value in XML file (QTP, VBScript)

Posted by Albert Gareev on Dec 30, 2009
0
Parent page: Service Functions – XML (QTP, VBScript)  Answers Description Open XML file – load into memory – locate target nodes – update (replace) values – save XML file (either under a new name or overwrite the original file). Search is performed by tag name (“target_node”). If you pass in a non-string parameter for .SetValue function, convert [...] ...

How to count XML nodes (QTP, VBScript)

Posted by Albert Gareev on Dec 29, 2009
0
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 ...

Generating text file from XML template (QTP, VBScript)

Posted by Albert Gareev on Dec 09, 2009
1
Parent page: Service Functions – System (QTP, VBScript) Description If you need to generate text file with values you don’t know ahead you may do it dynamically, by utilizing the function below. Make sure you designed template first. The current logic is oriented to executable text files generation, like Dexterity Macro or OS Shell batch files. Code lines are data-driven, [...] ...

Text File Compare Report example (XML, XSL, HTML)

Posted by Albert Gareev on Dec 03, 2009
1
Root page: Service Functions – XML (QTP, VBScript) Parent page: XSL introduction and references Related post: Text File compare in “WDIFF” style (QTP, VBScript, XML, XSL) – Instructions and XSL script Sample task After line by line (and word by word) text file comparison has been performed, XML log was produced. Review the log, identify and report found issues. [...] ...

XML verification example (XSL, HTML)

Posted by Albert Gareev on Dec 02, 2009
0
Root page: Service Functions – XML (QTP, VBScript) Parent page: XSL introduction and references Sample task Verify “transactions” xml file consisting of 10-1000 records. Only “debit” or “credit” record names are valid. Any other entries must be located and reported. Additionally, identify and report all debit records with debit amount greater than 50.00 Sample XML <?xml version="1.0" ...

XSL introduction and references

Posted by Albert Gareev on Nov 30, 2009
1
Parent page: Service Functions – XML (QTP, VBScript)  What is XSL? The Extensible Stylesheet Language. An XSL script is a set of transformation instructions used by an engine (often, web browser, but could be any other processing program as well) to produce a new document based on XML input document. The original document remains unchanged. The output document [...] ...

XPath introduction and references

Posted by Albert Gareev on Nov 23, 2009
0
Parent page: Service Functions – XML (QTP, VBScript)  Note. Although there could be no “reusable function” that would construct XPath for you, I store current post under “XML Service Functions” category, as it’s closely related to it. XPath is fairly simple to learn and very powerful in use.  You can use free XPath Designer Tool to validate [...] ...

QTP-XML service functions (7) – Add processing ...

Posted by Albert Gareev on Nov 15, 2009
0
Parent page: Service Functions – XML (QTP, VBScript) Description This particular example demonstrates adding XSL call that contains instructions transforming XML tree to a web-page (HTML). Built-in QTP support for XML does not provide mapping for XML methods that operate special nodes, like Processing Instructions. It can be done through Microsoft XML DOM object. Dim objXMLDoc Dim objNode Set [...] ...

QTP-XML service functions (6) – ...

Posted by Albert Gareev on Nov 14, 2009
0
Parent page: Service Functions – XML (QTP, VBScript) Description Uses .AddChildElementByName method to create a child XML node, then returns reference to the newly created object. If Parent XML node is not defined returns “Nothing”. Public Function CreateChildElementByName(ByRef objXMLParent, ByVal sTagName, ByVal sInnerText)  Dim objColl  If objXMLParent is Nothing Then   Set CreateChildElementByName = Nothing   Exit ...

How to open Excel workbook (QTP, VBScript)

Posted by Albert Gareev on Oct 17, 2009
0
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 [...] ...

Service Functions – XML (QTP, VBScript)

Posted by Albert Gareev on Oct 02, 2009
0
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.  Using built-in QTP-XML Objects and Functions  Returns reference of XML Element Returns text value of XML Element Returns reference of XML Attribute Returns text value of [...] ...
Creative Commons Attribution-NonCommercial-NoDerivs 3.0 Unported
This work by Albert Gareev is licensed under a Creative Commons Attribution-NonCommercial-NoDerivs 3.0 Unported.