<?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/"
	>

<channel>
	<title>Relevant Codes (by Anshoo Arora) &#187; All</title>
	<atom:link href="http://relevantcodes.com/category/all/feed/" rel="self" type="application/rss+xml" />
	<link>http://relevantcodes.com</link>
	<description>A Test Development Resource for HP QuickTest Professional.</description>
	<lastBuildDate>Fri, 30 Dec 2011 07:07:07 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.1.3</generator>
		<item>
		<title>Book Review and Giveaway &#8211; And I Thought I Knew QTP</title>
		<link>http://relevantcodes.com/book-review-and-giveaway-and-i-thought-i-knew-qtp/</link>
		<comments>http://relevantcodes.com/book-review-and-giveaway-and-i-thought-i-knew-qtp/#comments</comments>
		<pubDate>Mon, 26 Sep 2011 16:21:21 +0000</pubDate>
		<dc:creator>Anshoo Arora</dc:creator>
				<category><![CDATA[All]]></category>

		<guid isPermaLink="false">http://relevantcodes.com/?p=4637</guid>
		<description><![CDATA[Review of And I Thought I Knew QTP - a technical novel by Tarun Lalwani. Anshoo Arora (yours truly) had the opportunity to work on this project as the Technical Editor &#038; Reviewer. 3 free copies will be given away to the lucky winners signed by both Tarun and I.]]></description>
			<content:encoded><![CDATA[<p></p><p class="alert">US readers: Order your copy of And I Thought I Knew QTP From <a href="http://www.lulu.com/product/paperback/and-i-thought-i-knew-qtp---qtp-concepts-unplugged/17580430">Lulu</a>.
</p>
<p>
I thought I knew QTP is the only book available that is aimed to explain concepts and theories behind automation using QuickTest Professional. Its quite common to the QTP community to choose an approach provided an issue arises. However, when asked why we choose one particular approach over the other or why an approach works well in a given scenario and fails in another, there are no answers available or poorly drafted ones. This book uncovers the &#8216;why&#8217; by providing ample examples and scenarios.
</p>
<p><a href="http://knowledgeinbox.com/store/index.php?main_page=product_info&#038;cPath=1&#038;products_id=3"><img alt="" src="http://relevantcodes.com/Articles/QTPConceptsUnplugged/front.png" title="And I Thought I Knew QTP - QTP Concepts Unplugged" class="aligncenter" width="323" height="323" /></a></p>
<p>
And I Thought I Knew QTP can be described as a journey of an individual who goes through a series of questions that make him wonder if his QTP skills are as good as he thought they were. The questions are the ones we face on an every day basis to questions we have always wanted to seek answers for. The information made available through this book is written by the world renowned QTP expert, <a href="http://www.linkedin.com/in/tarunlalwani">Tarun Lalwani</a>. This book is written with only one vision in mind &#8211; there should be a formal source that aims to get rid of all misinformation that we see on an every day basis when searching answers to questions involving QTP.
</p>
<p>
Because this book is written in the form of a novel with a simple storyline it is very easy to follow through. So, instead of being a completely technical read, this book can be said to be a &#8220;technical novel&#8221; &#8211; it includes technical concepts by not being boring :)
</p>
<h3>Preview</h3>
<p>
The preview of the book is now available <a href="http://knowledgeinbox.com/demos/AndIThoughtIKnewQTP_Preview.pdf">here</a>.
</p>
<h3>Preorder</h3>
<p>
Go ahead and pre-order this book to make sure you have it before the official launch. Order <a href="http://knowledgeinbox.com/store/index.php?main_page=product_info&#038;cPath=1&#038;products_id=3">HERE</a>.
</p>
<h3>Giveaway (Winners now announced)</h3>
<p>
I will be giving out 1 copy of And I Thought I Knew QTP to one VERY lucky person! :)  All you have do to participate is post a comment in the comments section letting us know that you&#8217;re interested. That&#8217;s all! After a random vote, the winnerS will be declared.  <strong>Update:</strong> <strong>2</strong> more lucky winners (total of 3) will be announced, <a href="http://relevantcodes.com/book-review-and-giveaway-and-i-thought-i-knew-qtp/#comments<br />
">compliments of Tarun</a>.
</p>
<h3>Winners</h3>
<p>
Link to the recorded video: http://www.screenr.com/embed/cXls. Anish Pillai, Priyanka &#038; Suni: congratulations! :)
</p>
<h3>Links</h3>
<p>
Links that you will find helpful to order the book, find information and see the previews. I will be updating this section as more links become available.
</p>
<ul>
<li>US readers: Order your copy of And I Thought I Knew QTP From <a href="http://www.lulu.com/product/paperback/and-i-thought-i-knew-qtp---qtp-concepts-unplugged/17580430">Lulu</a></li>
<li><a href="http://knowledgeinbox.com/store/index.php?main_page=product_info&#038;cPath=1&#038;products_id=3">KnowledgeInbox page</a>
<li><a href="http://www.facebook.com/pages/And-I-thought-I-knew-QTP/165462290204637">Facebook page</a></li>
</ul>
]]></content:encoded>
			<wfw:commentRss>http://relevantcodes.com/book-review-and-giveaway-and-i-thought-i-knew-qtp/feed/</wfw:commentRss>
		<slash:comments>97</slash:comments>
		</item>
		<item>
		<title>Updates</title>
		<link>http://relevantcodes.com/updates-2/</link>
		<comments>http://relevantcodes.com/updates-2/#comments</comments>
		<pubDate>Thu, 04 Aug 2011 00:48:08 +0000</pubDate>
		<dc:creator>Anshoo Arora</dc:creator>
				<category><![CDATA[All]]></category>
		<category><![CDATA[design]]></category>
		<category><![CDATA[Framework]]></category>
		<category><![CDATA[relevantcodes[2]two]]></category>
		<category><![CDATA[Updates]]></category>

		<guid isPermaLink="false">http://relevantcodes.com/?p=4600</guid>
		<description><![CDATA[UI Changes To begin with, if you&#8217;re a regular reader here you will notice that there have been some changes to the post design here. I received an email from a reader who brought the site contrast to my attention which caused difficulty when reading for a long time. Well, the old contract for all [...]]]></description>
			<content:encoded><![CDATA[<p></p><h3>UI Changes</h3>
<p>
To begin with, if you&#8217;re a regular reader here you will notice that there have been some changes to the post design here. I received an email from a reader who brought the site contrast to my attention which caused difficulty when reading for a long time. Well, the old contract for all post-pages is now gone and we have the following changes:
</p>
<ul>
<li>Gray background replaced by white</li>
<li>Code font-family changed from Mono to Consolas</li>
<li>Code background changed from gray to yellow</li>
<li>All floating notes are lighter and easy on the eyes</li>
</ul>
<h3>Next Automation Framework</h3>
<p>
I&#8217;ve done some preliminary work for the upcoming framework and would like it to be data-driven. The biggest challenge has been to find an application on which the framework can run and not hurt it by loading a ton of data to it. Chances are I may create the AUT for this. BUT, if you have something in mind that can be used, please do let me know.
</p>
<h3>Have an idea for an article?</h3>
<p>
If you have an idea for an article, please let us know! I am always looking to write new stuff, but ideas are the hardest to gather. Your help will be much appreciated!
</p>
<h3>Subscribe</h3>
<p>
<a href="http://feedburner.google.com/fb/a/mailverify?uri=RelevantCodes&amp;loc=en_US" ><img src="http://relevantcodes.com/images/email.png" width="32" height="32" alt="Subscribe by Email" /></a><a href="http://feeds.feedburner.com/RelevantCodes" ><img src="http://relevantcodes.com/images/rss_32.png" alt="Subscribe by RSS Feed" /></a>
</p>
<p>
Please help Relevant Codes by becoming a subscriber. Click one of the buttons above to choose your method of receiving updates. Thank you!</p>
]]></content:encoded>
			<wfw:commentRss>http://relevantcodes.com/updates-2/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>IntelliSense for your Custom Class in 6 Steps</title>
		<link>http://relevantcodes.com/intellisense-for-your-custom-class-in-6-steps/</link>
		<comments>http://relevantcodes.com/intellisense-for-your-custom-class-in-6-steps/#comments</comments>
		<pubDate>Thu, 30 Jun 2011 14:48:51 +0000</pubDate>
		<dc:creator>Anshoo Arora</dc:creator>
				<category><![CDATA[.NET]]></category>
		<category><![CDATA[All]]></category>
		<category><![CDATA[QTP]]></category>
		<category><![CDATA[Class Intellisense]]></category>
		<category><![CDATA[COM]]></category>
		<category><![CDATA[Creating Intellisense in QTP]]></category>
		<category><![CDATA[Intellisense]]></category>
		<category><![CDATA[QTP COM Intellisense]]></category>
		<category><![CDATA[QTP Intellisense]]></category>
		<category><![CDATA[QTP Intellisense with .NET]]></category>
		<category><![CDATA[RegAsm]]></category>
		<category><![CDATA[VBC]]></category>

		<guid isPermaLink="false">http://relevantcodes.com/?p=4304</guid>
		<description><![CDATA[I have been researching this topic for a very long time and I finally have a workaround which I have tested for for the last 2 months with great success. The best part about this workaround is, I just need to create wrappers, without including any of the code I have in my QTP function libraries. If I add a new method to my class, all I do to update the Intellisense is add the method (without the QTP code) in my VB lib, create a DLL and Register the library for COM Interop.]]></description>
			<content:encoded><![CDATA[<p></p><p>
I have been using classes in my frameworks for a long time now, and my biggest gripe about QTP is its lack of Intellisense for custom classes. It also happens to be my biggest complaint. I understand this is not high priority for HP to include in its newer versions as there is a very small group of people who use OO techniques in test automation with QTP. There has been another workaround by Yaron, who used WSC to create intellisense.
</p>
<p>
I have been researching this topic for a very long time and I finally have a workaround which I have tested for for the past few weeks with great success. The best part about this workaround is, I just need to create wrappers, without including any of the code I have in my QTP function libraries. If I add a new method to my class, all I do to update the Intellisense is add the method (without the QTP code) in my VB lib, create a DLL and Register the library for COM Interop.
</p>
<p>
Let&#8217;s get working then!
</p>
<h3>Step 1: Create your QTP Modular/Custom/Generic Class</h3>

<div class="wp_syntax"><div class="code"><pre class="vb" style="font-family:consolas, monospace;"><span style="color: #0000A6;">Class</span> LoginClass
&nbsp;
<span style="color: #008000;">'#region Private Variables
</span>    <span style="color: #0000A6;">Private</span> UserName    <span style="color: #008000;">'As String
</span>    <span style="color: #0000A6;">Private</span> UserRole    <span style="color: #008000;">'As String
</span>
<span style="color: #008000;">'#region Public Variables
</span>    <span style="color: #0000A6;">Public</span> PageTitle    <span style="color: #008000;">'As String
</span>    <span style="color: #0000A6;">Public</span> LinksCount   <span style="color: #008000;">'As Integer
</span>    
<span style="color: #008000;">'#region Public Methods
</span>    <span style="color: #0000A6;">Public</span> <span style="color: #0000A6;">Sub</span> CheckLinks()
        <span style="color: #0000A6;">Dim</span> arrLinks
&nbsp;
        arrLinks = Array(<span style="color: #800000;">&quot;Home&quot;</span>, <span style="color: #800000;">&quot;Register&quot;</span>, <span style="color: #800000;">&quot;Language&quot;</span>, <span style="color: #800000;">&quot;Sign-In&quot;</span>)
&nbsp;
        <span style="color: #0000A6;">Call</span> FunctionToCheckLinks(arrLinks)
    <span style="color: #0000A6;">End</span> <span style="color: #0000A6;">Sub</span>
&nbsp;
    <span style="color: #0000A6;">Public</span> <span style="color: #0000A6;">Function</span> IsPageFound() <span style="color: #008000;">'As Boolean
</span>        <span style="color: #0000A6;">If</span> Browser(<span style="color: #800000;">&quot;title:=MyApp&quot;</span>).Exist(15) <span style="color: #0000A6;">Then</span> IsPageFound = <span style="color: #0000A6;">True</span>
    <span style="color: #0000A6;">End</span> <span style="color: #0000A6;">Function</span>
&nbsp;
<span style="color: #008000;">'#region Class Constructor &amp; Destructor
</span>    <span style="color: #0000A6;">Private</span> <span style="color: #0000A6;">Sub</span> Class_Initialize()
        UserName = <span style="color: #800000;">&quot;test&quot;</span>
        UserRole = Global.UserRole
    <span style="color: #0000A6;">End</span> <span style="color: #0000A6;">Sub</span>
&nbsp;
    <span style="color: #0000A6;">Private</span> <span style="color: #0000A6;">Sub</span> Class_Terminate
        <span style="color: #008000;">'code
</span>    <span style="color: #0000A6;">End</span> <span style="color: #0000A6;">Sub</span>
&nbsp;
<span style="color: #0000A6;">End</span> <span style="color: #0000A6;">Class</span>
&nbsp;
<span style="color: #0000A6;">Public</span> LoginX: <span style="color: #0000A6;">Set</span> LoginX = <span style="color: #0000A6;">New</span> LoginClass</pre></div></div>

<h3>Step 2: Converting QTP Class into VB.NET code</h3>
<p>
The next step is converting the method and property names to VB.NET. If you have never used VB.NET, don&#8217;t be scared! The syntax is quite straight-forward. The only thing to note here is, you must return values for Functions and Property Get. Also, the syntax of the Property construct differs slightly in VB.NET. Still, all you are including here are the names. You do NOT have to add the code from your QTP methods.
</p>
<p class="alert">Always remember to include the <strong>Microsoft.VisualBasic.ComClass()</strong> flag before the class, and also, remember to make the class <strong>Public</strong></p>
<p class="alert">All that goes in the VB.NET code are the names of the properties and methods. Do not include any QTP code here!</p>
<p>
Below is a conversion of the QTP code above, to VB.NET. Notice that I have not included any of the code from my QTP class here:
</p>
<h5>Save the converted code in a .VB format file</h5>

<div class="wp_syntax"><div class="code"><pre class="vb" style="font-family:consolas, monospace;">Namespace RelevantCodes
    &lt;Microsoft.VisualBasic.ComClass()&gt; <span style="color: #0000A6;">Public</span> <span style="color: #0000A6;">Class</span> LoginClass
&nbsp;
        <span style="color: #0000A6;">Public</span> <span style="color: #0000A6;">Property</span> PageTitle <span style="color: #0000A6;">As</span> <span style="color: #0000A6;">String</span>
            <span style="color: #0000A6;">Get</span>
                return <span style="color: #800000;">&quot;title&quot;</span>
            <span style="color: #0000A6;">End</span> <span style="color: #0000A6;">Get</span>
            <span style="color: #0000A6;">Set</span>(<span style="color: #0000A6;">ByVal</span> value <span style="color: #0000A6;">As</span> <span style="color: #0000A6;">String</span>)
                <span style="color: #008000;">'code
</span>            <span style="color: #0000A6;">End</span> <span style="color: #0000A6;">Set</span>
        <span style="color: #0000A6;">End</span> <span style="color: #0000A6;">Property</span>
&nbsp;
        <span style="color: #0000A6;">Public</span> <span style="color: #0000A6;">Property</span> LinksCount <span style="color: #0000A6;">As</span> <span style="color: #0000A6;">Integer</span>
            <span style="color: #0000A6;">Get</span>
                return 10
            <span style="color: #0000A6;">End</span> <span style="color: #0000A6;">Get</span>
            <span style="color: #0000A6;">Set</span>(<span style="color: #0000A6;">ByVal</span> value <span style="color: #0000A6;">As</span> <span style="color: #0000A6;">Integer</span>)
            <span style="color: #0000A6;">End</span> <span style="color: #0000A6;">Set</span>
        <span style="color: #0000A6;">End</span> <span style="color: #0000A6;">Property</span>
&nbsp;
        <span style="color: #0000A6;">Public</span> <span style="color: #0000A6;">Sub</span> CheckLinks()
        <span style="color: #0000A6;">End</span> <span style="color: #0000A6;">Sub</span>
&nbsp;
        <span style="color: #0000A6;">Public</span> <span style="color: #0000A6;">Function</span> IsPageFound() <span style="color: #0000A6;">As</span> <span style="color: #0000A6;">Boolean</span>
        <span style="color: #0000A6;">End</span> <span style="color: #0000A6;">Function</span>
&nbsp;
    <span style="color: #0000A6;">End</span> <span style="color: #0000A6;">Class</span>
<span style="color: #0000A6;">End</span> Namespace</pre></div></div>

<p>
Also remember that, your <strong>Public variables</strong> become <strong>Public Properties</strong> in VB.NET.
</p>
<h3>Step 3: Creating DLL from VB.NET Class using VBC.exe</h3>
<p>
Once our class is ready and we have saved it in <code>.vb</code> format, let&#8217;s create the DLL using VB&#8217;s command line compiler <code>VBC</code. To understand more about VBC, you can use the "VBC.exe /help" in your command prompt to see a full list of commands available. Using the <code>/target:library</code> creates a .NET code library (DLL), which is what we&#8217;re looking for.
</p>
<pre>
C:\windows\Microsoft.NET\Framework\v2.0.50727\vbc.exe /target:library c:\RelevantCodes.vb
</pre>
<p>
Executing the above syntax in cmd.exe will create a DLL file: RelevantCodes.DLL.
</p>
<p class="alert">The path to your VBC.exe file may be different than the one I have used.</p>
<h3>Step 4: Registering Class using RegAsm.exe</h3>
<p>
Next, we will use the .NET assembly registration tool RegAsm.exe that reads the metadata within an assembly (which we created using VBC.exe) and adds the necessary values to your registry. RegAsm.exe syntax: <code>regasm assemblyFile [options]</code>.
</p>
<pre>
C:\windows\Microsoft.NET\Framework\v2.0.50727\regasm.exe c:\Relevantcodes.dll /codebase
</pre>
<p>
If QTP is already open, save all your tests and resources with libraries and re-open it. Launch it, and use CreateObject to create an instance of your class to see if its working. The syntax will be:
</p>

<div class="wp_syntax"><div class="code"><pre class="vb" style="font-family:consolas, monospace;"><span style="color: #0000A6;">Set</span> InstanceName = <span style="color: #0000A6;">CreateObject</span>(<span style="color: #800000;">&quot;Namespace.Class&quot;</span>)
&nbsp;
<span style="color: #008000;">'for our class:
</span><span style="color: #0000A6;">Set</span> LoginX = <span style="color: #0000A6;">CreateObject</span>(<span style="color: #800000;">&quot;RelevantCodes.LoginClass&quot;</span>)</pre></div></div>

<p><img alt="" src="http://relevantcodes.com/Articles/ClassIntellisense/CreateObject.png" title="CreateObject" class="aligncenter" /></p>
<p>
You must see Intellisense for the instance to ensure everything has been a success until now. If this works, rest is just adding a few values to Registry and we&#8217;re done!
</p>
<h3>Step 5: Adding the Class Reference as a QTP Reserved Word</h3>
<p>
If the above works, <b>we&#8217;re almost done!</b> To get the intellisense for your class, we need to navigate to the registry key below and add a few values to the new key you create. Navigate to the following key in regedit.exe:
</p>
<pre>
HKEY_CURRENT_USER\Software\Mercury Interactive\QuickTest Professional\MicTest\ReservedObjects\
</pre>
<p>
If the above tree does not exist, try this:
</p>
<pre>
HKEY_LOCAL_MACHINE\Software\Mercury Interactive\QuickTest Professional\MicTest\ReservedObjects\
</pre>
<p>
Once you&#8217;re there, add a new key under reserved objects. You can give this key any name. What I generally do is, I give the same name as my QTP class. My key, then, becomes <strong>LoginClass</strong>. Once the key is created, I create the following entries in the key: ProgID (string), UIName (string) and VisibleMode (DWord).
</p>
<pre>
<b>New Key in \ReservedObjects:</b> Name of your QTP Class

<b>String:</b> ProgID,      <b>Value</b>: Namespace.ClassName
<b>String:</b> UIName,      <b>Value</b>: Name of your reference for your custom QTP class
<b>DWord:</b>  VisibleMode, <b>Value</b>: 2
</pre>
<p>
Therefore, in our case, considering the above, we will have the following values:
</p>
<pre>
<b>New Key in \ReservedObjects:</b> LoginClass

<b>String:</b> ProgID,      <b>Value</b>: RelevantCodes.LoginClass
<b>String:</b> UIName,      <b>Value</b>: LoginX
<b>DWord:</b>  VisibleMode, <b>Value</b>: 2
</pre>
<table style='margin-left:auto; margin-right:auto;'>
<tr>
<td><img alt="" src="http://relevantcodes.com/Articles/ClassIntellisense/ProgID.png" title="ProgID" class="alignleft" /><img alt="" src="http://relevantcodes.com/Articles/ClassIntellisense/UIName.png" title="UIName" class="alignleft" /></td>
</tr>
</table>
<p><img alt="" src="http://relevantcodes.com/Articles/ClassIntellisense/VisibleMode.png" title="VisibleMode" class="aligncenter" /></p>
<p>
The final output of adding the key and all entries to it must look like below:
</p>
<p><img alt="" src="http://relevantcodes.com/Articles/ClassIntellisense/AllRegValues.png" title="All Registry Values" class="aligncenter" /></p>
<h3>Step 6: Reference the Class Instance with another Keyword</h3>
<p>
Lastly, all you need to do now is add a new variable and reference your Class Instance with it (as shown by <strong>Login</strong> below):
</p>
<pre>
Public LoginX: Set LoginX = New LoginClass
Public Login : Set Login = LoginX
</pre>
<p><img alt="" src="http://relevantcodes.com/Articles/ClassIntellisense/QTLib.png" title="QTP Library" class="aligncenter" /></p>
<p>
To create your tests and to get Intellisense, remember to associate your library with the test and use the <strong>Login</strong> keyword to see the intellisense.
</p>
<p><img alt="" src="http://relevantcodes.com/Articles/ClassIntellisense/QTTest.png" title="QTP Test with Intellisense" class="aligncenter" /></p>
<h3>I need to add a new method to my existing class. How do I do that!?!!</h3>
<p>
Well, once you converted the code for your original VB.NET library, DO NOT delete it. Once you add a new Public method to your QTP class, just add it to your VB.NET code, create (update) DLL using VBC.exe and re-register it using RegAsm. The new methods will now be available.
</p>
<h3>Summary</h3>
<p>
In summary, you have to follow the below 6 steps to create Intellisense for your custom QTP class:
</p>
<ol>
<li>Create your QTP class</li>
<li>Convert &#8220;Public&#8221; QTP methods to VB.NET (only the method names required!)</li>
<ul>
<li>Public Class</li>
<li>Microsoft.VisualBasic.ComClass() attribute</li>
</ul>
<li>Use VBC.exe to create .NET library</li>
<ul>
<li>Creates a DLL in the same location as the .VB file</li>
</ul>
<li>Use RegAsm.exe Assembly Registration tool to add necessary values to Registry</li>
<li>Add the Class Instance as a Reserved word in Registry</li>
<li>Reference the class with another Keyword</li>
</ol>
<p>
I hope you will find this helpful. As always, thanks for visiting Relevant Codes :)
</p>
<p class="info">
A lot of time and effort has been put into this article, to research and to test it. The information here is available absolutely free of cost. If you like this article, and if it works for you, please make a donation to a charity of your choice. There is no way we will be able to check if you did, but we know you will. There is a lot of on-going crisis today, and your donation will only help. Thank you.</p>
]]></content:encoded>
			<wfw:commentRss>http://relevantcodes.com/intellisense-for-your-custom-class-in-6-steps/feed/</wfw:commentRss>
		<slash:comments>24</slash:comments>
		</item>
		<item>
		<title>Get Row/Column Of An Object in a WebTable</title>
		<link>http://relevantcodes.com/get-rowcolumn-of-an-object-in-a-webtable/</link>
		<comments>http://relevantcodes.com/get-rowcolumn-of-an-object-in-a-webtable/#comments</comments>
		<pubDate>Mon, 27 Jun 2011 05:03:28 +0000</pubDate>
		<dc:creator>Anshoo Arora</dc:creator>
				<category><![CDATA[All]]></category>
		<category><![CDATA[QTP]]></category>
		<category><![CDATA[QTP/Web]]></category>
		<category><![CDATA[cellIndex]]></category>
		<category><![CDATA[CellInfo]]></category>
		<category><![CDATA[Column]]></category>
		<category><![CDATA[DOM]]></category>
		<category><![CDATA[Object inside Table]]></category>
		<category><![CDATA[QTP Object inside WebTable]]></category>
		<category><![CDATA[Row]]></category>
		<category><![CDATA[rowIndex]]></category>
		<category><![CDATA[td]]></category>
		<category><![CDATA[tr]]></category>

		<guid isPermaLink="false">http://relevantcodes.com/?p=4218</guid>
		<description><![CDATA[This article shows a simple way of finding out in which cell a QTP's Test Object resides.]]></description>
			<content:encoded><![CDATA[<p></p><p>
This article shows a simple way of finding out in which cell a QTP&#8217;s Test Object resides. I find the method shown in this article a more effective and faster way of finding the cell I&#8217;m looking for. I have found that this method performs better than traversing rows/cells of a WebTable using in-built WebTable methods such as ChildItem, ChildItemCount and GetCellData. Also, for test objects, it is also not possible to find an exact match with the methods provided for WebTable &#8211; it is only possible for strings.
</p>
<p>
A workaround to find objects inside WebTable using DOM table/tr/td is shown in this article. The code snippets below show how to retrieve the row and column of a given object from a WebTable.
</p>
<p>
Consider the element &#8220;Doe&#8221; in the table below. We can visually see that the link is in the 5th row (starting at the heading) and the 3rd column.
</p>
<table border='1' style='margin-left:auto; margin-right:auto;'>
<tr>
<td style='padding:5px;'>ID</td>
<td style='padding:5px;'>First Name</td>
<td style='padding:5px;'>Last Name</td>
<td style='padding:5px;'>Gender</td>
<td style='padding:5px;'>Attending class?</td>
</tr>
<tr>
<td style='padding:5px;'>12345</td>
<td style='padding:5px;'>John</td>
<td style='padding:5px;'>Smith</td>
<td style='padding:5px;'>M</td>
<td style='padding:5px;'>
<input type='checkbox' name='attending'></td>
</tr>
<tr>
<td style='padding:5px;'>12346</td>
<td style='padding:5px;'>Anne</td>
<td style='padding:5px;'>Johnson</td>
<td style='padding:5px;'>F</td>
<td style='padding:5px;'>
<input type='checkbox' name='attending'></td>
</tr>
<tr>
<td style='padding:5px;'>12347</td>
<td style='padding:5px;'>Adam</td>
<td style='padding:5px;'>Roberts</td>
<td style='padding:5px;'>M</td>
<td style='padding:5px;'>
<input type='checkbox' name='attending'></td>
</tr>
<tr>
<td style='padding:5px;'>12348</td>
<td style='padding:5px;'>Mary</td>
<td style='padding:5px;'>Doe</td>
<td style='padding:5px;'>F</td>
<td style='padding:5px;'>
<input type='checkbox' name='attending'></td>
</tr>
<tr>
<td style='padding:5px;'>12349</td>
<td style='padding:5px;'>Tiffany</td>
<td style='padding:5px;'>Smith</td>
<td style='padding:5px;'>F</td>
<td style='padding:5px;'>
<input type='checkbox' name='attending'></td>
</tr>
</table>
<p>&nbsp;</p>
<p>
Executing the following code will provide us our expected output:
</p>
<pre>
Set element = Browser("creationtime:=0").WebElement("innertext:=Doe", "index:=0")

MsgBox "Row# " &#038; element.GetRow()
MsgBox "Col# " &#038; element.GetColumn()
</pre>
<table style='margin-left: auto; margin-right: auto;'>
<tr>
<td><img alt="" src="http://relevantcodes.com/Articles/FindTableCellFromObject/row.png" title="Row Output" class="alignnone" width="154" height="154" /></td>
<td><img alt="" src="http://relevantcodes.com/Articles/FindTableCellFromObject/column.png" title="Column Output" class="alignnone" width="154" height="154" /></td>
</tr>
</table>
<p>
The above example uses WebElement, but <strong>this approach works for all Web objects.</strong> Similarly, the code for finding the 2nd WebCheckBox for Anne Johnson will give us:  <code>Row# 3</code> and <code>Column#5</code> with the following code:
</p>
<pre>
MsgBox Browser("creationtime:=0").WebCheckBox("name:=attending", "index:=1").GetRow
MsgBox Browser("creationtime:=0").WebCheckBox("name:=attending", "index:=1").GetColumn
</pre>
<h2>The Code</h2>
<p>
The following two methods can be used directly for the object and will retrieve &#8216;either&#8217; the row or the column. The below method retrieves the Row for an object residing in a WebTable:
</p>
<h5>Find Row of the Object from WebTable</h5>

<div class="wp_syntax"><div class="code"><pre class="vb" style="font-family:consolas, monospace;"><span style="color: #0000A6;">Function</span> GetRow(<span style="color: #0000A6;">ByVal</span> TObject)
    GetRow = -1
&nbsp;
    <span style="color: #0000A6;">Set</span> TObject = TObject.<span style="color: #0000A6;">Object</span>
&nbsp;
    <span style="color: #0000A6;">Do</span>
        <span style="color: #0000A6;">If</span> TObject.nodeName = <span style="color: #800000;">&quot;TR&quot;</span> <span style="color: #0000A6;">Then</span>
            GetRow = TObject.rowIndex + 1
            <span style="color: #0000A6;">Exit</span> <span style="color: #0000A6;">Function</span>
        <span style="color: #0000A6;">End</span> <span style="color: #0000A6;">If</span>
&nbsp;
        <span style="color: #0000A6;">Set</span> TObject = TObject.parentNode
    <span style="color: #0000A6;">Loop</span> <span style="color: #0000A6;">Until</span> TObject.nodeName = <span style="color: #800000;">&quot;HTML&quot;</span>
<span style="color: #0000A6;">End</span> <span style="color: #0000A6;">Function</span>
&nbsp;
RegisterUserFunc <span style="color: #800000;">&quot;Image&quot;</span>, <span style="color: #800000;">&quot;GetRow&quot;</span>, <span style="color: #800000;">&quot;GetRow&quot;</span>
RegisterUserFunc <span style="color: #800000;">&quot;Link&quot;</span>, <span style="color: #800000;">&quot;GetRow&quot;</span>, <span style="color: #800000;">&quot;GetRow&quot;</span>
RegisterUserFunc <span style="color: #800000;">&quot;WebEdit&quot;</span>, <span style="color: #800000;">&quot;GetRow&quot;</span>, <span style="color: #800000;">&quot;GetRow&quot;</span>
RegisterUserFunc <span style="color: #800000;">&quot;WebList&quot;</span>, <span style="color: #800000;">&quot;GetRow&quot;</span>, <span style="color: #800000;">&quot;GetRow&quot;</span>
RegisterUserFunc <span style="color: #800000;">&quot;WebCheckBox&quot;</span>, <span style="color: #800000;">&quot;GetRow&quot;</span>, <span style="color: #800000;">&quot;GetRow&quot;</span>
RegisterUserFunc <span style="color: #800000;">&quot;WebElement&quot;</span>, <span style="color: #800000;">&quot;GetRow&quot;</span>, <span style="color: #800000;">&quot;GetRow&quot;</span>
RegisterUserFunc <span style="color: #800000;">&quot;WebRadioGroup&quot;</span>, <span style="color: #800000;">&quot;GetRow&quot;</span>, <span style="color: #800000;">&quot;GetRow&quot;</span></pre></div></div>

<h5>Example</h5>
<pre>
MsgBox Browser("title:=myBrowser").Link("innertext:=myLink", "index:=1").GetRow
</pre>
<p>
This method returns the column of the object inside a WebTable:
</p>
<h5>Find Column of the Object from WebTable</h5>

<div class="wp_syntax"><div class="code"><pre class="vb" style="font-family:consolas, monospace;"><span style="color: #0000A6;">Function</span> GetColumn(<span style="color: #0000A6;">ByVal</span> TObject)
    GetColumn = -1
&nbsp;
    <span style="color: #0000A6;">Set</span> TObject = TObject.<span style="color: #0000A6;">Object</span>
&nbsp;
    <span style="color: #0000A6;">Do</span>
        <span style="color: #0000A6;">If</span> TObject.nodeName = <span style="color: #800000;">&quot;TD&quot;</span> <span style="color: #0000A6;">Then</span>
            GetColumn = TObject.cellIndex + 1
            <span style="color: #0000A6;">Exit</span> <span style="color: #0000A6;">Function</span>
        <span style="color: #0000A6;">End</span> <span style="color: #0000A6;">If</span>
&nbsp;
        <span style="color: #0000A6;">Set</span> TObject = TObject.parentNode
    <span style="color: #0000A6;">Loop</span> <span style="color: #0000A6;">Until</span> TObject.nodeName = <span style="color: #800000;">&quot;HTML&quot;</span>
<span style="color: #0000A6;">End</span> <span style="color: #0000A6;">Function</span>
&nbsp;
RegisterUserFunc <span style="color: #800000;">&quot;Image&quot;</span>, <span style="color: #800000;">&quot;GetColumn&quot;</span>, <span style="color: #800000;">&quot;GetColumn&quot;</span>
RegisterUserFunc <span style="color: #800000;">&quot;Link&quot;</span>, <span style="color: #800000;">&quot;GetColumn&quot;</span>, <span style="color: #800000;">&quot;GetColumn&quot;</span>
RegisterUserFunc <span style="color: #800000;">&quot;WebEdit&quot;</span>, <span style="color: #800000;">&quot;GetColumn&quot;</span>, <span style="color: #800000;">&quot;GetColumn&quot;</span>
RegisterUserFunc <span style="color: #800000;">&quot;WebList&quot;</span>, <span style="color: #800000;">&quot;GetColumn&quot;</span>, <span style="color: #800000;">&quot;GetColumn&quot;</span>
RegisterUserFunc <span style="color: #800000;">&quot;WebCheckBox&quot;</span>, <span style="color: #800000;">&quot;GetColumn&quot;</span>, <span style="color: #800000;">&quot;GetColumn&quot;</span>
RegisterUserFunc <span style="color: #800000;">&quot;WebElement&quot;</span>, <span style="color: #800000;">&quot;GetColumn&quot;</span>, <span style="color: #800000;">&quot;GetColumn&quot;</span>
RegisterUserFunc <span style="color: #800000;">&quot;WebRadioGroup&quot;</span>, <span style="color: #800000;">&quot;GetColumn&quot;</span>, <span style="color: #800000;">&quot;GetColumn&quot;</span></pre></div></div>

<h5>Example</h5>
<pre>
MsgBox Browser("title:=myBrowser").Link("innertext:=myLink", "index:=1").GetColumn
</pre>
<p>
The below implementation retrieves both row and column as a Scripting.Dictionary.
</p>
<h5>Find Row &#038; Column Info as Scripting.Dictionary</h5>

<div class="wp_syntax"><div class="code"><pre class="vb" style="font-family:consolas, monospace;"><span style="color: #0000A6;">Function</span> CellInfo(<span style="color: #0000A6;">ByVal</span> TObject)
    <span style="color: #0000A6;">Dim</span> dic
&nbsp;
    <span style="color: #0000A6;">Set</span> dic = <span style="color: #0000A6;">CreateObject</span>(<span style="color: #800000;">&quot;Scripting.Dictionary&quot;</span>)
    dic.Add <span style="color: #800000;">&quot;row&quot;</span>, -1
    dic.Add <span style="color: #800000;">&quot;col&quot;</span>, -1
&nbsp;
    <span style="color: #0000A6;">Set</span> TObject = TObject.<span style="color: #0000A6;">Object</span>
&nbsp;
    <span style="color: #0000A6;">Do</span>
        <span style="color: #0000A6;">If</span> TObject.nodeName = <span style="color: #800000;">&quot;TD&quot;</span> <span style="color: #0000A6;">Then</span> dic(<span style="color: #800000;">&quot;col&quot;</span>) = TObject.cellIndex + 1
&nbsp;
        <span style="color: #0000A6;">If</span> TObject.nodeName = <span style="color: #800000;">&quot;TR&quot;</span> <span style="color: #0000A6;">Then</span>
            dic(<span style="color: #800000;">&quot;row&quot;</span>) = TObject.rowIndex + 1
            <span style="color: #0000A6;">Exit</span> <span style="color: #0000A6;">Do</span>
        <span style="color: #0000A6;">End</span> <span style="color: #0000A6;">If</span>
&nbsp;
        <span style="color: #0000A6;">Set</span> TObject = TObject.parentNode
    <span style="color: #0000A6;">Loop</span> <span style="color: #0000A6;">Until</span> TObject.nodeName = <span style="color: #800000;">&quot;HTML&quot;</span>
&nbsp;
    <span style="color: #0000A6;">Set</span> CellInfo = dic
<span style="color: #0000A6;">End</span> <span style="color: #0000A6;">Function</span>
&nbsp;
RegisterUserFunc <span style="color: #800000;">&quot;Image&quot;</span>, <span style="color: #800000;">&quot;CellInfo&quot;</span>, <span style="color: #800000;">&quot;CellInfo&quot;</span>
RegisterUserFunc <span style="color: #800000;">&quot;Link&quot;</span>, <span style="color: #800000;">&quot;CellInfo&quot;</span>, <span style="color: #800000;">&quot;CellInfo&quot;</span>
RegisterUserFunc <span style="color: #800000;">&quot;WebEdit&quot;</span>, <span style="color: #800000;">&quot;CellInfo&quot;</span>, <span style="color: #800000;">&quot;CellInfo&quot;</span>
RegisterUserFunc <span style="color: #800000;">&quot;WebList&quot;</span>, <span style="color: #800000;">&quot;CellInfo&quot;</span>, <span style="color: #800000;">&quot;CellInfo&quot;</span>
RegisterUserFunc <span style="color: #800000;">&quot;WebRadioGroup&quot;</span>, <span style="color: #800000;">&quot;CellInfo&quot;</span>, <span style="color: #800000;">&quot;CellInfo&quot;</span>
RegisterUserFunc <span style="color: #800000;">&quot;WebElement&quot;</span>, <span style="color: #800000;">&quot;CellInfo&quot;</span>, <span style="color: #800000;">&quot;CellInfo&quot;</span>
RegisterUserFunc <span style="color: #800000;">&quot;WebCheckBox&quot;</span>, <span style="color: #800000;">&quot;CellInfo&quot;</span>, <span style="color: #800000;">&quot;CellInfo&quot;</span></pre></div></div>

<h5>Example</h5>
<pre>
Set cells = Browser("title:=myBrowser").Link("innertext:=myLink", "index:=1").CellInfo()

MsgBox cells("row")
MsgBox cells("col")

cells.RemoveAll
Set cells = Nothing
</pre>
<p>
I hope you find this helpful. As always, thanks for visiting Relevant Codes :)</p>
]]></content:encoded>
			<wfw:commentRss>http://relevantcodes.com/get-rowcolumn-of-an-object-in-a-webtable/feed/</wfw:commentRss>
		<slash:comments>38</slash:comments>
		</item>
		<item>
		<title>ExcelUtil Class Library (MS Excel Utility Methods)</title>
		<link>http://relevantcodes.com/excelutil-class-library-excel-utility-methods/</link>
		<comments>http://relevantcodes.com/excelutil-class-library-excel-utility-methods/#comments</comments>
		<pubDate>Sat, 12 Mar 2011 20:34:45 +0000</pubDate>
		<dc:creator>Anshoo Arora</dc:creator>
				<category><![CDATA[All]]></category>
		<category><![CDATA[QTP]]></category>
		<category><![CDATA[VBScript]]></category>
		<category><![CDATA[Excel Utility]]></category>
		<category><![CDATA[ExcelUtil]]></category>
		<category><![CDATA[ExcelUtil Class Library]]></category>
		<category><![CDATA[RelevantCodes]]></category>
		<category><![CDATA[RelevantCodes.ExcelUtil]]></category>
		<category><![CDATA[SetFile]]></category>
		<category><![CDATA[VBScript Excel]]></category>
		<category><![CDATA[VBScript ExcelUtil]]></category>

		<guid isPermaLink="false">http://relevantcodes.com/?p=4100</guid>
		<description><![CDATA[Over the past few years, I have read numerous threads and posts talking about working with Excel using VBScript. Not only have there been numerous threads, but also frameworks that use Excel as the input and/or driver engine. I wanted to work on this mini-project for a long time, and I finally have Version 1.0 of ExcelUtil ready for download! It comes with .CHM documentation.]]></description>
			<content:encoded><![CDATA[<p></p><p>
Over the past few years, I have read numerous threads and posts talking about working with Excel using VBScript. Not only have there been numerous threads, but also frameworks that use Excel as the input and/or driver engine. I wanted to work on this mini-project for a long time, and I finally have Version 1.0 of ExcelUtil ready for download! It comes with <a href="http://relevantcodes.com/Articles/ExcelUtil/Documentation.chm">.CHM documentation</a>.
</p>
<p>
I&#8217;m quite sure I have missed some methods that the community uses, which I have not been able to include in the 1st version. I, however, am open to suggestions and would gladly include your ideas for Version 2.0.
</p>
<p class="centeralign alert"><span style='font-weight:bold; font-family:Calibri; font-size:1.2em;'><a class="downloadlink" href="http://relevantcodes.com/wp-content/plugins/download-monitor/download.php?id=11" title="Version1.0 downloaded 1054 times" >Download RelevantCodes.ExcelUtil Class Library (1054)</a></span></p>
<p>
<strong>IMPORTANT:</strong> To use any method of ExcelUtil, <strong>be sure to use <code>SetFile</code></strong>. This will set the Excel WorkBook and WorkSheet ready for use. To use a different WorkBook or WorkSheet, <code>SetFile</code> will have to be called again.
</p>
<h3>SetFile Property</h3>
<h5>Value Type</h5>
<p class="info">Read only.  A [RelevantCodes.ExcelUtil] object.</p>
<h5>Description</h5>
<p class="info">Sets the region instances for Excel WorkBook and WorkSheet. These instances for the Excel source are created only once and used by other methods. <strong>NOTE: For any method to execute, SetFile must be executed first to set the WorkBook and WorkSheet.</strong></p>
<h5>Syntax</h5>
<pre>
ExcelUtil.SetFile WorkBookPath, WorkSheet
</pre>
<h5>Examples</h5>

<div class="wp_syntax"><div class="code"><pre class="vb" style="font-family:consolas, monospace;"><span style="color: #008000;">'Example 1
</span>ExcelUtil.SetFile <span style="color: #800000;">&quot;C:\Student.xls&quot;</span>, <span style="color: #800000;">&quot;Sheet1&quot;</span>
&nbsp;
<span style="color: #008000;">'Example 2:  Reading value directly from a file
</span>sCellValue = ExcelUtil.SetFile(<span style="color: #800000;">&quot;C:\Student.xls&quot;</span>, <span style="color: #800000;">&quot;Sheet1&quot;</span>).GetCellValue(1, 1)
&nbsp;
<span style="color: #008000;">'Example 3:  Reading values from 2 different files - Approach 1
</span>ExcelUtil.SetFile <span style="color: #800000;">&quot;C:\Student.xls&quot;</span>, <span style="color: #800000;">&quot;Sheet1&quot;</span>
var1 = ExcelUtil.GetCellValue(1, 1)
ExcelUtil.SetFile <span style="color: #800000;">&quot;C:\Teacher.xls&quot;</span>, <span style="color: #800000;">&quot;Sheet1&quot;</span>
var2 = ExcelUtil.GetCellValue(1, 1)
&nbsp;
<span style="color: #008000;">'Example 4:  Reading values from 2 different files - Approach 2
</span>var1 = ExcelUtil.SetFile(<span style="color: #800000;">&quot;C:\Student.xls&quot;</span>, <span style="color: #800000;">&quot;Sheet1&quot;</span>).GetCellValue(1, 1)
var2 = ExcelUtil.SetFile(<span style="color: #800000;">&quot;C:\Teacher.xls&quot;</span>, <span style="color: #800000;">&quot;Sheet1&quot;</span>).GetCellValue(1, 1)</pre></div></div>

<h3>I found a Bug. What should I do next?</h3>
<p>
Reporting the bug in the comments section will ensure the next version of this class library is more robust! It may not be possible to release the fixed code immediately, but notifying me and the readers of all potential bugs will be highly appreciated! Thank you.
</p>
<h3>I have something cool I would like you to add to ExcelUtil.</h3>
<p>
I would love to hear all ideas and suggestions to improve or enhance this library. Please use the comments section to share them with me and the community. Thank you.
</p>
<p class="centeralign alert"><span style='font-weight:bold; font-family:Calibri; font-size:1.2em;'><a class="downloadlink" href="http://relevantcodes.com/wp-content/plugins/download-monitor/download.php?id=11" title="Version1.0 downloaded 1054 times" >Download RelevantCodes.ExcelUtil Class Library (1054)</a></span></p>
]]></content:encoded>
			<wfw:commentRss>http://relevantcodes.com/excelutil-class-library-excel-utility-methods/feed/</wfw:commentRss>
		<slash:comments>28</slash:comments>
		</item>
		<item>
		<title>Executing QC TestSet via OTA API (QCRunTestSet)</title>
		<link>http://relevantcodes.com/executing-qc-testset-via-ota-api-qcruntestset/</link>
		<comments>http://relevantcodes.com/executing-qc-testset-via-ota-api-qcruntestset/#comments</comments>
		<pubDate>Mon, 10 Jan 2011 12:10:31 +0000</pubDate>
		<dc:creator>Anshoo Arora</dc:creator>
				<category><![CDATA[All]]></category>
		<category><![CDATA[QTP]]></category>
		<category><![CDATA[Quality Center]]></category>
		<category><![CDATA[VBScript]]></category>
		<category><![CDATA[Custom Run TestSet Object]]></category>
		<category><![CDATA[QC Scheduler]]></category>
		<category><![CDATA[QC Scheduling]]></category>
		<category><![CDATA[QCRunTestSet]]></category>
		<category><![CDATA[Quality Center Scheduling]]></category>
		<category><![CDATA[Remote QC Scheduling]]></category>
		<category><![CDATA[Run TestSet on LocalHost]]></category>
		<category><![CDATA[Run TestSet Remotely]]></category>
		<category><![CDATA[RunTestSet]]></category>
		<category><![CDATA[Schedule Test Set]]></category>

		<guid isPermaLink="false">http://relevantcodes.com/?p=4018</guid>
		<description><![CDATA[Over the past few weeks, I have been actively working on Quality Center (ALM) and its integration with QuickTest Professional. One of the mini-projects I've worked on is creating a custom object that executes a test set and sends an email to the supplied distribution list from ALM TestSet's Automation tab. VBScript code available for download. ]]></description>
			<content:encoded><![CDATA[<p></p><p>
For the past few weeks, I have been actively working on Quality Center (<strong>ALM</strong>) and its integration with QuickTest Professional. One of the mini-projects I&#8217;ve worked on is creating a custom object that executes a test set and sends an email to the supplied distribution list from ALM TestSet&#8217;s Automation tab (as shown below):
</p>
<p><img alt="" src="http://relevantcodes.com/Articles/QCRunTestSet/EMailTo.PNG" title="EMailTo Field in QC TestSet&#039;s Automation tab" class="aligncenter" width="558" height="448" /></p>
<p>
Note: The above part (EMailTo) can be modified by either hard-coding it, or supplying an input from the Class Constructor.
</p>
<p>
I&#8217;ve extensively used the OTA API Reference to build this object and to understand how the API works. .NET developers having difficulty converting the VBScript code, please post in the comments section and I will mail you the class library (currently only C#).
</p>
<h2>Download (ALM Only)</h2>
<p>
QCRunTestSet is available for download, but comes as-is and currently executes TestSets on the localHost. However, I would be more than happy in helping you to modify this code to suit your needs.
</p>
<p class="centeralign alert"><span style='font-weight:bold; font-family:Calibri; font-size:1.2em;'><a class="downloadlink" href="http://relevantcodes.com/wp-content/plugins/download-monitor/download.php?id=10" title=" downloaded 1219 times" >QCRunTestSet.cls.vbs.zip [for ALM] (1219)</a></span></p>
<p>
If you&#8217;re having issues creating an instance of the <code>TSScheduler</code> object, please read <a href="http://www.sqaforums.com/showflat.php?Cat=&#038;Board=UBB20&#038;Number=652599">this thread</a> carefully. You may need to upgrade to a higher patch or perform a client registration on the execution machine.
</p>
<h2>Running QCRunTestSet from CommandLine</h2>
<p>
If you would like to pass parameters from the CommandLine instead of hard-coding them in the code, use WScript to pass arguments and WScript.Arguments to retrieve them in the class library. Example:
</p>

<div class="wp_syntax"><div class="code"><pre class="vb" style="font-family:consolas, monospace;"><span style="color: #008000;">'Passing arguments
</span>wscript C:\QCRunTestSet.cls.vbs <span style="color: #800000;">&quot;http//&lt;server&gt;:8080/qcbin&quot;</span> myUser myPassword myDomain _
                                                  myProject myTestSetPath myTestSetName</pre></div></div>


<div class="wp_syntax"><div class="code"><pre class="vb" style="font-family:consolas, monospace;"><span style="color: #008000;">'Retrieving arguments
</span><span style="color: #0000A6;">Set</span> args = WScript.Arguments
&nbsp;
QCServer = args(0)
UserName =  args(1)
Password = args(2)
QCDomain = args(3)
QCProject = args(4)
QCTestSetPath = args(5)
QCTestSetName = args(6)</pre></div></div>

<p>
I hope you find this helpful. Thanks for visiting Relevant Codes! :)</p>
]]></content:encoded>
			<wfw:commentRss>http://relevantcodes.com/executing-qc-testset-via-ota-api-qcruntestset/feed/</wfw:commentRss>
		<slash:comments>17</slash:comments>
		</item>
		<item>
		<title>IE Error: A script is causing IE to run slowly</title>
		<link>http://relevantcodes.com/ie-error-a-script-is-causing-ie-to-run-slowly/</link>
		<comments>http://relevantcodes.com/ie-error-a-script-is-causing-ie-to-run-slowly/#comments</comments>
		<pubDate>Mon, 06 Dec 2010 03:55:25 +0000</pubDate>
		<dc:creator>Anshoo Arora</dc:creator>
				<category><![CDATA[All]]></category>
		<category><![CDATA[QTP]]></category>
		<category><![CDATA[QTP/Web]]></category>
		<category><![CDATA[VBScript]]></category>
		<category><![CDATA[IE]]></category>
		<category><![CDATA[IE Error]]></category>
		<category><![CDATA[MaxScriptStatements]]></category>
		<category><![CDATA[QTP Web]]></category>

		<guid isPermaLink="false">http://relevantcodes.com/?p=3973</guid>
		<description><![CDATA[This tip shows how to disable the Error message: "A script on this page is causing Internet Explorer to run slowly" with using VBScript.]]></description>
			<content:encoded><![CDATA[<p></p><p>
While testing a script on IE8, me and my colleague kept getting the error &#8220;A script on this page is causing Internet Explorer to run slowly&#8221;.  Below is a snapshot of the error:</p>
<p><img alt="" src="http://relevantcodes.com/Articles/IEScriptRunningSlow/ie_error.JPG" title="IE Error: A script is causing IE to run slowly" class="aligncenter" width="340" height="155" /></p>
<p>After some research, I came across an article on MSDN which already had the solution: <a href="http://support.microsoft.com/default.aspx?scid=kb;en-us;175500">Microsoft KB # 175500</a>. The part we are concerned about is in the section &#8220;Let me fix it myself&#8221;:</p>
<p class="info">
1.Using a Registry Editor such as Regedt32.exe, open this key: <i>HKEY_CURRENT_USER\Software\Microsoft\Internet Explorer\Styles</i><br />
Note: If the Styles key is not present, create a new key that is called Styles.<br />
2. Create a new DWORD value called &#8220;MaxScriptStatements&#8221; under this key and set the value to the desired number of script statements. If you are unsure of what value you need to set this to, you can set it to a DWORD value of 0xFFFFFFFF to completely avoid the dialog.
</p>
<p>
For the curious ones, the article states that, to encounter the error, the DWord value of <strong>0xFFFFFFFF</strong> must be added.  The value equates to -1, which is what has been used in the function below.
</p>
<h2>The VBScript:</h2>

<div class="wp_syntax"><div class="code"><pre class="vb" style="font-family:consolas, monospace;"><span style="color: #0000A6;">Sub</span> IE_ChangeScriptTimeOut()
	<span style="color: #0000A6;">Dim</span> Registry, sKeyPath, sValueName, dwValue, sComputer
	CONST HKEY_CURRENT_USER = &amp;H80000001
&nbsp;
	sKeyPath = <span style="color: #800000;">&quot;Software\Microsoft\Internet Explorer\Styles&quot;</span>
	sValueName = <span style="color: #800000;">&quot;MaxScriptStatements&quot;</span>
	dwValue = -1
	sComputer = <span style="color: #800000;">&quot;.&quot;</span>
&nbsp;
	<span style="color: #0000A6;">On</span> <span style="color: #0000A6;">Error</span> <span style="color: #0000A6;">Resume</span> <span style="color: #0000A6;">Next</span>
		<span style="color: #0000A6;">Set</span> Registry = <span style="color: #0000A6;">GetObject</span>(<span style="color: #800000;">&quot;winmgmts:{impersonationLevel=impersonate}!\\&quot;</span> &amp;_ 
				sComputer &amp; <span style="color: #800000;">&quot;\root\default:StdRegProv&quot;</span>)
&nbsp;
		Registry.CreateKey HKEY_CURRENT_USER, sKeyPath
		Registry.SetDWORDValue HKEY_CURRENT_USER, sKeyPath, sValueName, CLng(dwValue)
	<span style="color: #0000A6;">On</span> <span style="color: #0000A6;">Error</span> <span style="color: #0000A6;">Goto</span> 0
&nbsp;
	<span style="color: #0000A6;">Set</span> Registry = <span style="color: #0000A6;">Nothing</span>
<span style="color: #0000A6;">End</span> <span style="color: #0000A6;">Sub</span></pre></div></div>

<p>
Thanks for reading, and thanks for visiting Relevant Codes! :)</p>
]]></content:encoded>
			<wfw:commentRss>http://relevantcodes.com/ie-error-a-script-is-causing-ie-to-run-slowly/feed/</wfw:commentRss>
		<slash:comments>10</slash:comments>
		</item>
		<item>
		<title>CreationTime</title>
		<link>http://relevantcodes.com/creationtime/</link>
		<comments>http://relevantcodes.com/creationtime/#comments</comments>
		<pubDate>Fri, 03 Sep 2010 11:34:51 +0000</pubDate>
		<dc:creator>Anshoo Arora</dc:creator>
				<category><![CDATA[All]]></category>
		<category><![CDATA[QTP]]></category>
		<category><![CDATA[QTP/Web]]></category>
		<category><![CDATA[Browser]]></category>
		<category><![CDATA[Browser Creationtime]]></category>
		<category><![CDATA[CreationTime]]></category>
		<category><![CDATA[Ordinal Identifier]]></category>
		<category><![CDATA[Ordinal Identifier CreationTime]]></category>

		<guid isPermaLink="false">http://relevantcodes.com/?p=3930</guid>
		<description><![CDATA[This article explains how the Browser's CreationTime ordinal identifier works in QTP with examples.]]></description>
			<content:encoded><![CDATA[<p></p><p>
I&#8217;ve generally seen some confusion around CreationTime. I think between the 3 Ordinal Identifiers, this one may be the easiest to understand and implement. That&#8217;s mostly because CreationTime is used <span class="emphasis_u">only</span> for the Browser object. Below is how CreationTime is applied to browsers:
</p>
<pre>
1st open browser -> CreationTime of -> 0
2nd open browser -> CreationTime of -> 1
3rd open browser -> CreationTime of -> 2
4th open browser -> CreationTime of -> 3
</pre>
<p>
According to QTP help:
</p>
<p class="info">
This value indicates the order in which the browser was opened relative to other open browsers. For example, if QuickTest learns three browsers that are opened at 9:01 pm, 9:03 pm, and 9:05 pm, QuickTest assigns the CreationTime values, as follows: CreationTime = 0 to the 9:01 am browser, CreationTime = 1 to the 9:03 am browser, and CreationTime = 2 to the 9:06 am browser.
</p>
<p>
Really, that&#8217;s it! No tricks here! To test it for proof, you can open 4 browsers (with different websites) and run the following code in QTP:
</p>

<div class="wp_syntax"><div class="code"><pre class="vb" style="font-family:consolas, monospace;"><span style="color: #0000A6;">For</span> ix = 0 <span style="color: #0000A6;">to</span> 3
	<span style="color: #0000A6;">Print</span> <span style="color: #800000;">&quot;CreationTime-&gt;&quot;</span> &amp; ix &amp; <span style="color: #800000;">&quot;-&gt;&quot;</span> &amp; Browser(<span style="color: #800000;">&quot;creationtime:=&quot;</span> &amp; ix).GetROProperty(<span style="color: #800000;">&quot;title&quot;</span>)
<span style="color: #0000A6;">Next</span></pre></div></div>

<p>
On my desktop, I&#8217;ve 4 open IE windows in the following order: Google, Bing, Yahoo, Microsoft. See snapshot below:
</p>
<div class="wp-caption aligncenter" style="width: 675px">
	<a href="http://relevantcodes.com/Articles/CreationTime/Taskbar.png"><img alt="My taskbar" src="http://relevantcodes.com/Articles/CreationTime/Taskbar.png" title="My taskbar" width="675" height="22" /></a>
	<p class="wp-caption-text">My taskbar: Click to view original size</p>
</div>
<p>
After running the above code, this is what I see in my print log:
</p>
<div class="wp-caption aligncenter" style="width: 321px">
	<img alt="Print log" src="http://relevantcodes.com/Articles/CreationTime/Output.png" title="Print log" width="321" height="162" />
	<p class="wp-caption-text">Print log</p>
</div>
<p>
The output shows the order in which the IE windows are placed on the Desktop, which is same as the order in which they were opened.
</p>
<h5>The tricky part</h5>
<p>
The only tricky part in this concept is its applicability when there is only one browser open. With one open browser, regardless of the CreationTime value supplied, QTP will always identify the only open browser. This is because, CreationTime values are generated when there are multiple browsers open &#8211; with a single open browser, this value is generally has no usage. This is at least true for QTP 10.0 and previous versions.
</p>
<p>
As always, thanks for visiting Relevant Codes! :)
</p>
<p class="alert">
If you have any questions, please ask them in the comments section.</p>
]]></content:encoded>
			<wfw:commentRss>http://relevantcodes.com/creationtime/feed/</wfw:commentRss>
		<slash:comments>19</slash:comments>
		</item>
		<item>
		<title>GUI Objects VBScript &amp; Try Catch Finally</title>
		<link>http://relevantcodes.com/gui-objects-vbscript-try-catch-finally/</link>
		<comments>http://relevantcodes.com/gui-objects-vbscript-try-catch-finally/#comments</comments>
		<pubDate>Mon, 30 Aug 2010 06:31:17 +0000</pubDate>
		<dc:creator>Anshoo Arora</dc:creator>
				<category><![CDATA[All]]></category>
		<category><![CDATA[QTP]]></category>
		<category><![CDATA[VBScript]]></category>
		<category><![CDATA[Catch]]></category>
		<category><![CDATA[Class]]></category>
		<category><![CDATA[Classes]]></category>
		<category><![CDATA[Error Handling]]></category>
		<category><![CDATA[Finally]]></category>
		<category><![CDATA[Module]]></category>
		<category><![CDATA[QTP Module]]></category>
		<category><![CDATA[Test Module]]></category>
		<category><![CDATA[Try]]></category>
		<category><![CDATA[Try..Catch..Finally]]></category>
		<category><![CDATA[Wrapper]]></category>

		<guid isPermaLink="false">http://relevantcodes.com/?p=3802</guid>
		<description><![CDATA[VBScript's error handling techniques have been quite limited to <code>On Error</code> statements, and even though they satisfy our needs to some extent, the lack of incorporating dynamic behavior with them has been a much bigger issue. In this article, I will implement a Try-Catch-Finally statement with QTP's GUI objects along with an On Error statement. This will enable dynamic behavior and enable us to easily divide flow depending on different error conditions.]]></description>
			<content:encoded><![CDATA[<p></p><p>
VBScript&#8217;s error handling techniques have been quite limited to <code>On Error</code> statements, and even though they satisfy our needs to some extent, the lack of incorporating dynamic behavior with them has been a much bigger issue. Lee Harvey <a href="http://my.opera.com/Lee_Harvey/blog/2007/04/21/try-catch-finally-in-vbscript-sure">here</a> shows how <code>Classes</code> can be extended to create simple Try-Catch-Finally statements with just a bit more work. I like this technique, and have been using it for the past few days with success. We know that this is not the best solution that is possible with a scripting language (JS does a lot better!), but its a start and a terrific workaround (thanks Lee!).
</p>
<h2>Creating Try-Catch-Finally Statements in VBScript</h2>
<p>
If you have already read Lee&#8217;s article, you can skip this part. Otherwise, a simple implementation is shown below:
</p>
<ol>
<li>As soon as the class executes, it enters Class_Initialize &#8211; Try statement</li>
<li>It encounters an error &#8211; Err.Raise 1002</li>
<li>As soon as it encounters an error, the Try statement (Class_Initialize) immediately ends execution</li>
<li>Because we&#8217;re releasing the Class reference using <code>Set NewTryCatchFinally = Nothing</code> right after initializing it, the Class enters Class_Terminate</li>
<li>Class_Terminate calls the Catch subroutine</li>
<li>When Catch runs in its entirety, Class_Terminate executes</li>
</ol>

<div class="wp_syntax"><div class="code"><pre class="vb" style="font-family:consolas, monospace;"><span style="color: #0000A6;">On</span> <span style="color: #0000A6;">Error</span> <span style="color: #0000A6;">Resume</span> <span style="color: #0000A6;">Next</span>
&nbsp;
<span style="color: #0000A6;">Class</span> TryCatchFinally
&nbsp;
    <span style="color: #0000A6;">Private</span> <span style="color: #0000A6;">Sub</span> Class_Initialize <span style="color: #008000;">'Try
</span>        <span style="color: #0000A6;">Print</span> <span style="color: #800000;">&quot;Entering Try..&quot;</span> &amp; vbNewLine
&nbsp;
        Err.Raise 1002 <span style="color: #008000;">'Raise a Syntax Error
</span>        MsgBox <span style="color: #800000;">&quot;This line will not execute&quot;</span>
    <span style="color: #0000A6;">End</span> <span style="color: #0000A6;">Sub</span>
&nbsp;
    <span style="color: #0000A6;">Private</span> <span style="color: #0000A6;">Sub</span> Catch <span style="color: #008000;">'Catch
</span>        <span style="color: #0000A6;">If</span> Err.Number = 0 <span style="color: #0000A6;">Then</span> <span style="color: #0000A6;">Exit</span> <span style="color: #0000A6;">Sub</span>
&nbsp;
        <span style="color: #0000A6;">Print</span> <span style="color: #800000;">&quot;Entering Catch..&quot;</span>
        <span style="color: #0000A6;">Print</span> <span style="color: #800000;">&quot;Error caught: &quot;</span> &amp; Err.Description  &amp; vbNewLine
&nbsp;
        Err.Clear
    <span style="color: #0000A6;">End</span> <span style="color: #0000A6;">Sub</span>
&nbsp;
    <span style="color: #0000A6;">Private</span> <span style="color: #0000A6;">Sub</span> Class_Terminate : Catch <span style="color: #008000;">'Finally
</span>        <span style="color: #0000A6;">Print</span> <span style="color: #800000;">&quot;Exiting..&quot;</span> 
    <span style="color: #0000A6;">End</span> <span style="color: #0000A6;">Sub</span>
&nbsp;
<span style="color: #0000A6;">End</span> <span style="color: #0000A6;">Class</span>
&nbsp;
<span style="color: #0000A6;">Set</span> NewTryCatchFinally = <span style="color: #0000A6;">New</span> TryCatchFinally : <span style="color: #0000A6;">Set</span> NewTryCatchFinally = <span style="color: #0000A6;">Nothing</span></pre></div></div>

<p>
The output of executing the above code should be the following:
</p>
<div class="wp-caption aligncenter" style="width: 299px">
	<img alt="" src="http://relevantcodes.com/Articles/VBScriptTryCatchFinallyIntro/TryCatchPrintLog.png" title="Try Catch Finally Implementation in VBScript" width="299" height="221" />
	<p class="wp-caption-text">Try Catch Finally Implementation in VBScript</p>
</div>
<p>
We can see from the result that as soon as the Class executes, it enters <code>Class_Initialize</code>. When it encounters an error, it enters into <code>Class_Terminate</code> which contains (and executes) the <code>Catch</code> method. A simple yet such an elegant solution!
</p>
<h2>Utility Class &#038; Error Handler</h2>
<p>
In this article, I will try to implement the technique with QTP&#8217;s GUI objects. To begin, let&#8217;s create a simple Login class with the following methods:
</p>
<ol>
<li><code>CheckPage</code></li>
<li><code>CheckImage</code></li>
<li><code>Login</code></li>
</ol>
<p>
The Login Class outputs the result through the <code>Result</code> property:
</p>
<h5>A simple Login Class</h5>

<div class="wp_syntax"><div class="code"><pre class="vb" style="font-family:consolas, monospace;"><span style="color: #0000A6;">On</span> <span style="color: #0000A6;">Error</span> <span style="color: #0000A6;">Resume</span> <span style="color: #0000A6;">Next</span>
&nbsp;
<span style="color: #0000A6;">Class</span> Login
&nbsp;
    <span style="color: #0000A6;">Public</span> <span style="color: #0000A6;">Property</span> <span style="color: #0000A6;">Get</span> Result
        Result = CheckPage <span style="color: #0000A6;">And</span> CheckImage <span style="color: #0000A6;">And</span> Login
    <span style="color: #0000A6;">End</span> <span style="color: #0000A6;">Property</span>
&nbsp;
    <span style="color: #0000A6;">Private</span> <span style="color: #0000A6;">Function</span> CheckPage
        MsgBox <span style="color: #800000;">&quot;CheckPage&quot;</span> : CheckPage = <span style="color: #0000A6;">True</span>
    <span style="color: #0000A6;">End</span> <span style="color: #0000A6;">Function</span>
&nbsp;
    <span style="color: #0000A6;">Private</span> <span style="color: #0000A6;">Function</span> CheckImage
        CheckImage = <span style="color: #0000A6;">False</span>
&nbsp;
        Browser(<span style="color: #800000;">&quot;title:=Welcome.*&quot;</span>).WebElement(<span style="color: #800000;">&quot;text:=Relevant Codes&quot;</span>).Click <span style="color: #008000;">'Error here!
</span>
        MsgBox <span style="color: #800000;">&quot;Error!&quot;</span> <span style="color: #008000;">'This will not execute
</span>    <span style="color: #0000A6;">End</span> <span style="color: #0000A6;">Function</span>
&nbsp;
    <span style="color: #008000;">'This will not execute
</span>    <span style="color: #0000A6;">Private</span> <span style="color: #0000A6;">Function</span> Login
        MsgBox <span style="color: #800000;">&quot;Login&quot;</span>
    <span style="color: #0000A6;">End</span> <span style="color: #0000A6;">Function</span>
&nbsp;
<span style="color: #0000A6;">End</span> <span style="color: #0000A6;">Class</span>
&nbsp;
<span style="color: #0000A6;">Dim</span> NewLogin : <span style="color: #0000A6;">Set</span> NewLogin = <span style="color: #0000A6;">New</span> Login</pre></div></div>

<p class="info">
Above, the Result property of the Login Class is called, which first executes CheckPage, then CheckImage and finally Login. Note that Login will only execute if CheckImage runs without any errors.
</p>
<p>
Let&#8217;s create another class that calls the methods of the original Login class, but with the error handling capabilities of a Try-Catch-Finally statement. This is also the Class that will always execute the original Login class because that&#8217;s where the actual error handling using Try-Catch-Finally exists.
</p>
<h5>Try..Catch..Finally with Class_Initialize &#038; Class_Terminate</h5>

<div class="wp_syntax"><div class="code"><pre class="vb" style="font-family:consolas, monospace;"><span style="color: #0000A6;">Class</span> LoginHandler <span style="color: #008000;">'LoginHandler start
</span>
    <span style="color: #0000A6;">Public</span> bResult
&nbsp;
    <span style="color: #0000A6;">Private</span> <span style="color: #0000A6;">Sub</span> Class_Initialize
         <span style="color: #0000A6;">Print</span> <span style="color: #800000;">&quot;Entering Try..&quot;</span> &amp; vbNewLine
         bResult = NewLogin.Result
    <span style="color: #0000A6;">End</span> <span style="color: #0000A6;">Sub</span>
&nbsp;
    <span style="color: #0000A6;">Private</span> <span style="color: #0000A6;">Sub</span> CatchErr
        <span style="color: #0000A6;">If</span> Err.Number = 0 <span style="color: #0000A6;">Then</span> <span style="color: #0000A6;">Exit</span> <span style="color: #0000A6;">Sub</span>
&nbsp;
        <span style="color: #0000A6;">Print</span> <span style="color: #800000;">&quot;Entering Catch..&quot;</span>
        <span style="color: #0000A6;">Print</span> <span style="color: #800000;">&quot;Error: &quot;</span> &amp; Err.Description &amp; vbNewLine
&nbsp;
        Err.Clear
    <span style="color: #0000A6;">End</span> <span style="color: #0000A6;">Sub</span>
&nbsp;
    <span style="color: #0000A6;">Private</span> <span style="color: #0000A6;">Sub</span> Class_Terminate : CatchErr
        <span style="color: #0000A6;">Print</span> <span style="color: #800000;">&quot;Exiting..&quot;</span>
    <span style="color: #0000A6;">End</span> <span style="color: #0000A6;">Sub</span>
&nbsp;
<span style="color: #0000A6;">End</span> <span style="color: #0000A6;">Class</span> <span style="color: #008000;">'LoginHandler end
</span>
<span style="color: #0000A6;">Set</span> NewLoginHandler = <span style="color: #0000A6;">New</span> LoginHandler
<span style="color: #0000A6;">Set</span> NewLoginHandler = <span style="color: #0000A6;">Nothing</span>
<span style="color: #0000A6;">Set</span> NewLogin = <span style="color: #0000A6;">Nothing</span></pre></div></div>

<p class="info">
The <code>Class_Initialize</code> method of the class calls the Result property of the Login class. Once Result is called, it executes all the methods called by the Result property. If any error occurs, CatchErr is immediately called by <code>Class_Terminate</code> and later, all code inside the Class_Terminate method is executed.
</p>
<p>
Output of executing Login Class &#038; LoginHandler:
</p>
<div class="wp-caption aligncenter" style="width: 500px">
	<img alt="" src="http://relevantcodes.com/Articles/VBScriptTryCatchFinallyIntro/PrintLog1.png" title="Print Log" width="500" height="199" />
	<p class="wp-caption-text">QTP Print Log</p>
</div>
<h2>Method Containing the Error?</h2>
<p>
By including the name of each method in the very first line, we can also find out where exactly the error occurred. This, however, I agree is quite time consuming and repetitive work. The only alternative to this has been shown by PowerDebug Beta. However, if you would like to extend the above approach in VBScript, this *may be* the only possible approach. I&#8217;ve been wrong before, and would love to see a technique which simplifies the method naming approach used below.
</p>
<h5>Login Class with Method Names</h5>

<div class="wp_syntax"><div class="code"><pre class="vb" style="font-family:consolas, monospace;"><span style="color: #0000A6;">On</span> <span style="color: #0000A6;">Error</span> <span style="color: #0000A6;">Resume</span> <span style="color: #0000A6;">Next</span>
&nbsp;
<span style="color: #0000A6;">Class</span> Login <span style="color: #008000;">'Login start
</span>
    <span style="color: #0000A6;">Public</span> sMethod
&nbsp;
    <span style="color: #0000A6;">Public</span> <span style="color: #0000A6;">Property</span> <span style="color: #0000A6;">Get</span> Result
        Result = CheckPage <span style="color: #0000A6;">And</span> CheckImage <span style="color: #0000A6;">And</span> Login
    <span style="color: #0000A6;">End</span> <span style="color: #0000A6;">Property</span>
&nbsp;
    <span style="color: #0000A6;">Private</span> <span style="color: #0000A6;">Function</span> CheckPage
        Me.sMethod = <span style="color: #800000;">&quot;CheckPage&quot;</span>
&nbsp;
        MsgBox <span style="color: #800000;">&quot;CheckPage&quot;</span> : CheckPage = <span style="color: #0000A6;">True</span>
    <span style="color: #0000A6;">End</span> <span style="color: #0000A6;">Function</span>
&nbsp;
    <span style="color: #0000A6;">Private</span> <span style="color: #0000A6;">Function</span> CheckImage
        Me.sMethod = <span style="color: #800000;">&quot;CheckImage&quot;</span>
&nbsp;
        CheckImage = <span style="color: #0000A6;">False</span>
        Browser(<span style="color: #800000;">&quot;title:=Welcome.*&quot;</span>).WebElement(<span style="color: #800000;">&quot;text:=Relevant Codes&quot;</span>).Click <span style="color: #008000;">'Error here!
</span>        
        MsgBox <span style="color: #800000;">&quot;Error!&quot;</span> <span style="color: #008000;">'This will not execute
</span>    <span style="color: #0000A6;">End</span> <span style="color: #0000A6;">Function</span>
&nbsp;
    <span style="color: #0000A6;">Private</span> <span style="color: #0000A6;">Function</span> Login <span style="color: #008000;">'This will not execute
</span>        Me.sMethod = <span style="color: #800000;">&quot;Login&quot;</span>
&nbsp;
        Msgbox <span style="color: #800000;">&quot;Login&quot;</span>
    <span style="color: #0000A6;">End</span> <span style="color: #0000A6;">Function</span>
&nbsp;
<span style="color: #0000A6;">End</span> <span style="color: #0000A6;">Class</span> <span style="color: #008000;">'Login end
</span><span style="color: #0000A6;">Dim</span> NewLogin : <span style="color: #0000A6;">Set</span> NewLogin = <span style="color: #0000A6;">New</span> Login</pre></div></div>

<h5>LoginHandler (Outputs Method Names)</h5>

<div class="wp_syntax"><div class="code"><pre class="vb" style="font-family:consolas, monospace;"><span style="color: #0000A6;">Class</span> LoginHandler <span style="color: #008000;">'LoginHandler start
</span>
    <span style="color: #0000A6;">Public</span> bResult
&nbsp;
    <span style="color: #0000A6;">Private</span> <span style="color: #0000A6;">Sub</span> Class_Initialize
         <span style="color: #0000A6;">Print</span> <span style="color: #800000;">&quot;Entering Try..&quot;</span> &amp; vbNewLine
         bResult = NewLogin.Result
    <span style="color: #0000A6;">End</span> <span style="color: #0000A6;">Sub</span>
&nbsp;
    <span style="color: #0000A6;">Private</span> <span style="color: #0000A6;">Sub</span> CatchErr
        <span style="color: #0000A6;">If</span> Err.Number = 0 <span style="color: #0000A6;">Then</span> <span style="color: #0000A6;">Exit</span> <span style="color: #0000A6;">Sub</span>
&nbsp;
        <span style="color: #0000A6;">Print</span> <span style="color: #800000;">&quot;Entering Catch..&quot;</span>
        <span style="color: #0000A6;">Print</span> <span style="color: #800000;">&quot;Error occured in: &quot;</span> &amp; NewLogin.sMethod
        <span style="color: #0000A6;">Print</span> <span style="color: #800000;">&quot;Error: &quot;</span> &amp; Err.Description &amp; vbNewLine
&nbsp;
        Err.Clear
    <span style="color: #0000A6;">End</span> <span style="color: #0000A6;">Sub</span>
&nbsp;
    <span style="color: #0000A6;">Private</span> <span style="color: #0000A6;">Sub</span> Class_Terminate : CatchErr
        <span style="color: #0000A6;">Print</span> <span style="color: #800000;">&quot;Exiting..&quot;</span>
    <span style="color: #0000A6;">End</span> <span style="color: #0000A6;">Sub</span>
&nbsp;
<span style="color: #0000A6;">End</span> <span style="color: #0000A6;">Class</span> <span style="color: #008000;">'LoginHandler end
</span>
<span style="color: #0000A6;">Set</span> NewLoginHandler = <span style="color: #0000A6;">New</span> LoginHandler
<span style="color: #0000A6;">Set</span> NewLoginHandler = <span style="color: #0000A6;">Nothing</span>
<span style="color: #0000A6;">Set</span> NewLogin = <span style="color: #0000A6;">Nothing</span></pre></div></div>

<p>
View <a href="http://relevantcodes.com/Articles/VBScriptTryCatchFinallyIntro/Example2.txt">code</a>.
</p>
<p>
Output of executing Login Class &#038; LoginHandler:
</p>
<div class="wp-caption aligncenter" style="width: 502px">
	<img alt="" src="http://relevantcodes.com/Articles/VBScriptTryCatchFinallyIntro/PrintLog2.png" title="Print Log" width="502" height="211" />
	<p class="wp-caption-text">QTP Print Log</p>
</div>
<h2>Notes</h2>
<p>
After using this technique for several days and manipulating it a bit from the original work, I have found some success. However, implementing Handler classes when the scope of the utility class increases can be quite challenging, and time consuming. I still believe its a start to something that we haven&#8217;t witnessed in QTP (yet). To be honest, I still prefer the old way of doing things where I can branch out most of my GUI code in conditional statements &#8211; which has enabled me to always create more comprehensive reporting.</p>
<p>
My recommendation would be to use this approach with VBScript code instead of using it for QTP&#8217;s GUI objects, ofcourse, until absolutely necessary. Most of my usage for the above technique has been with pure VBScript code which has enabled me to create better error handling. In an upcoming article, I will show how this technique will be used to handle Excel errors and recover from them in the <code>CatchErr</code> method using a Select Case block. Including Try-Catch-Finally statements within Try-Catch-Finally statements is quite easily done in .NET, but its very complex to perform the same operation with VBScript. I&#8217;m still happy to have a start though.
</p>
<p class="alert">
If you have any questions, please ask them in the comments section.</p>
]]></content:encoded>
			<wfw:commentRss>http://relevantcodes.com/gui-objects-vbscript-try-catch-finally/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>Updates</title>
		<link>http://relevantcodes.com/updates/</link>
		<comments>http://relevantcodes.com/updates/#comments</comments>
		<pubDate>Fri, 23 Jul 2010 04:11:14 +0000</pubDate>
		<dc:creator>Anshoo Arora</dc:creator>
				<category><![CDATA[All]]></category>
		<category><![CDATA[Anshoo Arora]]></category>
		<category><![CDATA[Credits]]></category>
		<category><![CDATA[Relevant Codes]]></category>
		<category><![CDATA[Updates]]></category>

		<guid isPermaLink="false">http://relevantcodes.com/?p=3761</guid>
		<description><![CDATA[<p>I know and you may have realized that there haven't been any new article or updates here for the last few weeks. I have been extremely busy with prior obligations, work and a few big projects outside of work that I have been engaged in. However, please be assured that there are some articles on the way and another demo framework over the next few days. Please click the topic to continue reading..</p>]]></description>
			<content:encoded><![CDATA[<p></p><p>Hi everyone,</p>
<p>I know and you may have realized that there haven&#8217;t been any new article or updates here for the last few weeks. I have been extremely busy with prior obligations, work and a few big projects outside of work that I have been engaged in. However, please be assured that there are some articles on the way and another demo framework over the next few days.</p>
<p>I also appreciate requests for articles that you would like to see here, so please feel free to contribute your ideas!</p>
<p>I really appreciate everyone who visited and supported Relevant Codes during my off-time. I also value all your comments, suggestions, criticism and queries. They keep me coming back everyday to see that this website has grown to such a level from a very little blog that started a year ago.</p>
<p>Also, please don&#8217;t forget to <strong><a href="http://feedburner.google.com/fb/a/mailverify?uri=RelevantCodes&#038;loc=en_US">subscribe</a></strong> to ensure all articles are delivered to your email as soon as they are published! :)</p>
<p>Thanks!</p>
<p>Anshoo Arora</p>
]]></content:encoded>
			<wfw:commentRss>http://relevantcodes.com/updates/feed/</wfw:commentRss>
		<slash:comments>25</slash:comments>
		</item>
	</channel>
</rss>

