<?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>Perpetual Complexity &#187; Watir Script Generator Plugin</title>
	<atom:link href="http://www.flex.shallwelearn.com/blog/archives/category/watir-script-generator-plugin/feed" rel="self" type="application/rss+xml" />
	<link>http://www.flex.shallwelearn.com/blog</link>
	<description>Visualize, therefore simplified</description>
	<lastBuildDate>Wed, 19 May 2010 15:46:23 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0</generator>
		<item>
		<title>Watir Script Generation (WSG) Internet Explorer Plug-in</title>
		<link>http://www.flex.shallwelearn.com/blog/archives/1118</link>
		<comments>http://www.flex.shallwelearn.com/blog/archives/1118#comments</comments>
		<pubDate>Wed, 24 Jun 2009 14:17:31 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Watir Script Generator Plugin]]></category>

		<guid isPermaLink="false">http://www.flex.shallwelearn.com/blog/archives/1118</guid>
		<description><![CDATA[This project started as a take-home assignment from a company which is consider hiring me. Unfortunately I did not get the position because my design was too complex that I did not get to finish it in time. But I intend to finish implementing this project and will post the progress, documentation, and result on [...]]]></description>
			<content:encoded><![CDATA[<p>This project started as a take-home assignment from a company which is consider hiring me. Unfortunately I did not get the position because my design was too complex that I did not get to finish it in time. But I intend to finish implementing this project and will post the progress, documentation, and result on this site.</p>
<p><img src="http://www.flex.shallwelearn.com/blog/wp-content/uploads/2009/06/062409-1417-watirscript1.png" alt="" /><span id="more-1118"></span></p>
<p><span style="text-decoration: underline;"><strong>General Requirement:<br />
</strong></span></p>
<ul>
<li>Design and build a useful Internet Explorer plug-in to record the user actions and turn it to a Watir test script.</li>
</ul>
<p><span style="text-decoration: underline;"><strong>Detailed Requirement:<br />
</strong></span></p>
<ul>
<li>
<div>Create an Internet Explorer Plug-in that has a tool bar that looks like Webmetric&#8217;s Script Recorder but I will implement just two buttons: <em>Start</em> and <em>STOP</em> buttons.</div>
<p><img src="http://www.flex.shallwelearn.com/blog/wp-content/uploads/2009/06/062409-1417-watirscript1.png" alt="" /></li>
<li>When the START button <img src="http://www.flex.shallwelearn.com/blog/wp-content/uploads/2009/06/062409-1417-watirscript2.png" alt="" /> is clicked, all user actions will start being recorded.</li>
<li>When the STOP button is clicked, the recording will stop. And a window will pop up with where the script has been saved to.</li>
<li>
<div><span style="text-decoration: underline;">Limitation<br />
</span></div>
<ul>
<li> The recording will always be saved to the same file called &#8220;MyRecording.rb&#8221;.</li>
</ul>
</li>
</ul>
<p><span style="text-decoration: underline;"><strong>Required Development Tools and Libraries:<br />
</strong></span></p>
<ul style="margin-left: 54pt">
<li>Ruby</li>
<li>Watir</li>
<li>Asynchronous  Pluggable Protocol</li>
<li>Web Browser Control</li>
<li>ArrayList Data Container</li>
<li>Windows Template Library</li>
<li>ATL</li>
<li>Visual Studio 2008 (90-days trial version)</li>
<li>
<div>Windows Platform SDK</div>
</li>
</ul>
<p><span style="text-decoration: underline;"><strong>Estimated Time for Completion:<br />
</strong></span></p>
<ul style="margin-left: 54pt">
<li>24 hours ( already spent 12 hours; the implementation should take about 12 hours)</li>
</ul>
<p><span style="text-decoration: underline;"><strong>Time Already Spent to Overcome Learning Curve:<br />
</strong></span></p>
<ul style="margin-left: 54pt">
<li>
<div>Set up and Get Familiarized with the Development Environment (3 hours):</div>
<ul>
<li> Downloaded, installed, and got acquainted with Visual Studio 2008. Obtained  sample VC++ projects from Microsoft site and get most of them to build on my Windows XP machine</li>
<li>
<div>Downloaded and installed the Ruby and Watir test environment. Studied several Watir scripts from Watir and OpenQA sites.</div>
</li>
</ul>
</li>
<li>
<div>Learned How to Create a New Protocol, Register it, and Create Protocol Handlers, using   Asynchronous Pluggable Protocols (3 hours)</div>
<ul>
<li>Read <a href="http://msdn.microsoft.com/en-us/library/aa767743(VS.85).aspx">Asynchronous Pluggable Protocols</a> reference page from MSDN</li>
<li>Found a sample project which demonstrates how to create a new protocol, register that protocol, and invoke that protocol from IE.</li>
<li>
<div>Studied this project (David M Brooks&#8217; &#8220;<a href="http://www.codeproject.com/KB/aspnet/APPHyperlinks.aspx">Custom Hyperlinks Using Asynchronous Pluggable Protocols</a>&#8221; ) and took notes of relevant codes .</div>
</li>
</ul>
</li>
<li>
<div>Learned How to Create and Add a Custom Toolbar to IE (2 hour)</div>
<ul>
<li>Read <a href="http://msdn.microsoft.com/en-us/library/aa753588(VS.85).aspx">Adding Toolbar Buttons</a> page on MSDN</li>
<li>Searched for and found a sample project. This sample project demonstrates how to add a costume toolbar to process RSS feed.</li>
<li>
<div>Studied this sample project (Prafulla Tekawade&#8217;s <a href="http://www.codeproject.com/KB/wtl/rssreaderplugin.aspx">RSS Reader Plug-in for Internet Explorer</a>) and took notes of relevant codes.</div>
</li>
</ul>
</li>
<li>
<div>Learned How to Catch the User Clicking Events When Users Click a Link or Enter a new URL( 2 hours)</div>
<ul>
<li>Read <a href="http://msdn.microsoft.com/en-us/library/aa752042(VS.85).aspx">WebBrowser Control</a> page on event handling</li>
<li>Searched for and found a sample project. This sample project demonstrates how to catch when users hit the refresh button. Got the sample project to build.</li>
<li>Study this sample project (Steven Fox&#8217;s &#8220;<a href="http://www.codeproject.com/KB/IP/detecting_the_ie_refresh.aspx">Detecting the IE Refresh button using IWebBrowser2 and DWebBrowserEvents2 events</a>&#8220;) and took notes of relevant codes to be used in WSG project.</li>
<li>
<div>Modified the sample project so that the new link events are caught, instead of the refresh events. Of course, the ideal is to catch all events, but I&#8217;d like to keep it simple for now.</div>
</li>
</ul>
</li>
<li>Created a preliminary design for WSG plug-in after overcoming the learning curve (2 hour)</li>
</ul>
<p><span style="text-decoration: underline;"><strong>Essential Classes in Preliminary Design:<br />
</strong></span></p>
<ul style="margin-left: 54pt">
<li>
<div>Watir Script Writer:</div>
<ul>
<li>This class will handle writing and saving a valid Watir script</li>
</ul>
</li>
<li>
<div>Watir Script Executor:</div>
<ul>
<li>This class will handle executing a Watir script. It will also handle invalid scripts.</li>
</ul>
</li>
<li>
<div>IE Content Events Handler</div>
<ul>
<li>This class will handle events fired when users click links on the pages or when they enter a new URL in the address field</li>
</ul>
</li>
<li>
<div>WSG Toolbar Events Handler</div>
<ul>
<li>This class will handle events fired when users click buttons in the WSG toolbar to start or stop the recording</li>
</ul>
</li>
</ul>
<p><span style="text-decoration: underline;"><strong>References and Sample Code:<br />
</strong></span></p>
<ol>
<li><a href="http://wtr.rubyforge.org/">Watir site</a></li>
<li>MSDN&#8217;s <a href="http://msdn.microsoft.com/en-us/library/aa737439.aspx">Internet Explorer Development</a> reference page</li>
<li><a href="http://msdn.microsoft.com/en-us/library/aa767743(VS.85).aspx">Asynchronous Pluggable Protocols</a> reference page from MSDN</li>
<li>Prafulla Tekawade&#8217;s &#8220;<a href="http://www.codeproject.com/KB/wtl/rssreaderplugin.aspx">RSS Reader Plug-in for Internet Explorer</a>&#8221; project from The Code Project site</li>
<li>David M Brooks&#8217; &#8220;<a href="http://www.codeproject.com/KB/aspnet/APPHyperlinks.aspx">Custom Hyperlinks Using Asynchronous Pluggable Protocols</a>&#8221; project from The Code Project site</li>
<li>Steven Fox&#8217;s &#8220;<a href="http://www.codeproject.com/KB/IP/detecting_the_ie_refresh.aspx">Detecting the IE Refresh button using IWebBrowser2 and DWebBrowserEvents2 events</a>&#8221; project from The Code Project site</li>
</ol>
<p><a href="http://download.microsoft.com/download/a/f/7/af7777e5-7dcd-4800-8a0a-b18336565f5b/DLL_bestprac.doc">Best Practice for Creating Dlls</a> from Windows Hardware Developer Central</p>
]]></content:encoded>
			<wfw:commentRss>http://www.flex.shallwelearn.com/blog/archives/1118/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Create an Internet Explorer Plug-In Toolbar Part I</title>
		<link>http://www.flex.shallwelearn.com/blog/archives/1098</link>
		<comments>http://www.flex.shallwelearn.com/blog/archives/1098#comments</comments>
		<pubDate>Wed, 24 Jun 2009 12:55:00 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Watir Script Generator Plugin]]></category>
		<category><![CDATA[Windows Development]]></category>

		<guid isPermaLink="false">http://www.flex.shallwelearn.com/blog/archives/1098</guid>
		<description><![CDATA[This is Part I of a new series on creating IE plug-ins. In this article, I will show you how I ported and debugged an existing project from Code Project. So let&#8217;s go! This is what final product will look like. Here are the steps I took to get this plug-in working. Search for available [...]]]></description>
			<content:encoded><![CDATA[<p><strong><span style="font-size:12pt"> </span></strong>This is Part I of a new series on creating IE plug-ins. In this article, I will show you how I ported and debugged an existing project from Code Project. So let&#8217;s go! This is what final product will look like.</p>
<p><img src="http://www.flex.shallwelearn.com/blog/wp-content/uploads/2009/06/062409-1250-createinter21.png" alt="" width="390" height="287" /></p>
<p><span id="more-1098"></span></p>
<p>Here are the steps I took to get this plug-in working.</p>
<ol>
<li>Search for available ways/templates to create an IE plug-in</li>
</ol>
<p>Unfortunately I could not find any Internet Explorer plug-in template, neither from Visual Studio 2008 nor from MSDN nor from googling.</p>
<ol>
<li>Search for open source code snippets or project</li>
</ol>
<p>After a bit digging, I found a relevant and promising project: Prafulla Tekawade&#8217;s <a href="http://www.codeproject.com/KB/wtl/rssreaderplugin.aspx">RSS Reader Plug-in for Internet Explorer</a>.</p>
<p><img src="http://www.flex.shallwelearn.com/blog/wp-content/uploads/2009/06/062409-1250-createinter1.png" alt="" /></p>
<p><img src="http://www.flex.shallwelearn.com/blog/wp-content/uploads/2009/06/062409-1250-createinter2.png" alt="" /></p>
<ol>
<li>Tried to get this project to build</li>
</ol>
<p>I first tried using Visual C++ 2008 Express but to no avails because of missing libraries. I finally had to download and install the 90-day trial version of Microsoft Visual Studio, which I highly recommended. It&#8217;s very easy to use and it&#8217;s free!! Three months should be enough time for you to get your feet wet (very wet) with developing Visual C++ programs.</p>
<p>I had to make the following changes to port this RssReaderPlugin, a Visual Studio 6.0 project, to a Visual Studio 2008 project.  First, double click RssReaderPlugin.sln to start Visual Studio 2008.</p>
<p><img src="http://www.flex.shallwelearn.com/blog/wp-content/uploads/2009/06/062409-1250-createinter3.png" alt="" /></p>
<p>The Visual Studio Conversion Wizard would pop up. Click &#8220;Next&#8221;.</p>
<p><img src="http://www.flex.shallwelearn.com/blog/wp-content/uploads/2009/06/062409-1250-createinter4.png" alt="" /></p>
<p>Keep the default setting (create a backup file) and click &#8220;Next&#8221; to continue.</p>
<p><img src="http://www.flex.shallwelearn.com/blog/wp-content/uploads/2009/06/062409-1250-createinter5.png" alt="" /></p>
<p>Click &#8220;Finish&#8221;.</p>
<p><img src="http://www.flex.shallwelearn.com/blog/wp-content/uploads/2009/06/062409-1250-createinter6.png" alt="" /></p>
<p>Then click &#8220;Close&#8221; to close the windows.</p>
<p><img src="http://www.flex.shallwelearn.com/blog/wp-content/uploads/2009/06/062409-1250-createinter7.png" alt="" /></p>
<p>When the solution is open, build it by &#8220;Build&#8221;-&gt;&#8221;Build Solution&#8221;.</p>
<p><img src="http://www.flex.shallwelearn.com/blog/wp-content/uploads/2009/06/062409-1250-createinter8.png" alt="" /></p>
<p>But you will see this error: &#8220;Error C2061: syntax error : identifier &#8216;IWebBrowser2&#8242;. Double click the error to get to the violating line.</p>
<p><img src="http://www.flex.shallwelearn.com/blog/wp-content/uploads/2009/06/062409-1250-createinter9.png" alt="" /></p>
<p>The <a href="http://msdn.microsoft.com/en-us/library/aa752127(VS.85).aspx">IWebBrowser2</a> class is included in &lt;Exdist.h&gt;. Add the include statement to get rid of all IWebBrowser2 related errors.</p>
<p><img src="http://www.flex.shallwelearn.com/blog/wp-content/uploads/2009/06/062409-1250-createinter10.png" alt="" /></p>
<p>Build again. This time you will get another error :&#8221;error C2664: &#8216;ATL:CWindowImpl&lt;T,TBase&gt;::Create&#8217; : cannot convert parameter 2 from &#8216;int&#8217; to &#8216;RECT &amp;&#8217;. Double click to get to the violating line.</p>
<p><img src="http://www.flex.shallwelearn.com/blog/wp-content/uploads/2009/06/062409-1250-createinter11.png" alt="" /></p>
<p>Change the second argument from NULL to rect.</p>
<p><img src="http://www.flex.shallwelearn.com/blog/wp-content/uploads/2009/06/062409-1250-createinter12.png" alt="" /></p>
<p>Build again. This time it should build without error.</p>
<p><img src="http://www.flex.shallwelearn.com/blog/wp-content/uploads/2009/06/062409-1250-createinter13.png" alt="" /></p>
<p>Note that at this point, not only is this project built, the DLL also has been installed, because the author very considerably adding Custom Build Steps. To view, right click the project name and select &#8220;Property&#8221; from the drop down list.</p>
<p><img src="http://www.flex.shallwelearn.com/blog/wp-content/uploads/2009/06/062409-1250-createinter14.png" alt="" /></p>
<p><img src="http://www.flex.shallwelearn.com/blog/wp-content/uploads/2009/06/062409-1250-createinter15.png" alt="" /></p>
<p>This is the full Command Line entry for Custom Build Step.</p>
<p><img src="http://www.flex.shallwelearn.com/blog/wp-content/uploads/2009/06/062409-1250-createinter16.png" alt="" /></p>
<p>Another way you can register the DLL is by using the register.bat already in the Debug directory.</p>
<p><img src="http://www.flex.shallwelearn.com/blog/wp-content/uploads/2009/06/062409-1250-createinter17.png" alt="" /></p>
<p>Start a new Internet Explorer instance. The Rss Reader Toolbar already has been enabled.</p>
<p>To view the Rss Reader entry from the list of Internet Explorer Add-ons, click &#8220;Tools&#8221;-&gt;&#8221;Manager Add-ons&#8221;-&gt;&#8221;Enable or Disable Add-ons&#8221;.</p>
<p><img src="http://www.flex.shallwelearn.com/blog/wp-content/uploads/2009/06/062409-1250-createinter18.png" alt="" /></p>
<p>There is Rss Reader Toolbar.</p>
<p><img src="http://www.flex.shallwelearn.com/blog/wp-content/uploads/2009/06/062409-1250-createinter19.png" alt="" /></p>
<p>To add it to the viewable panel, go to &#8220;View&#8221;-&gt;&#8221;Toolbars&#8221;, then click &#8220;Rss Reader Toolbar&#8221; to check it.</p>
<p><img src="http://www.flex.shallwelearn.com/blog/wp-content/uploads/2009/06/062409-1250-createinter20.png" alt="" /></p>
<p>Then you should see a RssReader toolbar.</p>
<p><img src="http://www.flex.shallwelearn.com/blog/wp-content/uploads/2009/06/062409-1250-createinter21.png" alt="" /></p>
<p>Now let&#8217;s try running it. Click &#8220;Top Story button&#8221;.</p>
<p><img src="http://www.flex.shallwelearn.com/blog/wp-content/uploads/2009/06/062409-1250-createinter22.png" alt="" /></p>
<p>Ouch! You would see a Debug Assertion Failed message. Don&#8217;t worry – we will take care of it. Click &#8220;Retry&#8221;.</p>
<p><img src="http://www.flex.shallwelearn.com/blog/wp-content/uploads/2009/06/062409-1250-createinter23.png" alt="" /></p>
<p><img src="http://www.flex.shallwelearn.com/blog/wp-content/uploads/2009/06/062409-1250-createinter24.png" alt="" /></p>
<p><img src="http://www.flex.shallwelearn.com/blog/wp-content/uploads/2009/06/062409-1250-createinter25.png" alt="" /></p>
<p>Make sure that RssReaderPlugin project is open and select it from the Possible Debuggers list.</p>
<p><img src="http://www.flex.shallwelearn.com/blog/wp-content/uploads/2009/06/062409-1250-createinter26.png" alt="" /></p>
<p>Click Break.</p>
<p><img src="http://www.flex.shallwelearn.com/blog/wp-content/uploads/2009/06/062409-1250-createinter27.png" alt="" /></p>
<p><span style="font-size:10pt">Go to the source panel. You should see a small Yellow Arrow, indicating the breakpoint. This line tells us that uFormat contains DT_MODIFYSTRING option, which tells DrawText to modify the specified string to match the displayed text. This value has no effect unless DT_END_ELLIPSIS or DT_PATH_ELLIPSIS is specified.  This option is only allowed for Windows CE platform (_WIN32_WCE).<br />
</span></p>
<p><img src="http://www.flex.shallwelearn.com/blog/wp-content/uploads/2009/06/062409-1250-createinter28.png" alt="" /></p>
<p><span style="font-size:10pt">To find out where DT_MODIFYSTRING option is set (we need to unset it), use the Find and Replace tool from Visual Studio (also available in the Express edition). Go to &#8220;Edit&#8221;-&gt;&#8221;Find and Replace&#8221;.<br />
</span></p>
<p><img src="http://www.flex.shallwelearn.com/blog/wp-content/uploads/2009/06/062409-1250-createinter29.png" alt="" /></p>
<p>Click the first find, which is on line 263 of RRPNewsButton.cpp and delete all DT_MODIFYSTRING from the OR combo.</p>
<p><img src="http://www.flex.shallwelearn.com/blog/wp-content/uploads/2009/06/062409-1250-createinter30.png" alt="" /></p>
<p><img src="http://www.flex.shallwelearn.com/blog/wp-content/uploads/2009/06/062409-1250-createinter31.png" alt="" /></p>
<p>Click the second find, which is on line 347 of RRPNewsButton.cpp and delete all DT_MODIFYSTRING from the OR combo.</p>
<p><img src="http://www.flex.shallwelearn.com/blog/wp-content/uploads/2009/06/062409-1250-createinter32.png" alt="" /><img src="http://www.flex.shallwelearn.com/blog/wp-content/uploads/2009/06/062409-1250-createinter33.png" alt="" /></p>
<p>To compile, click the Stop Debugging button.</p>
<p><img src="http://www.flex.shallwelearn.com/blog/wp-content/uploads/2009/06/062409-1250-createinter34.png" alt="" /></p>
<p>Click Continue to keep running to the end.</p>
<p><img src="http://www.flex.shallwelearn.com/blog/wp-content/uploads/2009/06/062409-1250-createinter35.png" alt="" /></p>
<p>Then now rebuild and re-register the DLL. This time it should work without throwing exception.</p>
<p><img src="http://www.flex.shallwelearn.com/blog/wp-content/uploads/2009/06/062409-1250-createinter36.png" alt="" /></p>
<p>To view the RSS feed from shallwelearn.com,  click the RSS feed button.</p>
<p><img src="http://www.flex.shallwelearn.com/blog/wp-content/uploads/2009/06/062409-1250-createinter37.png" alt="" /></p>
<p>You will be taken to the RSS page of shallwelearn.com, which is:</p>
<p>http://shallwelearn.com/index.php?format=feed&amp;type=rss</p>
<p><img src="http://www.flex.shallwelearn.com/blog/wp-content/uploads/2009/06/062409-1250-createinter38.png" alt="" /></p>
<p><span style="font-size:10pt">To set the RSS page to shallwelearn&#8217;s RSS feed, click &#8220;Rss Reader&#8221; to open the Configuration Settings Window.<br />
</span></p>
<p><img src="http://www.flex.shallwelearn.com/blog/wp-content/uploads/2009/06/062409-1250-createinter39.png" alt="" /></p>
<p><span style="font-size:10pt">Right now the code will always just shows the first one in the RSS item list, which is &#8220;Top Stories&#8221;, so we copy and paste the ShallWeLearn RSS feed as the Link of the RSS of the Top Stories. Click Save to save.<br />
</span></p>
<p><img src="http://www.flex.shallwelearn.com/blog/wp-content/uploads/2009/06/062409-1250-createinter40.png" alt="" /></p>
<p><span style="font-size:10pt">Then &#8220;Cancel&#8221; to close the pop-up window.<br />
</span></p>
<p><img src="http://www.flex.shallwelearn.com/blog/wp-content/uploads/2009/06/062409-1250-createinter41.png" alt="" /></p>
<p>Now if you click Top Stories button, you should see the updated RSS feed.</p>
<p><img src="http://www.flex.shallwelearn.com/blog/wp-content/uploads/2009/06/062409-1250-createinter42.png" alt="" /></p>
<p>DONE!! In Next Article of this Series, I will use this project as a template to start create my own toolbar.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.flex.shallwelearn.com/blog/archives/1098/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
