<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	xmlns:creativeCommons="http://backend.userland.com/creativeCommonsRssModule">

<channel>
	<title>Automation Beyond &#187; 4. Programming</title>
	<atom:link href="http://automation-beyond.com/category/programming/feed/" rel="self" type="application/rss+xml" />
	<link>http://automation-beyond.com</link>
	<description>An engineering approach to Software Testing and Test Automation</description>
	<lastBuildDate>Fri, 20 Apr 2012 13:30:04 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.2.1</generator>
<creativeCommons:license>http://creativecommons.org/licenses/by-nc-nd/3.0/</creativeCommons:license>		<item>
		<title>TestComplete Forms &#8211; Using Custom Events</title>
		<link>http://automation-beyond.com/2012/04/17/testcomplete-custom-events/</link>
		<comments>http://automation-beyond.com/2012/04/17/testcomplete-custom-events/#comments</comments>
		<pubDate>Tue, 17 Apr 2012 10:14:48 +0000</pubDate>
		<dc:creator>Albert Gareev</dc:creator>
				<category><![CDATA[How to]]></category>
		<category><![CDATA[Routines]]></category>
		<category><![CDATA[Source code]]></category>
		<category><![CDATA[2. Testing]]></category>
		<category><![CDATA[3. Automation]]></category>
		<category><![CDATA[automated]]></category>
		<category><![CDATA[code]]></category>
		<category><![CDATA[Configure]]></category>
		<category><![CDATA[controls]]></category>
		<category><![CDATA[Custom]]></category>
		<category><![CDATA[Dialog]]></category>
		<category><![CDATA[dynamically]]></category>
		<category><![CDATA[event]]></category>
		<category><![CDATA[Example]]></category>
		<category><![CDATA[form]]></category>
		<category><![CDATA[function]]></category>
		<category><![CDATA[GUI]]></category>
		<category><![CDATA[Input]]></category>
		<category><![CDATA[interface]]></category>
		<category><![CDATA[onchange]]></category>
		<category><![CDATA[parameter]]></category>
		<category><![CDATA[script]]></category>
		<category><![CDATA[source]]></category>
		<category><![CDATA[test]]></category>
		<category><![CDATA[testcomplete]]></category>
		<category><![CDATA[VBScript]]></category>

		<guid isPermaLink="false">http://automation-beyond.com/?p=5052</guid>
		<description><![CDATA[Parent page: Using GUI Forms in TestComplete Even though automation scripts are intended to drive the application under test there are cases when communication with tester is required. With TestComplete, we have a vast arsenal of predefined GUI controls for that (and those, acquainted with Delphi, will be pleasantly surprised by the way it’s organized). [...]]]></description>
			<content:encoded><![CDATA[
<div class="topsy_widget_data topsy_theme_blue" style="float: right;margin-left: 0.75em; background: url(data:,%7B%20%22url%22%3A%20%22http%253A%252F%252Fautomation-beyond.com%252F2012%252F04%252F17%252Ftestcomplete-custom-events%252F%22%2C%20%22shorturl%22%3A%20%22http%3A%2F%2Fbit.ly%2FJwqw8D%22%2C%20%22style%22%3A%20%22big%22%2C%20%22title%22%3A%20%22TestComplete%20Forms%20-%20Using%20Custom%20Events%22%20%7D);"></div>
<p>Parent page: <a href="http://automation-beyond.com/chapters/tutorials/gui-forms-tc/" target="_blank">Using GUI Forms in TestComplete</a></p>
<p>Even though automation scripts are intended to drive the application under test there are cases when communication with tester is required. With TestComplete, we have a vast arsenal of predefined GUI controls for that (and those, acquainted with Delphi, will be pleasantly surprised by the way it’s organized).</p>
<p>Today’s post provides an example of creating and using dialog with custom event handlers &#8211; whenever script user provides input, event handler may be used to provide a customized response.<br />
In the scope of the exercise let&#8217;s use the following task.</p>
<ul>
<li>Setup form prompts to choose an environment where test plan is to be run</li>
<li>User can choose one of predefined environments: DEV, SIT, UAT</li>
<li>Receives a response as a url of the environment</li>
<li>User can leave suggested by default test data file or can type filepath directly</li>
</ul>
<p>&nbsp;</p>
<h4>Preparing Modal Form</h4>
<p>We begin with a <a href="http://automation-beyond.com/2012/04/09/adding-gui-forms-in-testcomplete-project/" target="_blank">sample form</a>.</p>
<p><div style="position: relative; z-index:1;"><script type="text/javascript"><!--
google_ad_client = "pub-4470793787913935";
/* Banner 468x60 */
google_ad_slot = "8933038987";
google_ad_width = 468;
google_ad_height = 60;
//-->
</script>
<script type="text/javascript"
src="http://pagead2.googlesyndication.com/pagead/show_ads.js">
</script></div></p>
<h4>Add Edit Controls, Buttons, and Labels</h4>
<p><img class="alignnone size-full wp-image-5055" title="SetupForm" src="http://automation-beyond.com/wp/wp-content/uploads/2012/04/SetupForm.png" alt="" width="262" height="318" /></p>
<h4>Set Object Properties</h4>
<h5>Form</h5>
<ul>
<li>Name – object name to use in the code; ‘Security’ in my example</li>
<li>Caption – title of the window when the form is displayed</li>
</ul>
<h5>Label controls</h5>
<ul>
<li>Caption – displayed text</li>
</ul>
<h5>Edit Box Control</h5>
<ul>
<li>Name – object name to use in the code; ‘ShowUrl’ in my example</li>
<li>Text - initial value</li>
<li>ReadOnly = True &#8211; because user can&#8217;t input Url directly</li>
</ul>
<h5>Combo Box Control</h5>
<ul>
<li>Name – object name to use in the code; ‘Environment’/&#8217;TestData&#8217; in my example</li>
<li>Properties.Items &#8211; items to select; &#8216;DEV&#8217;, &#8216;SIT&#8217;, &#8216;UAT&#8217; in my example</li>
<li>ItemIndex = 0 &#8211; initial selection</li>
<li>Properties.DropDownListStyle = lsFixedList &#8211; for Environment combobox</li>
<li>Properties.DropDownListStyle = lsEditList &#8211; for TestData combobox</li>
</ul>
<h5>Buttons</h5>
<ul>
<li>Caption – displayed text; ‘OK’/&#8217;Cancel’ in my example</li>
<li>Cancel = True – for ‘Cancel’ button</li>
<li>ModalResult = mrCancel &#8211; for ‘Cancel’ button</li>
<li>Default = True – for ‘OK’ button</li>
<li>ModalResult = mrOK &#8211; for ‘OK’ button</li>
</ul>
<p>&nbsp;</p>
<h4>Set Event Handler</h4>
<h5>Properties</h5>
<p><img class="alignnone size-full wp-image-5059" style="border: black 1px solid;" title="Events" src="http://automation-beyond.com/wp/wp-content/uploads/2012/04/Events.png" alt="" width="631" height="374" /></p>
<h5>Path</h5>
<p><a href="http://automation-beyond.com/wp/wp-content/uploads/2012/04/Handler.png"><img class="alignnone size-full wp-image-5060" title="Handler" src="http://automation-beyond.com/wp/wp-content/uploads/2012/04/Handler.png" alt="" width="500" height="470" /></a></p>
<h5>Code</h5>
<pre class="brush: vb; title: ;">

Public Sub Setup_Environment_OnChange(Sender)
  Dim sEnvironment

  sEnvironment = UserForms.Setup.Environment.Text

  Select Case sEnvironment
    Case &quot;DEV&quot;
      UserForms.Setup.ShowUrl.Text = &quot;http://dev/&quot;
      UserForms.Setup.TestData.Text = &quot;W:\Test Suite\Data\DEV.xlsx&quot;
    Case &quot;SIT&quot;
      UserForms.Setup.ShowUrl.Text = &quot;http://sit/&quot;
      UserForms.Setup.TestData.Text = &quot;W:\Test Suite\Data\SIT.xlsx&quot;
    Case &quot;UAT&quot;
      UserForms.Setup.ShowUrl.Text = &quot;http://uat/&quot;
      UserForms.Setup.TestData.Text = &quot;W:\Test Suite\Data\UAT.xlsx&quot;
  End Select

End Sub
</pre>
<h4>Example</h4>
<p><script type="text/javascript"><!--
google_ad_client = "pub-4470793787913935";
/* 4 links text line */
google_ad_slot = "5367351963";
google_ad_width = 468;
google_ad_height = 15;
//-->
</script>
<script type="text/javascript"
src="http://pagead2.googlesyndication.com/pagead/show_ads.js">
</script></p>
<pre class="brush: vb; title: ;">
Public Function Form1()
  Dim objDlg
  Dim sEnvironment, sTestData
  Dim Result

  'Get object's instance
  Set objDlg = UserForms.Setup

  'Execute
  Result = objDlg.ShowModal

  If Result = mrOK Then
    'retrieve the selected input
    sEnvironment = objDlg.Environment.Text
    sTestData = objDlg.TestData.Text
  Else
    'Respond
    MsgBox &quot;Execution cancelled&quot;, vbOKOnly
    'exit function or finalize execution
  End If

End Function
</pre>
<div id="crp_related"><h3>Related Posts:</h3><ul><li><a href="http://automation-beyond.com/2009/08/24/great-plains-automation/" rel="bookmark" class="crp_title">MS Dynamics Great Plains: availability for Test Automation</a></li><li><a href="http://automation-beyond.com/2009/08/26/dynamics-great-plains-gui/" rel="bookmark" class="crp_title">MS Dynamics Great Plains: GUI Platform (automation perspective)</a></li><li><a href="http://automation-beyond.com/2012/04/09/adding-gui-forms-in-testcomplete-project/" rel="bookmark" class="crp_title">Adding GUI forms in TestComplete project</a></li><li><a href="http://automation-beyond.com/2010/09/07/anti-sleep-function2/" rel="bookmark" class="crp_title">Anti sleep function (TestComplete, VBScript, LLPlayer)</a></li><li><a href="http://automation-beyond.com/2007/04/10/links-dot-net-objects/" rel="bookmark" class="crp_title">Link-a-log: Dot NET objects</a></li></ul></div>
]]></content:encoded>
			<wfw:commentRss>http://automation-beyond.com/2012/04/17/testcomplete-custom-events/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>TestComplete – &#8220;UserName/Password&#8221; Form</title>
		<link>http://automation-beyond.com/2012/04/16/testcomplete-username-password-form/</link>
		<comments>http://automation-beyond.com/2012/04/16/testcomplete-username-password-form/#comments</comments>
		<pubDate>Mon, 16 Apr 2012 10:34:35 +0000</pubDate>
		<dc:creator>Albert Gareev</dc:creator>
				<category><![CDATA[How to]]></category>
		<category><![CDATA[Routines]]></category>
		<category><![CDATA[Source code]]></category>
		<category><![CDATA[2. Testing]]></category>
		<category><![CDATA[3. Automation]]></category>
		<category><![CDATA[automated]]></category>
		<category><![CDATA[code]]></category>
		<category><![CDATA[Configure]]></category>
		<category><![CDATA[Custom]]></category>
		<category><![CDATA[Dialog]]></category>
		<category><![CDATA[dynamically]]></category>
		<category><![CDATA[Example]]></category>
		<category><![CDATA[form]]></category>
		<category><![CDATA[function]]></category>
		<category><![CDATA[GUI]]></category>
		<category><![CDATA[Input]]></category>
		<category><![CDATA[interface]]></category>
		<category><![CDATA[not store]]></category>
		<category><![CDATA[parameter]]></category>
		<category><![CDATA[password]]></category>
		<category><![CDATA[script]]></category>
		<category><![CDATA[security]]></category>
		<category><![CDATA[source]]></category>
		<category><![CDATA[test]]></category>
		<category><![CDATA[testcomplete]]></category>
		<category><![CDATA[username]]></category>
		<category><![CDATA[VBScript]]></category>

		<guid isPermaLink="false">http://automation-beyond.com/?p=5041</guid>
		<description><![CDATA[Parent page: Using GUI Forms in TestComplete Even though automation scripts are intended to drive the application under test there are cases when communication with tester is required. With TestComplete, we have a vast arsenal of predefined GUI controls for that (and those, acquainted with Delphi, will be pleasantly surprised by the way it’s organized). [...]]]></description>
			<content:encoded><![CDATA[
<div class="topsy_widget_data topsy_theme_blue" style="float: right;margin-left: 0.75em; background: url(data:,%7B%20%22url%22%3A%20%22http%253A%252F%252Fautomation-beyond.com%252F2012%252F04%252F16%252Ftestcomplete-username-password-form%252F%22%2C%20%22shorturl%22%3A%20%22http%3A%2F%2Fbit.ly%2FHYWCcF%22%2C%20%22style%22%3A%20%22big%22%2C%20%22title%22%3A%20%22TestComplete%20%E2%80%93%20%5C%22UserName%2FPassword%5C%22%20Form%22%20%7D);"></div>
<p>Parent page: <a href="http://automation-beyond.com/chapters/tutorials/gui-forms-tc/" target="_blank">Using GUI Forms in TestComplete</a></p>
<p>Even though automation scripts are intended to drive the application under test there are cases when communication with tester is required. With TestComplete, we have a vast arsenal of predefined GUI controls for that (and those, acquainted with Delphi, will be pleasantly surprised by the way it’s organized).</p>
<p>Today&#8217;s post provides an example of creating and using ‘Username/Password’ dialog.<br />
But, first, a couple of words why automation scripts would need one.</p>
<p>No, this is not an authorization to run the scripts. This is for the scripts.<br />
Maybe you need to connect to the database. Or run the scripts with administrator&#8217;s permission. Or it&#8217;s just a security requirement from your stakeholders.</p>
<p>Whatever it is, you better not store such sensitive data in a file or the source code. Make them exist only during run-time.</p>
<h4>Preparing Modal Form</h4>
<p>We begin with a <a href="http://automation-beyond.com/2012/04/09/adding-gui-forms-in-testcomplete-project/" target="_blank">sample form</a>.</p>
<p><div style="position: relative; z-index:1;"><script type="text/javascript"><!--
google_ad_client = "pub-4470793787913935";
/* Banner 468x60 */
google_ad_slot = "8933038987";
google_ad_width = 468;
google_ad_height = 60;
//-->
</script>
<script type="text/javascript"
src="http://pagead2.googlesyndication.com/pagead/show_ads.js">
</script></div></p>
<h4>Add Edit Controls, Buttons, and Labels</h4>
<p><img class="alignnone size-full wp-image-5046" style="border: black 1px solid;" title="AuthForm" src="http://automation-beyond.com/wp/wp-content/uploads/2012/04/AuthForm.png" alt="" width="409" height="342" /></p>
<h4>Set Object Properties</h4>
<h5>Form</h5>
<ul>
<li>Name &#8211; object name to use in the code; &#8216;Security&#8217; in my example</li>
<li>Caption &#8211; title of the window when the form is displayed</li>
</ul>
<h5>Label controls</h5>
<ul>
<li>Caption &#8211; displayed text</li>
</ul>
<h5>Edit Box Controls</h5>
<ul>
<li>Name &#8211; object name to use in the code; &#8216;EditUsername&#8217;/'EditPassword&#8217; in my example</li>
<li>EditPassword.Properties.EchoMode = eemPassword &#8211; to mask password characters</li>
</ul>
<h5>Buttons</h5>
<ul>
<li>Caption &#8211; displayed text; &#8216;OK&#8217;/'Cancel&#8217; in my example</li>
<li>Cancel = True &#8211; for &#8216;Cancel&#8217; button</li>
<li>ModalResult = mrCancel - for &#8216;Cancel&#8217; button</li>
<li>Default = True &#8211; for &#8216;OK&#8217; button</li>
<li>ModalResult = mrOK - for &#8216;OK&#8217; button</li>
</ul>
<h4>Example</h4>
<p><script type="text/javascript"><!--
google_ad_client = "pub-4470793787913935";
/* 4 links text line */
google_ad_slot = "5367351963";
google_ad_width = 468;
google_ad_height = 15;
//-->
</script>
<script type="text/javascript"
src="http://pagead2.googlesyndication.com/pagead/show_ads.js">
</script></p>
<pre class="brush: vb; title: ;">
  Dim objDlg
  Dim sUsername, sPassword
  Dim Result

  'Get object's instance
  Set objDlg = UserForms.Security

  'Execute
  Result = objDlg.ShowModal

  If Result = mrOK Then
    'retrieve the input
    sUsername = objDlg.EditUsername.Text
    sPassword = objDlg.EditPassword.Text
  Else
    'Respond
    MsgBox &quot;Execution cancelled&quot;, vbOKOnly
    'exit function or finalize execution
  End If
</pre>
<div id="crp_related"><h3>Related Posts:</h3><ul><li><a href="http://automation-beyond.com/2008/10/10/on-functional-decomposition/" rel="bookmark" class="crp_title">On Functional Decomposition</a></li><li><a href="http://automation-beyond.com/2007/01/22/on-hard-coding-of-test-data-2/" rel="bookmark" class="crp_title">On hard-coding of test data (2)</a></li><li><a href="http://automation-beyond.com/2007/01/20/on-hard-coding-of-test-data-1/" rel="bookmark" class="crp_title">On hard-coding of test data (1)</a></li><li><a href="http://automation-beyond.com/2009/01/23/associaterecords/" rel="bookmark" class="crp_title">AssociateRecords (QTP, TestComplete, VBScript)</a></li><li><a href="http://automation-beyond.com/2012/04/09/adding-gui-forms-in-testcomplete-project/" rel="bookmark" class="crp_title">Adding GUI forms in TestComplete project</a></li></ul></div>
]]></content:encoded>
			<wfw:commentRss>http://automation-beyond.com/2012/04/16/testcomplete-username-password-form/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>TestComplete &#8211; Using &#8216;File Open&#8217; Dialog</title>
		<link>http://automation-beyond.com/2012/04/10/testcomplete-using-file-open-dialog/</link>
		<comments>http://automation-beyond.com/2012/04/10/testcomplete-using-file-open-dialog/#comments</comments>
		<pubDate>Tue, 10 Apr 2012 10:41:36 +0000</pubDate>
		<dc:creator>Albert Gareev</dc:creator>
				<category><![CDATA[How to]]></category>
		<category><![CDATA[Routines]]></category>
		<category><![CDATA[Source code]]></category>
		<category><![CDATA[2. Testing]]></category>
		<category><![CDATA[3. Automation]]></category>
		<category><![CDATA[automated]]></category>
		<category><![CDATA[code]]></category>
		<category><![CDATA[Configure]]></category>
		<category><![CDATA[Custom]]></category>
		<category><![CDATA[Dialog]]></category>
		<category><![CDATA[Example]]></category>
		<category><![CDATA[file]]></category>
		<category><![CDATA[form]]></category>
		<category><![CDATA[function]]></category>
		<category><![CDATA[GUI]]></category>
		<category><![CDATA[Input]]></category>
		<category><![CDATA[interface]]></category>
		<category><![CDATA[open]]></category>
		<category><![CDATA[parameter]]></category>
		<category><![CDATA[script]]></category>
		<category><![CDATA[source]]></category>
		<category><![CDATA[test]]></category>
		<category><![CDATA[testcomplete]]></category>
		<category><![CDATA[VBScript]]></category>

		<guid isPermaLink="false">http://automation-beyond.com/?p=5014</guid>
		<description><![CDATA[Parent page: Using GUI Forms in TestComplete Even though automation scripts are intended to drive the application under test there are cases when communication with tester is required. With TestComplete, we have a vast arsenal of predefined GUI controls for that (and those, acquainted with Delphi, will be pleasantly surprised by the way it’s organized). [...]]]></description>
			<content:encoded><![CDATA[
<div class="topsy_widget_data topsy_theme_blue" style="float: right;margin-left: 0.75em; background: url(data:,%7B%20%22url%22%3A%20%22http%253A%252F%252Fautomation-beyond.com%252F2012%252F04%252F10%252Ftestcomplete-using-file-open-dialog%252F%22%2C%20%22shorturl%22%3A%20%22http%3A%2F%2Fbit.ly%2FIeZnv4%22%2C%20%22style%22%3A%20%22big%22%2C%20%22title%22%3A%20%22TestComplete%20-%20Using%20%27File%20Open%27%20Dialog%22%20%7D);"></div>
<p>Parent page: <a href="http://automation-beyond.com/chapters/tutorials/gui-forms-tc/" target="_blank">Using GUI Forms in TestComplete</a></p>
<p>Even though automation scripts are intended to drive the application under test there are cases when communication with tester is required. With TestComplete, we have a vast arsenal of predefined GUI controls for that (and those, acquainted with Delphi, will be pleasantly surprised by the way it’s organized).</p>
<p>The second post in the series provides an example of using &#8216;File Open&#8217; dialog.</p>
<p>We begin with a <a href="http://automation-beyond.com/2012/04/09/adding-gui-forms-in-testcomplete-project/" target="_blank">sample form</a>.</p>
<h4>Add &#8216;TOpenDialog&#8217; Icon</h4>
<p><img class="alignnone size-full wp-image-5016" style="border: black 1px solid;" title="FormAddDialog" src="http://automation-beyond.com/wp/wp-content/uploads/2012/03/FormAddDialog.png" alt="" width="516" height="366" /></p>
<p><div style="position: relative; z-index:1;"><script type="text/javascript"><!--
google_ad_client = "pub-4470793787913935";
/* Banner 468x60 */
google_ad_slot = "8933038987";
google_ad_width = 468;
google_ad_height = 60;
//-->
</script>
<script type="text/javascript"
src="http://pagead2.googlesyndication.com/pagead/show_ads.js">
</script></div></p>
<h4>Set Dialog Properties</h4>
<p><img class="alignnone size-full wp-image-5017" style="border: black 1px solid;" title="DialogProperties" src="http://automation-beyond.com/wp/wp-content/uploads/2012/03/DialogProperties.png" alt="" width="409" height="663" /></p>
<p>The property names are straight-forward, so I cover only main ones.</p>
<ul>
<li>Name &#8211; object name to use in the code;</li>
<li>InitialDir &#8211; folder to begin browsing from;</li>
<li>Filter &#8211; to specify what filetypes to display;</li>
<li>FileName &#8211; will contain the full pathname of the file upon successful selection;</li>
<li>Options\ofPathMustExist &#8211; set <strong>True</strong> if selection accepts only existing files;</li>
<li>Options\ofFileMustExist - set <strong>True</strong> if selection accepts only existing files;</li>
</ul>
<p>These properties can be set in the Property Editor or directly in the code at run-time as in the example below.</p>
<h4>Example</h4>
<p><script type="text/javascript"><!--
google_ad_client = "pub-4470793787913935";
/* 4 links text line */
google_ad_slot = "5367351963";
google_ad_width = 468;
google_ad_height = 15;
//-->
</script>
<script type="text/javascript"
src="http://pagead2.googlesyndication.com/pagead/show_ads.js">
</script></p>
<pre class="brush: vb; title: ;">
'Get object's instance
Set objDlg = UserForms.PlanOpenDlg
'Assign path
objDlg.OpenDialog.InitialDir = &quot;C:\FakePath\Test Plans&quot;
'Set filter
objDlg.OpenDialog.Filter = &quot;XML Test Plans (*.xml)|*.XML&quot;
'Execute as modal and get the status
If objDlg.OpenDialog.Execute Then
  'retrieve the selected file
  sTestPlan = objDlg.OpenDialog.FileName
Else
  'Respond
  MsgBox &quot;Execution cancelled&quot;, vbOKOnly
  'exit function or finalize execution
End If
</pre>
<div id="crp_related"><h3>Related Posts:</h3><ul><li><a href="http://automation-beyond.com/2010/10/26/how-to-save-as/" rel="bookmark" class="crp_title">How to &#8220;Save As&#8221; text template</a></li><li><a href="http://automation-beyond.com/2010/08/24/testcomplete-gui-extensibility/" rel="bookmark" class="crp_title">TestComplete GUI extensibility with Object Mapping</a></li><li><a href="http://automation-beyond.com/2009/11/19/using-built-in-and-system-dialogs-in-qtp/" rel="bookmark" class="crp_title">Using built-in and system dialogs in QTP</a></li><li><a href="http://automation-beyond.com/2010/04/08/using-locked-excel-workbook/" rel="bookmark" class="crp_title">How to use test data from a locked Excel Workbook (QTP, VBScript)</a></li><li><a href="http://automation-beyond.com/2009/10/17/how-to-open-excel-workbook-qtp-vbscript/" rel="bookmark" class="crp_title">How to open Excel workbook (QTP, VBScript)</a></li></ul></div>
]]></content:encoded>
			<wfw:commentRss>http://automation-beyond.com/2012/04/10/testcomplete-using-file-open-dialog/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Adding GUI forms in TestComplete project</title>
		<link>http://automation-beyond.com/2012/04/09/adding-gui-forms-in-testcomplete-project/</link>
		<comments>http://automation-beyond.com/2012/04/09/adding-gui-forms-in-testcomplete-project/#comments</comments>
		<pubDate>Mon, 09 Apr 2012 10:43:59 +0000</pubDate>
		<dc:creator>Albert Gareev</dc:creator>
				<category><![CDATA[How to]]></category>
		<category><![CDATA[Routines]]></category>
		<category><![CDATA[Source code]]></category>
		<category><![CDATA[2. Testing]]></category>
		<category><![CDATA[3. Automation]]></category>
		<category><![CDATA[automated]]></category>
		<category><![CDATA[Configure]]></category>
		<category><![CDATA[Custom]]></category>
		<category><![CDATA[Dialog]]></category>
		<category><![CDATA[Example]]></category>
		<category><![CDATA[form]]></category>
		<category><![CDATA[function]]></category>
		<category><![CDATA[GUI]]></category>
		<category><![CDATA[Input]]></category>
		<category><![CDATA[interface]]></category>
		<category><![CDATA[parameter]]></category>
		<category><![CDATA[script]]></category>
		<category><![CDATA[test]]></category>
		<category><![CDATA[testcomplete]]></category>
		<category><![CDATA[VBScript]]></category>

		<guid isPermaLink="false">http://automation-beyond.com/?p=4994</guid>
		<description><![CDATA[Parent page: Using GUI Forms in TestComplete Even though automation scripts are intended to drive the application under test there are cases when communication with tester is required. With TestComplete, we have a vast arsenal of predefined GUI controls for that (and those, acquainted with Delphi, will be pleasantly surprised by the way it&#8217;s organized). [...]]]></description>
			<content:encoded><![CDATA[
<div class="topsy_widget_data topsy_theme_blue" style="float: right;margin-left: 0.75em; background: url(data:,%7B%20%22url%22%3A%20%22http%253A%252F%252Fautomation-beyond.com%252F2012%252F04%252F09%252Fadding-gui-forms-in-testcomplete-project%252F%22%2C%20%22shorturl%22%3A%20%22http%3A%2F%2Fbit.ly%2FHmqykl%22%2C%20%22style%22%3A%20%22big%22%2C%20%22title%22%3A%20%22Adding%20GUI%20forms%20in%20TestComplete%20project%22%20%7D);"></div>
<p>Parent page: <a href="http://automation-beyond.com/chapters/tutorials/gui-forms-tc/" target="_blank">Using GUI Forms in TestComplete</a></p>
<p>Even though automation scripts are intended to drive the application under test there are cases when communication with tester is required. With TestComplete, we have a vast arsenal of predefined GUI controls for that (and those, acquainted with Delphi, will be pleasantly surprised by the way it&#8217;s organized).</p>
<p>Today&#8217;s post walks through the main preparation steps.</p>
<h4>Add New Project Item</h4>
<p><img class="alignnone size-full wp-image-4997" style="border: black 1px solid;" title="AddNewItem" src="http://automation-beyond.com/wp/wp-content/uploads/2012/02/AddNewItem.png" alt="" width="585" height="313" /></p>
<h4>Select Project Item Type &#8211; &#8216;User Forms&#8217;</h4>
<p><img class="alignnone size-full wp-image-4998" style="border: black 1px solid;" title="CreateProjectItem" src="http://automation-beyond.com/wp/wp-content/uploads/2012/02/CreateProjectItem.png" alt="" width="522" height="348" /></p>
<h4>Add New Item into &#8216;User Forms&#8217;</h4>
<p><img class="alignnone size-full wp-image-4999" style="border: black 1px solid;" title="AddNewForm" src="http://automation-beyond.com/wp/wp-content/uploads/2012/02/AddNewForm.png" alt="" width="574" height="412" /></p>
<h4>Add New Item into &#8216;User Forms&#8217; &#8211; Create a New Form</h4>
<p><img class="alignnone size-full wp-image-5000" style="border: black 1px solid;" title="CreateNewForm" src="http://automation-beyond.com/wp/wp-content/uploads/2012/02/CreateNewForm.png" alt="" width="519" height="382" /></p>
<p><div style="position: relative; z-index:1;"><script type="text/javascript"><!--
google_ad_client = "pub-4470793787913935";
/* Banner 468x60 */
google_ad_slot = "8933038987";
google_ad_width = 468;
google_ad_height = 60;
//-->
</script>
<script type="text/javascript"
src="http://pagead2.googlesyndication.com/pagead/show_ads.js">
</script></div></p>
<h4>You end up in the Form Editor</h4>
<p><img class="alignnone size-full wp-image-5012" style="border: black 1px solid;" title="FormView" src="http://automation-beyond.com/wp/wp-content/uploads/2012/03/FormView.png" alt="" width="597" height="721" /></p>
<p><script type="text/javascript"><!--
google_ad_client = "pub-4470793787913935";
/* 4 links text line */
google_ad_slot = "5367351963";
google_ad_width = 468;
google_ad_height = 15;
//-->
</script>
<script type="text/javascript"
src="http://pagead2.googlesyndication.com/pagead/show_ads.js">
</script></p>
<p>Note that you can add GUI controls from 4 main categories:</p>
<ul>
<li>&#8216;Editors&#8217;</li>
<li>&#8216;Helpers&#8217;</li>
<li>&#8216;Extra&#8217;</li>
<li>&#8216;Dialogs&#8217;</li>
<li>&#8216;Buttons&#8217;</li>
</ul>
<div id="crp_related"><h3>Related Posts:</h3><ul><li><a href="http://automation-beyond.com/2012/04/16/testcomplete-username-password-form/" rel="bookmark" class="crp_title">TestComplete – &#8220;UserName/Password&#8221; Form</a></li><li><a href="http://automation-beyond.com/2012/04/10/testcomplete-using-file-open-dialog/" rel="bookmark" class="crp_title">TestComplete &#8211; Using &#8216;File Open&#8217; Dialog</a></li><li><a href="http://automation-beyond.com/2012/04/17/testcomplete-custom-events/" rel="bookmark" class="crp_title">TestComplete Forms &#8211; Using Custom Events</a></li><li><a href="http://automation-beyond.com/2007/04/10/links-dot-net-objects/" rel="bookmark" class="crp_title">Link-a-log: Dot NET objects</a></li><li><a href="http://automation-beyond.com/2009/08/24/great-plains-automation/" rel="bookmark" class="crp_title">MS Dynamics Great Plains: availability for Test Automation</a></li></ul></div>
]]></content:encoded>
			<wfw:commentRss>http://automation-beyond.com/2012/04/09/adding-gui-forms-in-testcomplete-project/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>GetTokenByKeyword (QTP, TestComplete, VBScript)</title>
		<link>http://automation-beyond.com/2012/03/06/gettokenbykeyword/</link>
		<comments>http://automation-beyond.com/2012/03/06/gettokenbykeyword/#comments</comments>
		<pubDate>Tue, 06 Mar 2012 16:01:41 +0000</pubDate>
		<dc:creator>Albert Gareev</dc:creator>
				<category><![CDATA[Source code]]></category>
		<category><![CDATA[Text Data]]></category>
		<category><![CDATA[answer]]></category>
		<category><![CDATA[code]]></category>
		<category><![CDATA[Example]]></category>
		<category><![CDATA[expression]]></category>
		<category><![CDATA[function]]></category>
		<category><![CDATA[How to]]></category>
		<category><![CDATA[QTP]]></category>
		<category><![CDATA[question]]></category>
		<category><![CDATA[replace]]></category>
		<category><![CDATA[reusable]]></category>
		<category><![CDATA[routine function]]></category>
		<category><![CDATA[separator]]></category>
		<category><![CDATA[service function]]></category>
		<category><![CDATA[source]]></category>
		<category><![CDATA[split]]></category>
		<category><![CDATA[string]]></category>
		<category><![CDATA[text]]></category>
		<category><![CDATA[token]]></category>
		<category><![CDATA[trim]]></category>
		<category><![CDATA[VBScript]]></category>
		<category><![CDATA[wrap]]></category>

		<guid isPermaLink="false">http://automation-beyond.com/?p=5035</guid>
		<description><![CDATA[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 = [...]]]></description>
			<content:encoded><![CDATA[
<div class="topsy_widget_data topsy_theme_blue" style="float: right;margin-left: 0.75em; background: url(data:,%7B%20%22url%22%3A%20%22http%253A%252F%252Fautomation-beyond.com%252F2012%252F03%252F06%252Fgettokenbykeyword%252F%22%2C%20%22shorturl%22%3A%20%22http%3A%2F%2Fbit.ly%2FA3pK5m%22%2C%20%22style%22%3A%20%22big%22%2C%20%22title%22%3A%20%22GetTokenByKeyword%20%28QTP%2C%20TestComplete%2C%20VBScript%29%22%20%7D);"></div>
<p>Parent page: <a title="Service Functions – String (QTP, VBScript)" href="http://automation-beyond.com/2009/10/01/service-functions-string/" target="_blank">Service Functions – String (QTP, VBScript)</a></p>
<p><div style="position: relative; z-index:1;"><script type="text/javascript"><!--
google_ad_client = "pub-4470793787913935";
/* Banner 468x60 */
google_ad_slot = "8933038987";
google_ad_width = 468;
google_ad_height = 60;
//-->
</script>
<script type="text/javascript"
src="http://pagead2.googlesyndication.com/pagead/show_ads.js">
</script></div></p>
<h4>Description</h4>
<p>Get token string from the source string. Position is relative, defined by another token-keyword and a number.</p>
<h4>Implementation</h4>
<p><script type="text/javascript"><!--
google_ad_client = "pub-4470793787913935";
/* 4 links text line */
google_ad_slot = "5367351963";
google_ad_width = 468;
google_ad_height = 15;
//-->
</script>
<script type="text/javascript"
src="http://pagead2.googlesyndication.com/pagead/show_ads.js">
</script></p>
<pre class="brush: vb; title: ;">
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 = -1

	For i=0 To intCount-1
		If Regex_Test(Tokens(i),strKeyword) Then
			intIndex = i
			Exit For
		End If
	Next

	If intIndex = -1 Then
    strToken = &quot;&quot;
		GetTokenByKeyword = False
		Exit Function
	End If

	If (intIndex+1+intNumber) &gt; intCount Then
    strToken = &quot;&quot;
		GetTokenByKeyword = False
		Exit Function
	End If

	If (intIndex+1+intNumber) &lt; 0 Then
    strToken = &quot;&quot;
		GetTokenByKeyword = True
		Exit Function
	End If

	strToken = Tokens(intIndex+intNumber)
	GetTokenByKeyword = True
End Function
</pre>
<div id="crp_related"><h3>Related Posts:</h3><ul><li><a href="http://automation-beyond.com/2009/10/01/service-functions-string/" rel="bookmark" class="crp_title">Service Functions &#8211; String (QTP, VBScript)</a></li><li><a href="http://automation-beyond.com/2008/06/30/service-functions-msxmldom/" rel="bookmark" class="crp_title">Service Functions &#8211; MSXMLDOM (QTP, TestComplete, VBScript)</a></li><li><a href="http://automation-beyond.com/2009/01/09/service-functions-dictionary/" rel="bookmark" class="crp_title">Service Functions – Dictionary (QTP, TestComplete, VBScript)</a></li><li><a href="http://automation-beyond.com/2011/07/20/xmlnodeset2dictionary/" rel="bookmark" class="crp_title">XMLNodeSet2Dictionary (QTP, TestComplete, VBScript)</a></li><li><a href="http://automation-beyond.com/2008/08/05/p_getxmlelementattrtext/" rel="bookmark" class="crp_title">p_GetXMLElementAttrText (QTP, TestComplete, VBScript)</a></li></ul></div>
]]></content:encoded>
			<wfw:commentRss>http://automation-beyond.com/2012/03/06/gettokenbykeyword/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>GetTokenByNumber (QTP, TestComplete, VBScript)</title>
		<link>http://automation-beyond.com/2012/03/05/gettokenbynumber/</link>
		<comments>http://automation-beyond.com/2012/03/05/gettokenbynumber/#comments</comments>
		<pubDate>Mon, 05 Mar 2012 14:12:17 +0000</pubDate>
		<dc:creator>Albert Gareev</dc:creator>
				<category><![CDATA[Source code]]></category>
		<category><![CDATA[Text Data]]></category>
		<category><![CDATA[answer]]></category>
		<category><![CDATA[code]]></category>
		<category><![CDATA[Example]]></category>
		<category><![CDATA[expression]]></category>
		<category><![CDATA[function]]></category>
		<category><![CDATA[How to]]></category>
		<category><![CDATA[parse]]></category>
		<category><![CDATA[QTP]]></category>
		<category><![CDATA[question]]></category>
		<category><![CDATA[replace]]></category>
		<category><![CDATA[reusable]]></category>
		<category><![CDATA[routine function]]></category>
		<category><![CDATA[separator]]></category>
		<category><![CDATA[service function]]></category>
		<category><![CDATA[source]]></category>
		<category><![CDATA[split]]></category>
		<category><![CDATA[string]]></category>
		<category><![CDATA[testcomplete]]></category>
		<category><![CDATA[text]]></category>
		<category><![CDATA[token]]></category>
		<category><![CDATA[trim]]></category>
		<category><![CDATA[VBScript]]></category>
		<category><![CDATA[wrap]]></category>

		<guid isPermaLink="false">http://automation-beyond.com/?p=5032</guid>
		<description><![CDATA[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, &#34; *&#34;, &#34; &#34;, False) Tokens = Split(strSource, chrDelimiter) intCount = UBound(Tokens) If intNumber &#62; intCount [...]]]></description>
			<content:encoded><![CDATA[
<div class="topsy_widget_data topsy_theme_blue" style="float: right;margin-left: 0.75em; background: url(data:,%7B%20%22url%22%3A%20%22http%253A%252F%252Fautomation-beyond.com%252F2012%252F03%252F05%252Fgettokenbynumber%252F%22%2C%20%22shorturl%22%3A%20%22http%3A%2F%2Fbit.ly%2Fyos1LO%22%2C%20%22style%22%3A%20%22big%22%2C%20%22title%22%3A%20%22GetTokenByNumber%20%28QTP%2C%20TestComplete%2C%20VBScript%29%22%20%7D);"></div>
<p>Parent page: <a title="Service Functions – String (QTP, VBScript)" href="http://automation-beyond.com/2009/10/01/service-functions-string/" target="_blank">Service Functions – String (QTP, VBScript)</a></p>
<p><div style="position: relative; z-index:1;"><script type="text/javascript"><!--
google_ad_client = "pub-4470793787913935";
/* Banner 468x60 */
google_ad_slot = "8933038987";
google_ad_width = 468;
google_ad_height = 60;
//-->
</script>
<script type="text/javascript"
src="http://pagead2.googlesyndication.com/pagead/show_ads.js">
</script></div></p>
<h4>Description</h4>
<p>Get token string from the source string. Position is absolute, defined by number.</p>
<h4>Implementation</h4>
<p><script type="text/javascript"><!--
google_ad_client = "pub-4470793787913935";
/* 4 links text line */
google_ad_slot = "5367351963";
google_ad_width = 468;
google_ad_height = 15;
//-->
</script>
<script type="text/javascript"
src="http://pagead2.googlesyndication.com/pagead/show_ads.js">
</script></p>
<pre class="brush: vb; title: ;">
Public Function GetTokenByNumber(ByVal strSource, ByVal chrDelimiter, ByVal intNumber, ByRef strToken)
	Dim Tokens, intCount

	strSource = ReplaceEx(strSource, &quot;  *&quot;, &quot; &quot;, False)
	Tokens = Split(strSource, chrDelimiter)
	intCount = UBound(Tokens)

	If  intNumber &gt; intCount Then
		GetTokenByNumber = FALSE
		Exit Function
	End If

	strToken = Tokens(intNumber-1)
	GetTokenByNumber = TRUE
End Function
</pre>
<div id="crp_related"><h3>Related Posts:</h3><ul><li><a href="http://automation-beyond.com/2008/06/30/service-functions-msxmldom/" rel="bookmark" class="crp_title">Service Functions &#8211; MSXMLDOM (QTP, TestComplete, VBScript)</a></li><li><a href="http://automation-beyond.com/2009/01/09/service-functions-dictionary/" rel="bookmark" class="crp_title">Service Functions – Dictionary (QTP, TestComplete, VBScript)</a></li><li><a href="http://automation-beyond.com/2011/07/20/xmlnodeset2dictionary/" rel="bookmark" class="crp_title">XMLNodeSet2Dictionary (QTP, TestComplete, VBScript)</a></li><li><a href="http://automation-beyond.com/2008/08/05/p_getxmlelementattrtext/" rel="bookmark" class="crp_title">p_GetXMLElementAttrText (QTP, TestComplete, VBScript)</a></li><li><a href="http://automation-beyond.com/2009/10/01/service-functions-string/" rel="bookmark" class="crp_title">Service Functions &#8211; String (QTP, VBScript)</a></li></ul></div>
]]></content:encoded>
			<wfw:commentRss>http://automation-beyond.com/2012/03/05/gettokenbynumber/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>CopyChildElements (QTP, TestComplete, VBScript)</title>
		<link>http://automation-beyond.com/2011/12/08/copychildelements/</link>
		<comments>http://automation-beyond.com/2011/12/08/copychildelements/#comments</comments>
		<pubDate>Thu, 08 Dec 2011 10:41:39 +0000</pubDate>
		<dc:creator>Albert Gareev</dc:creator>
				<category><![CDATA[Source code]]></category>
		<category><![CDATA[XML Data]]></category>
		<category><![CDATA[Child]]></category>
		<category><![CDATA[code]]></category>
		<category><![CDATA[copy]]></category>
		<category><![CDATA[depth]]></category>
		<category><![CDATA[document]]></category>
		<category><![CDATA[DOM]]></category>
		<category><![CDATA[elements]]></category>
		<category><![CDATA[Example]]></category>
		<category><![CDATA[function]]></category>
		<category><![CDATA[hierarchy]]></category>
		<category><![CDATA[How]]></category>
		<category><![CDATA[Move]]></category>
		<category><![CDATA[MSXMLDOM]]></category>
		<category><![CDATA[Node]]></category>
		<category><![CDATA[Nodes]]></category>
		<category><![CDATA[processing]]></category>
		<category><![CDATA[QTP]]></category>
		<category><![CDATA[sample]]></category>
		<category><![CDATA[snippet]]></category>
		<category><![CDATA[Test Automation]]></category>
		<category><![CDATA[testcomplete]]></category>
		<category><![CDATA[to]]></category>
		<category><![CDATA[VBScript]]></category>
		<category><![CDATA[XML]]></category>
		<category><![CDATA[XMLDOM]]></category>

		<guid isPermaLink="false">http://automation-beyond.com/?p=4794</guid>
		<description><![CDATA[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 [...]]]></description>
			<content:encoded><![CDATA[
<div class="topsy_widget_data topsy_theme_blue" style="float: right;margin-left: 0.75em; background: url(data:,%7B%20%22url%22%3A%20%22http%253A%252F%252Fautomation-beyond.com%252F2011%252F12%252F08%252Fcopychildelements%252F%22%2C%20%22shorturl%22%3A%20%22http%3A%2F%2Fbit.ly%2Fshperf%22%2C%20%22style%22%3A%20%22big%22%2C%20%22title%22%3A%20%22CopyChildElements%20%28QTP%2C%20TestComplete%2C%20VBScript%29%22%20%7D);"></div>
<p>Parent page: <a title="Service Functions – MSXMLDOM (QTP, TestComplete, VBScript)" href="http://automation-beyond.com/2008/06/30/service-functions-msxmldom/" target="_blank">Service Functions – MSXMLDOM (QTP, TestComplete, VBScript)</a></p>
<p><div style="position: relative; z-index:1;"><script type="text/javascript"><!--
google_ad_client = "pub-4470793787913935";
/* Banner 468x60 */
google_ad_slot = "8933038987";
google_ad_width = 468;
google_ad_height = 60;
//-->
</script>
<script type="text/javascript"
src="http://pagead2.googlesyndication.com/pagead/show_ads.js">
</script></div></p>
<h4>Description</h4>
<p>Copy all child elements (and attributes, comments, text nodes) from one XML node to another.</p>
<h4>Implementation</h4>
<p><script type="text/javascript"><!--
google_ad_client = "pub-4470793787913935";
/* 4 links text line */
google_ad_slot = "5367351963";
google_ad_width = 468;
google_ad_height = 15;
//-->
</script>
<script type="text/javascript"
src="http://pagead2.googlesyndication.com/pagead/show_ads.js">
</script></p>
<pre class="brush: vb; title: ;">
Public Function CopyChildElements(ByRef objXMLSrc, ByRef objXMLDest)
   Dim objCloneNode
 
   If objXMLSrc is Nothing Then
    Set MoveChildElements = objXMLDest
    Exit Function
   End If

   If objXMLDest is Nothing Then
    Set objXMLDest = objXMLSrc.CloneNode(True)
    Set CopyChildElements = objXMLDest
    Exit Function
   End If

   Set objCloneNode = objXMLSrc.CloneNode(True)

   While Not (objCloneNode.FirstChild is Nothing)
    Call objXMLDest.AppendChild(objCloneNode.FirstChild)
   Wend

   Set objCloneNode = Nothing

   Set CopyChildElements = objXMLDest

End Function
</pre>
<h4>Test Code</h4>
<pre class="brush: vb; title: ;">
  Set objXMLDoc = CreateXMLDOM(&quot;test&quot;)
  Set objXMLParent = CreateChildElementByName(objXMLDoc.DocumentElement, &quot;Modules&quot;, &quot;modules parent node&quot;)
  If objXMLParent is Nothing Then
    Call Reporter.ReportEvent(micFail, &quot;CreateChildElementByName&quot;, &quot;&quot;)
  End If
  Set objXMLNode = CreateChildElementByName(objXMLParent, &quot;Macro&quot;, &quot;macro node 1&quot;)
  If objXMLNode is Nothing Then
    Call Reporter.ReportEvent(micFail, &quot;CreateChildElementByName&quot;, &quot;&quot;)
  End If
  Set objXMLNode = CreateChildElementByName(objXMLParent, &quot;Macro&quot;, &quot;macro node 2&quot;)
  If objXMLNode is Nothing Then
    Call Reporter.ReportEvent(micFail, &quot;CreateChildElementByName&quot;, &quot;&quot;)
  End If
  Set objXMLNode = CreateChildElementByName(objXMLParent, &quot;Macro&quot;, &quot;macro node 3&quot;)
  If objXMLNode is Nothing Then
    Call Reporter.ReportEvent(micFail, &quot;CreateChildElementByName&quot;, &quot;&quot;)
  End If

  sText = &quot;&lt;root&gt;text&lt;/root&gt;&quot;
  Set objXMLDoc2 = CreateXMLDOMFromString(sText)
  If objXMLDoc2 is Nothing Then
    Call Reporter.ReportEvent(micFail, &quot;CreateXMLDOMFromString&quot;, &quot;&quot;)
  End If

  Set objXMLParent2 = Nothing
  Set objXMLParent2 = CopyChildElements(objXMLParent, objXMLParent2)

  Set objXMLNode = ChildElementByName(objXMLParent2, &quot;Macro&quot;) 
  If objXMLNode is Nothing Then
    Call Reporter.ReportEvent(micFail, &quot;ChildElementByName&quot;, &quot;&quot;)
  End If
  If objXMLNode.BaseName &lt;&gt; &quot;Macro&quot; Then
    Call Reporter.ReportEvent(micFail, &quot;ChildElementByName&quot;, &quot;&quot;)
  End If
  If objXMLNode.Text &lt;&gt; &quot;macro node 1&quot; Then
    Call Reporter.ReportEvent(micFail, &quot;ChildElementByName&quot;, &quot;&quot;)
  End If
  Set objXMLNode = ChildElementByName(objXMLParent, &quot;Macro&quot;) 
  If objXMLNode is Nothing Then
    Call Reporter.ReportEvent(micFail, &quot;ChildElementByName&quot;, &quot;&quot;)
  End If
  If objXMLNode.BaseName &lt;&gt; &quot;Macro&quot; Then
    Call Reporter.ReportEvent(micFail, &quot;ChildElementByName&quot;, &quot;&quot;)
  End If
  If objXMLNode.Text &lt;&gt; &quot;macro node 1&quot; Then
    Call Reporter.ReportEvent(micFail, &quot;ChildElementByName&quot;, &quot;&quot;)
  End If

  Set objXMLParent2 = CreateChildElementByName(objXMLDoc2.DocumentElement, &quot;Modules&quot;, &quot;modules parent node dest&quot;)
  If objXMLParent2 is Nothing Then
    Call Reporter.ReportEvent(micFail, &quot;CreateChildElementByName&quot;, &quot;&quot;)
  End If
  Set objXMLParent2 = CopyChildElements(objXMLParent, objXMLParent2)
  Set objXMLNode = ChildElementByName(objXMLParent2, &quot;Macro&quot;) 
  If objXMLNode is Nothing Then
    Call Reporter.ReportEvent(micFail, &quot;ChildElementByName&quot;, &quot;&quot;)
  End If
  If objXMLNode.BaseName &lt;&gt; &quot;Macro&quot; Then
    Call Reporter.ReportEvent(micFail, &quot;ChildElementByName&quot;, &quot;&quot;)
  End If
  If objXMLNode.Text &lt;&gt; &quot;macro node 1&quot; Then
    Call Reporter.ReportEvent(micFail, &quot;ChildElementByName&quot;, &quot;&quot;)
  End If
  Set objXMLNode = ChildElementByName(objXMLParent, &quot;Macro&quot;) 
  If objXMLNode is Nothing Then
    Call Reporter.ReportEvent(micFail, &quot;ChildElementByName&quot;, &quot;&quot;)
  End If
  If objXMLNode.BaseName &lt;&gt; &quot;Macro&quot; Then
    Call Reporter.ReportEvent(micFail, &quot;ChildElementByName&quot;, &quot;&quot;)
  End If
  If objXMLNode.Text &lt;&gt; &quot;macro node 1&quot; Then
    Call Reporter.ReportEvent(micFail, &quot;ChildElementByName&quot;, &quot;&quot;)
  End If
</pre>
<div id="crp_related"><h3>Related Posts:</h3><ul><li><a href="http://automation-beyond.com/2008/06/30/service-functions-msxmldom/" rel="bookmark" class="crp_title">Service Functions &#8211; MSXMLDOM (QTP, TestComplete, VBScript)</a></li><li><a href="http://automation-beyond.com/2009/01/09/service-functions-dictionary/" rel="bookmark" class="crp_title">Service Functions – Dictionary (QTP, TestComplete, VBScript)</a></li><li><a href="http://automation-beyond.com/2011/07/20/xmlnodeset2dictionary/" rel="bookmark" class="crp_title">XMLNodeSet2Dictionary (QTP, TestComplete, VBScript)</a></li><li><a href="http://automation-beyond.com/2008/08/05/p_getxmlelementattrtext/" rel="bookmark" class="crp_title">p_GetXMLElementAttrText (QTP, TestComplete, VBScript)</a></li><li><a href="http://automation-beyond.com/2008/08/06/p_setxmlelementattrtext/" rel="bookmark" class="crp_title">p_SetXMLElementAttrText (QTP, TestComplete, VBScript)</a></li></ul></div>
]]></content:encoded>
			<wfw:commentRss>http://automation-beyond.com/2011/12/08/copychildelements/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>MoveChildElements (QTP, TestComplete, VBScript)</title>
		<link>http://automation-beyond.com/2011/12/06/movechildelements/</link>
		<comments>http://automation-beyond.com/2011/12/06/movechildelements/#comments</comments>
		<pubDate>Tue, 06 Dec 2011 10:21:22 +0000</pubDate>
		<dc:creator>Albert Gareev</dc:creator>
				<category><![CDATA[Source code]]></category>
		<category><![CDATA[XML Data]]></category>
		<category><![CDATA[Child]]></category>
		<category><![CDATA[code]]></category>
		<category><![CDATA[copy]]></category>
		<category><![CDATA[depth]]></category>
		<category><![CDATA[document]]></category>
		<category><![CDATA[DOM]]></category>
		<category><![CDATA[elements]]></category>
		<category><![CDATA[Example]]></category>
		<category><![CDATA[function]]></category>
		<category><![CDATA[hierarchy]]></category>
		<category><![CDATA[How]]></category>
		<category><![CDATA[Move]]></category>
		<category><![CDATA[MSXMLDOM]]></category>
		<category><![CDATA[Node]]></category>
		<category><![CDATA[Nodes]]></category>
		<category><![CDATA[processing]]></category>
		<category><![CDATA[QTP]]></category>
		<category><![CDATA[sample]]></category>
		<category><![CDATA[snippet]]></category>
		<category><![CDATA[Test Automation]]></category>
		<category><![CDATA[testcomplete]]></category>
		<category><![CDATA[to]]></category>
		<category><![CDATA[VBScript]]></category>
		<category><![CDATA[XML]]></category>
		<category><![CDATA[XMLDOM]]></category>

		<guid isPermaLink="false">http://automation-beyond.com/?p=4790</guid>
		<description><![CDATA[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     [...]]]></description>
			<content:encoded><![CDATA[
<div class="topsy_widget_data topsy_theme_blue" style="float: right;margin-left: 0.75em; background: url(data:,%7B%20%22url%22%3A%20%22http%253A%252F%252Fautomation-beyond.com%252F2011%252F12%252F06%252Fmovechildelements%252F%22%2C%20%22shorturl%22%3A%20%22http%3A%2F%2Fbit.ly%2Fs5t46r%22%2C%20%22style%22%3A%20%22big%22%2C%20%22title%22%3A%20%22MoveChildElements%20%28QTP%2C%20TestComplete%2C%20VBScript%29%22%20%7D);"></div>
<p>Parent page: <a title="Service Functions – MSXMLDOM (QTP, TestComplete, VBScript)" href="http://automation-beyond.com/2008/06/30/service-functions-msxmldom/" target="_blank">Service Functions – MSXMLDOM (QTP, TestComplete, VBScript)</a><br />
<div style="position: relative; z-index:1;"><script type="text/javascript"><!--
google_ad_client = "pub-4470793787913935";
/* Banner 468x60 */
google_ad_slot = "8933038987";
google_ad_width = 468;
google_ad_height = 60;
//-->
</script>
<script type="text/javascript"
src="http://pagead2.googlesyndication.com/pagead/show_ads.js">
</script></div> </p>
<h4>Description</h4>
<p>Move all child elements (and attributes, comments, text nodes) from one XML node to another. </p>
<h4>Implementation</h4>
<p><script type="text/javascript"><!--
google_ad_client = "pub-4470793787913935";
/* 4 links text line */
google_ad_slot = "5367351963";
google_ad_width = 468;
google_ad_height = 15;
//-->
</script>
<script type="text/javascript"
src="http://pagead2.googlesyndication.com/pagead/show_ads.js">
</script></p>
<pre class="brush: vb; title: ;">

Public Function MoveChildElements(ByRef objXMLSrc, ByRef objXMLDest)

   If objXMLSrc is Nothing Then
    Set MoveChildElements = objXMLDest
    Exit Function
   End If

   If objXMLDest is Nothing Then
    Set objXMLDest = objXMLSrc.CloneNode(False)
   End If

   While Not (objXMLSrc.FirstChild is Nothing)
    Call objXMLDest.AppendChild(objXMLSrc.FirstChild)
   Wend

   Set MoveChildElements = objXMLDest

End Function
</pre>
<h4>Test Code</h4>
<pre class="brush: vb; title: ;">

  Set objXMLDoc = CreateXMLDOM(&quot;test&quot;)
  Set objXMLParent = CreateChildElementByName(objXMLDoc.DocumentElement, &quot;Modules&quot;, &quot;modules parent node&quot;)
  If objXMLParent is Nothing Then
    Call Reporter.ReportEvent(micFail, &quot;CreateChildElementByName&quot;, &quot;&quot;)
  End If
  Set objXMLNode = CreateChildElementByName(objXMLParent, &quot;Macro&quot;, &quot;macro node 1&quot;)
  If objXMLNode is Nothing Then
    Call Reporter.ReportEvent(micFail, &quot;CreateChildElementByName&quot;, &quot;&quot;)
  End If
  Set objXMLNode = CreateChildElementByName(objXMLParent, &quot;Macro&quot;, &quot;macro node 2&quot;)
  If objXMLNode is Nothing Then
    Call Reporter.ReportEvent(micFail, &quot;CreateChildElementByName&quot;, &quot;&quot;)
  End If
  Set objXMLNode = CreateChildElementByName(objXMLParent, &quot;Macro&quot;, &quot;macro node 3&quot;)
  If objXMLNode is Nothing Then
    Call Reporter.ReportEvent(micFail, &quot;CreateChildElementByName&quot;, &quot;&quot;)
  End If

  sText = &quot;&lt;root&gt;text&lt;/root&gt;&quot;
  Set objXMLDoc2 = CreateXMLDOMFromString(sText)
  If objXMLDoc2 is Nothing Then
    Call Reporter.ReportEvent(micFail, &quot;CreateXMLDOMFromString&quot;, &quot;&quot;)
  End If
  Set objXMLParent2 = CreateChildElementByName(objXMLDoc2.DocumentElement, &quot;Modules&quot;, &quot;modules parent node dest&quot;)
  If objXMLParent2 is Nothing Then
    Call Reporter.ReportEvent(micFail, &quot;CreateChildElementByName&quot;, &quot;&quot;)
  End If

  Set objXMLParent2 = MoveChildElements(objXMLParent, objXMLParent2)

  Set objXMLNode = ChildElementByName(objXMLParent2, &quot;Macro&quot;) 
  If objXMLNode is Nothing Then
    Call Reporter.ReportEvent(micFail, &quot;ChildElementByName&quot;, &quot;&quot;)
  End If
  If objXMLNode.BaseName &lt;&gt; &quot;Macro&quot; Then
    Call Reporter.ReportEvent(micFail, &quot;ChildElementByName&quot;, &quot;&quot;)
  End If
  If objXMLNode.Text &lt;&gt; &quot;macro node 1&quot; Then
    Call Reporter.ReportEvent(micFail, &quot;ChildElementByName&quot;, &quot;&quot;)
  End If

  Set objXMLNode = CreateChildElementByName(objXMLParent, &quot;Macro&quot;, &quot;macro node 1&quot;)
  If objXMLNode is Nothing Then
    Call Reporter.ReportEvent(micFail, &quot;CreateChildElementByName&quot;, &quot;&quot;)
  End If
  Set objXMLNode = CreateChildElementByName(objXMLParent, &quot;Macro&quot;, &quot;macro node 2&quot;)
  If objXMLNode is Nothing Then
    Call Reporter.ReportEvent(micFail, &quot;CreateChildElementByName&quot;, &quot;&quot;)
  End If
  Set objXMLNode = CreateChildElementByName(objXMLParent, &quot;Macro&quot;, &quot;macro node 3&quot;)
  If objXMLNode is Nothing Then
    Call Reporter.ReportEvent(micFail, &quot;CreateChildElementByName&quot;, &quot;&quot;)
  End If

  Set objXMLParent2 = Nothing
  Set objXMLParent2 = MoveChildElements(objXMLParent, objXMLParent2)

  Set objXMLNode = ChildElementByName(objXMLParent2, &quot;Macro&quot;) 
  If objXMLNode is Nothing Then
    Call Reporter.ReportEvent(micFail, &quot;ChildElementByName&quot;, &quot;&quot;)
  End If
  If objXMLNode.BaseName &lt;&gt; &quot;Macro&quot; Then
    Call Reporter.ReportEvent(micFail, &quot;ChildElementByName&quot;, &quot;&quot;)
  End If
  If objXMLNode.Text &lt;&gt; &quot;macro node 1&quot; Then
    Call Reporter.ReportEvent(micFail, &quot;ChildElementByName&quot;, &quot;&quot;)
  End If
</pre>
<div id="crp_related"><h3>Related Posts:</h3><ul><li><a href="http://automation-beyond.com/2008/06/30/service-functions-msxmldom/" rel="bookmark" class="crp_title">Service Functions &#8211; MSXMLDOM (QTP, TestComplete, VBScript)</a></li><li><a href="http://automation-beyond.com/2011/12/08/copychildelements/" rel="bookmark" class="crp_title">CopyChildElements (QTP, TestComplete, VBScript)</a></li><li><a href="http://automation-beyond.com/2009/01/09/service-functions-dictionary/" rel="bookmark" class="crp_title">Service Functions – Dictionary (QTP, TestComplete, VBScript)</a></li><li><a href="http://automation-beyond.com/2011/07/20/xmlnodeset2dictionary/" rel="bookmark" class="crp_title">XMLNodeSet2Dictionary (QTP, TestComplete, VBScript)</a></li><li><a href="http://automation-beyond.com/2008/08/05/p_getxmlelementattrtext/" rel="bookmark" class="crp_title">p_GetXMLElementAttrText (QTP, TestComplete, VBScript)</a></li></ul></div>
]]></content:encoded>
			<wfw:commentRss>http://automation-beyond.com/2011/12/06/movechildelements/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>How to select random list item (QTP, VBScript)</title>
		<link>http://automation-beyond.com/2011/11/24/how-to-select-random-list-item/</link>
		<comments>http://automation-beyond.com/2011/11/24/how-to-select-random-list-item/#comments</comments>
		<pubDate>Thu, 24 Nov 2011 10:36:55 +0000</pubDate>
		<dc:creator>Albert Gareev</dc:creator>
				<category><![CDATA[How to]]></category>
		<category><![CDATA[Source code]]></category>
		<category><![CDATA[Web]]></category>
		<category><![CDATA[code]]></category>
		<category><![CDATA[Example]]></category>
		<category><![CDATA[How]]></category>
		<category><![CDATA[item]]></category>
		<category><![CDATA[list]]></category>
		<category><![CDATA[pick]]></category>
		<category><![CDATA[QTP]]></category>
		<category><![CDATA[random]]></category>
		<category><![CDATA[rnd]]></category>
		<category><![CDATA[sample]]></category>
		<category><![CDATA[script]]></category>
		<category><![CDATA[select]]></category>
		<category><![CDATA[snippet]]></category>
		<category><![CDATA[source]]></category>
		<category><![CDATA[to]]></category>
		<category><![CDATA[VBScript]]></category>
		<category><![CDATA[WebList]]></category>

		<guid isPermaLink="false">http://automation-beyond.com/?p=4723</guid>
		<description><![CDATA[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: ' &#34;Google Advanced Search&#34; page is up ' &#34;Results per page&#34; WebList exists and enabled 'Get page object Set objPage = Browser(&#34;CreationTime:=0&#34;).Page(&#34;title:=Google Advanced Search&#34;) [...]]]></description>
			<content:encoded><![CDATA[
<div class="topsy_widget_data topsy_theme_blue" style="float: right;margin-left: 0.75em; background: url(data:,%7B%20%22url%22%3A%20%22http%253A%252F%252Fautomation-beyond.com%252F2011%252F11%252F24%252Fhow-to-select-random-list-item%252F%22%2C%20%22shorturl%22%3A%20%22http%3A%2F%2Fbit.ly%2Fu8ZG6A%22%2C%20%22style%22%3A%20%22big%22%2C%20%22title%22%3A%20%22How%20to%20select%20random%20list%20item%20%28QTP%2C%20VBScript%29%22%20%7D);"></div>
<p><div style="position: relative; z-index:1;"><script type="text/javascript"><!--
google_ad_client = "pub-4470793787913935";
/* Banner 468x60 */
google_ad_slot = "8933038987";
google_ad_width = 468;
google_ad_height = 60;
//-->
</script>
<script type="text/javascript"
src="http://pagead2.googlesyndication.com/pagead/show_ads.js">
</script></div></p>
<h4>Description </h4>
<p>Get object reference. Get total number of items in the list. Generate an index within the given range. Select item by index.</p>
<h4>Implementation</h4>
<p><script type="text/javascript"><!--
google_ad_client = "pub-4470793787913935";
/* 4 links text line */
google_ad_slot = "5367351963";
google_ad_width = 468;
google_ad_height = 15;
//-->
</script>
<script type="text/javascript"
src="http://pagead2.googlesyndication.com/pagead/show_ads.js">
</script></p>
<pre class="brush: vb; title: ;">

Dim objPage, objList
Dim boolRC
Dim intItemsCount, intRndItem

'Assumptions:
' &quot;Google Advanced Search&quot; page is up
' &quot;Results per page&quot; WebList exists and enabled

'Get page object
Set objPage = Browser(&quot;CreationTime:=0&quot;).Page(&quot;title:=Google Advanced Search&quot;)
boolRC = objPage.Exist(0)
If Not boolRC Then
 ExitTest
End If

'Get list object
Set objList = objPage.WebList(&quot;name:=num&quot;)
boolRC = objList.Exist(0)
If Not boolRC Then
 ExitTest
End If

'Get number of list items
intItemsCount = objList.GetROProperty(&quot;items count&quot;)
'Create random index
Randomize
intRndItem = CInt(Rnd*intItemsCount)
'Select the item
'Note: selection by index is zero-based
objList.Select &quot;#&quot; &amp; intRndItem
</pre>
<div id="crp_related"><h3>Related Posts:</h3><ul><li><a href="http://automation-beyond.com/2007/12/23/custom-lists-winrunner/" rel="bookmark" class="crp_title">Custom lists: Select Multi / Select All with WinRunner</a></li><li><a href="http://automation-beyond.com/2007/11/15/test-log-messages/" rel="bookmark" class="crp_title">Test Log Messages</a></li><li><a href="http://automation-beyond.com/2011/07/19/xmlnode2dictionary/" rel="bookmark" class="crp_title">XMLNode2Dictionary (QTP, TestComplete, VBScript)</a></li><li><a href="http://automation-beyond.com/2009/09/23/gp-automation-vbscript-limitation/" rel="bookmark" class="crp_title">GP/QTP Automation: Overcoming VBScript limitation with Excel macros</a></li><li><a href="http://automation-beyond.com/2010/03/04/manually-get-dexterity-gui-field-names/" rel="bookmark" class="crp_title">How to manually get Dexterity GUI field names</a></li></ul></div>
]]></content:encoded>
			<wfw:commentRss>http://automation-beyond.com/2011/11/24/how-to-select-random-list-item/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>XMLElementDepth (QTP, TestComplete, VBScript)</title>
		<link>http://automation-beyond.com/2011/10/20/xmlelementdepth/</link>
		<comments>http://automation-beyond.com/2011/10/20/xmlelementdepth/#comments</comments>
		<pubDate>Thu, 20 Oct 2011 10:47:42 +0000</pubDate>
		<dc:creator>Albert Gareev</dc:creator>
				<category><![CDATA[Source code]]></category>
		<category><![CDATA[XML Data]]></category>
		<category><![CDATA[Child]]></category>
		<category><![CDATA[code]]></category>
		<category><![CDATA[depth]]></category>
		<category><![CDATA[document]]></category>
		<category><![CDATA[DOM]]></category>
		<category><![CDATA[Example]]></category>
		<category><![CDATA[function]]></category>
		<category><![CDATA[hierarchy]]></category>
		<category><![CDATA[MSXMLDOM]]></category>
		<category><![CDATA[Node]]></category>
		<category><![CDATA[processing]]></category>
		<category><![CDATA[QTP]]></category>
		<category><![CDATA[sample]]></category>
		<category><![CDATA[snippet]]></category>
		<category><![CDATA[Test Automation]]></category>
		<category><![CDATA[testcomplete]]></category>
		<category><![CDATA[VBScript]]></category>
		<category><![CDATA[XML]]></category>
		<category><![CDATA[XMLDOM]]></category>

		<guid isPermaLink="false">http://automation-beyond.com/?p=4149</guid>
		<description><![CDATA[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   XMLElementDepth [...]]]></description>
			<content:encoded><![CDATA[
<div class="topsy_widget_data topsy_theme_blue" style="float: right;margin-left: 0.75em; background: url(data:,%7B%20%22url%22%3A%20%22http%253A%252F%252Fautomation-beyond.com%252F2011%252F10%252F20%252Fxmlelementdepth%252F%22%2C%20%22shorturl%22%3A%20%22http%3A%2F%2Fbit.ly%2FrixjsD%22%2C%20%22style%22%3A%20%22big%22%2C%20%22title%22%3A%20%22XMLElementDepth%20%28QTP%2C%20TestComplete%2C%20VBScript%29%22%20%7D);"></div>
<p>Parent page: <a title="Service Functions – MSXMLDOM (QTP, TestComplete, VBScript)" href="http://automation-beyond.com/2008/06/30/service-functions-msxmldom/" target="_blank">Service Functions – MSXMLDOM (QTP, TestComplete, VBScript)</a></p>
<p><div style="position: relative; z-index:1;"><script type="text/javascript"><!--
google_ad_client = "pub-4470793787913935";
/* Banner 468x60 */
google_ad_slot = "8933038987";
google_ad_width = 468;
google_ad_height = 60;
//-->
</script>
<script type="text/javascript"
src="http://pagead2.googlesyndication.com/pagead/show_ads.js">
</script></div></p>
<h4>Description</h4>
<p>Locate XML node depth within the hierarchy. Valid argument: an XML element node (NODE_ELEMENT type). </p>
<h4>Implementation</h4>
<p><script type="text/javascript"><!--
google_ad_client = "pub-4470793787913935";
/* 4 links text line */
google_ad_slot = "5367351963";
google_ad_width = 468;
google_ad_height = 15;
//-->
</script>
<script type="text/javascript"
src="http://pagead2.googlesyndication.com/pagead/show_ads.js">
</script></p>
<pre class="brush: vb; title: ;">

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
  XMLElementDepth = 0
  Exit Function
 End If

 'NODE_ELEMENT(1)
 If objXMLElement.NodeType &lt;&gt; 1 Then
  XMLElementDepth = -1
  Exit Function
 End If

 intDepth = 0
 Set objXMLNode = objXMLElement
 Do While True
  Set objXMLNode = objXMLNode.parentNode
  intDepth = intDepth + 1
  If objXMLNode.NodeType = 9 Then
   Exit Do
  End If
 Loop

 XMLElementDepth = intDepth

End Function
</pre>
<div id="crp_related"><h3>Related Posts:</h3><ul><li><a href="http://automation-beyond.com/2008/06/30/service-functions-msxmldom/" rel="bookmark" class="crp_title">Service Functions &#8211; MSXMLDOM (QTP, TestComplete, VBScript)</a></li><li><a href="http://automation-beyond.com/2009/01/09/service-functions-dictionary/" rel="bookmark" class="crp_title">Service Functions – Dictionary (QTP, TestComplete, VBScript)</a></li><li><a href="http://automation-beyond.com/2011/07/20/xmlnodeset2dictionary/" rel="bookmark" class="crp_title">XMLNodeSet2Dictionary (QTP, TestComplete, VBScript)</a></li><li><a href="http://automation-beyond.com/2008/08/05/p_getxmlelementattrtext/" rel="bookmark" class="crp_title">p_GetXMLElementAttrText (QTP, TestComplete, VBScript)</a></li><li><a href="http://automation-beyond.com/2008/08/06/p_setxmlelementattrtext/" rel="bookmark" class="crp_title">p_SetXMLElementAttrText (QTP, TestComplete, VBScript)</a></li></ul></div>
]]></content:encoded>
			<wfw:commentRss>http://automation-beyond.com/2011/10/20/xmlelementdepth/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

