Posted by Albert Gareev on Dec 08, 2011
Parent page: Service Functions – MSXMLDOM (QTP, TestComplete, VBScript) Description Copy all child elements (and attributes, comments, text nodes) from one XML node to another. Implementation Public Function CopyChildElements(ByRef objXMLSrc, ByRef objXMLDest) Dim objCloneNode If objXMLSrc is Nothing Then Set MoveChildElements = objXMLDest Exit Function End If If [...] ...
Posted by Albert Gareev on Dec 06, 2011
Parent page: Service Functions – MSXMLDOM (QTP, TestComplete, VBScript) Description Move all child elements (and attributes, comments, text nodes) from one XML node to another. Implementation Public Function MoveChildElements(ByRef objXMLSrc, ByRef objXMLDest) If objXMLSrc is Nothing Then Set MoveChildElements = objXMLDest Exit Function End If If objXMLDest is Nothing Then [...] ...
Posted by Albert Gareev on Nov 24, 2011
Description Get object reference. Get total number of items in the list. Generate an index within the given range. Select item by index. Implementation Dim objPage, objList Dim boolRC Dim intItemsCount, intRndItem 'Assumptions: ' "Google Advanced Search" page is up ' "Results per page" WebList exists and enabled 'Get page object Set objPage = Browser("CreationTime:=0").Page("title:=Google Advanced ...
Posted by Albert Gareev on Oct 20, 2011
Parent page: Service Functions – MSXMLDOM (QTP, TestComplete, VBScript) Description Locate XML node depth within the hierarchy. Valid argument: an XML element node (NODE_ELEMENT type). Implementation Public Function XMLElementDepth(ByRef objXMLElement) Dim intDepth Dim objXMLNode If objXMLElement is Nothing Then XMLElementDepth = -1 Exit Function End If 'NODE_DOCUMENT(9) If objXMLElement.NodeType = 9 Then ...
Posted by Albert Gareev on Oct 08, 2011
Parent page: Service Functions – MSXMLDOM (QTP, TestComplete, VBScript) Description Create XML DOM object by loading source XML from string. If the string is empty or source XML is invalid returns Nothing. Implementation Public Function CreateXMLDOMFromString(ByVal sXMLSource) Dim boolRC, intRC Dim objXMLDoc, objXMLRoot If Trim(sXMLSource) = "" Then Set CreateXMLDOMFromString = Nothing Exit [...] ...
Posted by Albert Gareev on Jul 26, 2011
Reference page: Service Functions – System (QTP, VBScript) Description Check folder exists – check folder has files. Iterate through collection of files and keep reference of the most recently modified file (its DateLastModified property is always the highest number). The remaining reference is the one that you need. In case of errors the function returns [...] ...
Posted by Albert Gareev on Jul 20, 2011
Parent page: Service Functions – MSXMLDOM (QTP, TestComplete, VBScript) Description For each occurrence of XML node perform conversion to Dictionary, and store all records in indexed Dictionary object. Implementation Public Function XMLNodeSet2Dictionary(ByRef objXMLNodeSet) Dim objDictionary Dim Iter Set objDictionary = CreateObject("Scripting.Dictionary") If objXMLNodeSet is Nothing Then Set XMLNodeSet2Dictionary = ...
Posted by Albert Gareev on Jul 19, 2011
Parent page: Service Functions – MSXMLDOM (QTP, TestComplete, VBScript) Description Create Dictionary object and populate with data (only direct content – text, comments, CData, and attributes) taken from XML node. Naming convention: @attr_name for attributes; #text_index for text nodes; #comment_index for comment nodes; #cdata_index for CData Section nodes. Implementation Public Function XMLNode2Dictionary(ByRef objXMLElement) ...
Posted by Albert Gareev on Jun 23, 2011
Parent page: Generating Test Reports Today I put all examples together. Here’s our XML record simulating log data of a test session. XML Source <?xml version="1.0" encoding="utf-8"?> <?xml-stylesheet type="text/xsl" href=".\LogView4.xsl"?> <log> <area id="A001"> <description>Testing login page, invalid password</description> <step type="#note" ...
Posted by Albert Gareev on Jun 14, 2011
Parent page: Generating Test Reports Today’s post is a little bit of a side mini-project within the test reports theme. What I wanted is to add more structure in test logs, but made it summarized. So I went to explore about simple approaches in that. Very often, on static pages (without AJAX) the approach used is [...] ...
Posted by Albert Gareev on May 25, 2011
Parent page: Generating Test Reports Let’s now take the examples from the previous post, and add more style. Here’s our XML record simulating log data of a test session. XML Source <?xml version="1.0" encoding="utf-8"?> <?xml-stylesheet type="text/xsl" href=".\LogView3.xsl"?> <log> <step type="#note"> <time>21/04/2011 11:45:31 AM</time> ...
Posted by Albert Gareev on Mar 14, 2011
Parent page: Generating Test Reports Today I continue with more complex examples using previously demonstrated XSL parsing nodes grouped into sub-templates. Here’s our XML record simulating log data of a test session. XML Source <?xml version="1.0" encoding="utf-8"?> <?xml-stylesheet type="text/xsl" href=".\LogView2.xsl"?> <log> <step type="#note"> ...
Posted by Albert Gareev on Mar 04, 2011
Parent page: Generating Test Reports Today I present XML Tree to HTML Table transformation example. Here’s our XML record simulating logged test steps. XML Source <?xml version="1.0" encoding="utf-8"?> <?xml-stylesheet type="text/xsl" href=".\Tree2Table.xsl"?> <log> <step type="GUI Step"> <description>Pasted data [User1234] in edit box [Username] ...
Posted by Albert Gareev on Mar 03, 2011
Parent page: Generating Test Reports Today I present example on dynamically building HTML nodes, with XSL, and from XML data. Here’s our XML record simulating log data of a test session. XML Source <?xml version="1.0" encoding="utf-8"?> <?xml-stylesheet type="text/xsl" href=".\LogView1.xsl"?> <log> <step type="GUI Step"> <time>21/04/2011 11:45:31 AM</time> ...
Posted by Albert Gareev on Mar 02, 2011
Parent page: Generating Test Reports Today I present example of an HTML Table populated with XML data. Here’s our XML record simulating stats data of a test session. XML Source <?xml version="1.0" encoding="utf-8"?> <?xml-stylesheet type="text/xsl" href=".\StatsTable.xsl"?> <log> <description>Test login page</description> <reporter>John Doe</reporter> ...
Posted by Albert Gareev on Jan 06, 2011
Close/Terminate Specified Process Parent page: Service Functions – DotNetFactory (QTP, VBScript) Description Create an instance of Process object through DotNetFactory – search for local processes by name – iterate through the returned array and close one by one. First attempt – “gentle” close (via CloseMainWindow()). WaitForExit() gives a process some time to finalize, you may customize [...] ...
Posted by Albert Gareev on Jan 04, 2011
Check If a Process Exists in Memory Parent page: Service Functions – DotNetFactory (QTP, VBScript) Description Create an instance of Process object through DotNetFactory – search for local processes by name – return result as boolean. Note. Name is case-insensitive but no wildcards supported. Implementation Public Function SysProcessExists(ByVal sName) Dim objSDP Dim objSDPArr Dim boolRC [...] ...
Posted by Albert Gareev on Dec 13, 2010
Parent page: GUI Recognition with TestComplete TestComplete provides a whole set of run-time GUI recognition functionalities, based, however, on the same approach: recognition by property values and/or location of the object in internal hierarchy. In addition to methods that immediately return a child object, if it’s available, there are others, that help finding objects that only about [...] ...
Posted by Albert Gareev on Dec 07, 2010
Parent page: GUI Recognition with TestComplete TestComplete provides a whole set of run-time GUI recognition functionalities, based, however, on the same approach: recognition by property values and/or location of the object in internal hierarchy. In addition to methods that immediately return a child object, if it’s available, there are others, that help finding objects that only about [...] ...
Posted by Albert Gareev on Nov 23, 2010
Parent page: GUI Recognition with TestComplete First of all, a short note to those readers who like to rush into conclusions. This post is about a feature, not bug. Here I continue exploring TestComplete GUI recognition capabilities with code example. The previous two posts (here and here) were about Find, FindChild, and FindAllChildren methods. Today I [...] ...