preload

ChildAttributeValueByName (QTP, TestComplete, VBScript)

Posted by Albert Gareev on Sep 08, 2012
0
Parent page: Service Functions – MSXMLDOM (QTP, TestComplete, VBScript) Description Returns text value of node’s child attribute specified by name. Valid arguments: an XML element node (NODE_ELEMENT type), name of the attribute. If XML node is not defined, returns empty string. Uses private function p_GetXMLElementAttrText, defined within the library (see parent page). Implementation Public Function [...] ...

GetTokenByKeyword (QTP, TestComplete, VBScript)

Posted by Albert Gareev on Mar 06, 2012
0
Parent page: Service Functions – String (QTP, VBScript) Description Get token string from the source string. Position is relative, defined by another token-keyword and a number. Implementation Public Function GetTokenByKeyword(ByVal strSource, ByVal chrDelimiter, ByVal strKeyword, ByVal intNumber, ByRef strToken) Dim Tokens, intCount, intIndex Dim i, boolRC Tokens = Split(strSource, chrDelimiter) intCount = UBound(Tokens)+1 intIndex = [...] ...

GetTokenByNumber (QTP, TestComplete, VBScript)

Posted by Albert Gareev on Mar 05, 2012
0
Parent page: Service Functions – String (QTP, VBScript) Description Get token string from the source string. Position is absolute, defined by number. Implementation Public Function GetTokenByNumber(ByVal strSource, ByVal chrDelimiter, ByVal intNumber, ByRef strToken) Dim Tokens, intCount strSource = ReplaceEx(strSource, " *", " ", False) Tokens = Split(strSource, chrDelimiter) intCount = UBound(Tokens) If intNumber > ...

Automatic Data Maintenance – Date/Time (Excel)

Posted by Albert Gareev on Jan 08, 2012
0
A few simple Excel macros I use for automatic data maintenance. Date Macro Current date/time =NOW() 9/7/2011 17:57 Date formatted as text =TEXT(NOW(),”mm/dd/yyyy”) 09/07/2011 Future date (5 days from today) =TEXT(NOW()+5,”mm/dd/yyyy”) 09/12/2011 A year 180 days before today =TEXT(YEAR(NOW()-180), “00″) 2011 A month 58 days from today =TEXT(MONTH(NOW()+58), “00″) 11 Year, formatted ...

CopyChildElements (QTP, TestComplete, VBScript)

Posted by Albert Gareev on Dec 08, 2011
0
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 [...] ...

MoveChildElements (QTP, TestComplete, VBScript)

Posted by Albert Gareev on Dec 06, 2011
0
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     [...] ...

XMLElementDepth (QTP, TestComplete, VBScript)

Posted by Albert Gareev on Oct 20, 2011
0
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 ...

CreateXMLDOMFromString (QTP, TestComplete, VBScript)

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

XMLNodeSet2Dictionary (QTP, TestComplete, VBScript)

Posted by Albert Gareev on Jul 20, 2011
0
Parent page: Service Functions – MSXMLDOM (QTP, TestComplete, VBScript) Service Functions – Dictionary (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 ...

XMLNode2Dictionary (QTP, TestComplete, VBScript)

Posted by Albert Gareev on Jul 19, 2011
0
Parent page: Service Functions – MSXMLDOM (QTP, TestComplete, VBScript) Service Functions – Dictionary (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. [...] ...

Generating Test Reports: Final Example

Posted by Albert Gareev on Jun 23, 2011
0
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" ...

XML/XSL Transformation: Using Styles

Posted by Albert Gareev on May 25, 2011
0
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> ...

XML/XSL Transformation: Using Sub-Templates

Posted by Albert Gareev on Mar 14, 2011
3
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"> ...

XML/XSL Transformation: Tree to Table

Posted by Albert Gareev on Mar 04, 2011
1
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] ...

XML/XSL Transformation: Using Complex Nodes

Posted by Albert Gareev on Mar 03, 2011
0
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> ...

XML/XSL Transformation: Stats Table

Posted by Albert Gareev on Mar 02, 2011
0
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> ...

How to “Save As” text template

Posted by Albert Gareev on Oct 26, 2010
0
Parent page: Service Functions – System (QTP, VBScript) Question I need to modify text file template (add a few lines) and “Save as”. Answer One of the typical challenges that people face while trying to automate work tasks, is “procedure – result” confusion. Here, the end result* is confused with a way** to do the [...] ...

Inserting breaks into text line

Posted by Albert Gareev on Aug 19, 2010
0
Parent page: Service Functions – String (QTP, VBScript) Description Based on the maximum allowed length of  the string (strMsgText) insert space characters. Implementation Public Function BreakTextLine(ByVal strMsgText, ByVal intMaxLen)  Dim intLoc, intMaxLen, strResult  If Len(strMsgText) < intMaxLen Then   BreakTextLine = strMsgText   Exit Function  End If  strResult = ""  While Len(strMsgText) > 0   intLoc = ...

How to use Dictionary object for storing Excel data ...

Posted by Albert Gareev on Jun 10, 2010
0
Parent page: Service Functions – Excel (QTP, VBScript) Answers Description Connect to Excel through COM - Open workbook - Open worksheet – map cell values to column names. Notes. Heading and trailing space characters are removed To make mapping not case sensitive index is brought to lower case If your spreadsheet allows column name duplication you need to enhance [...] ...

How to use test data from a locked Excel Workbook ...

Posted by Albert Gareev on Apr 08, 2010
1
Parent page: Service Functions – Excel (QTP, VBScript) Question The question was asked here. How can I get data from Excel spreadsheet if it is accidentally open? It ruins whole batch execution. While opening manually I can go “read-only” and still access it. Is there any way to read data from an open and locked [...] ...
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.