<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	xmlns:georss="http://www.georss.org/georss" xmlns:geo="http://www.w3.org/2003/01/geo/wgs84_pos#" xmlns:media="http://search.yahoo.com/mrss/"
	>

<channel>
	<title>The Testing Blog &#187; test automation</title>
	<atom:link href="http://thetestingblog.com/category/test-automation/feed/" rel="self" type="application/rss+xml" />
	<link>http://thetestingblog.com</link>
	<description>Why, testing, of course!</description>
	<lastBuildDate>Wed, 15 Feb 2012 13:01:56 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.com/</generator>
<cloud domain='thetestingblog.com' port='80' path='/?rsscloud=notify' registerProcedure='' protocol='http-post' />
<image>
		<url>http://s2.wp.com/i/buttonw-com.png</url>
		<title>The Testing Blog &#187; test automation</title>
		<link>http://thetestingblog.com</link>
	</image>
	<atom:link rel="search" type="application/opensearchdescription+xml" href="http://thetestingblog.com/osd.xml" title="The Testing Blog" />
	<atom:link rel='hub' href='http://thetestingblog.com/?pushpress=hub'/>
		<item>
		<title>Have you heard about NUnit Attributes and how they&#8217;re awesome?</title>
		<link>http://thetestingblog.com/2010/08/31/have-you-heard-about-nunit-attributes-and-how-theyre-awesome/</link>
		<comments>http://thetestingblog.com/2010/08/31/have-you-heard-about-nunit-attributes-and-how-theyre-awesome/#comments</comments>
		<pubDate>Tue, 31 Aug 2010 23:16:50 +0000</pubDate>
		<dc:creator>Daniel Brown</dc:creator>
				<category><![CDATA[NUnit]]></category>
		<category><![CDATA[open source]]></category>
		<category><![CDATA[Selenium]]></category>
		<category><![CDATA[test automation]]></category>
		<category><![CDATA[Tools]]></category>

		<guid isPermaLink="false">http://thetestingblog.com/?p=425</guid>
		<description><![CDATA[VERY IMPORTANT!!! Some attributes in this article are only available in NUnit 2.5 and later. I would strongly recommend upgrading your NUnit to the newest version. Okay, so, have you heard about NUnit attributes, and how they&#8217;re awesome? Sure you&#8217;ve heard of Setup, Test, TestFixture, and TearDown? But how about Values? How about Range? The [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=thetestingblog.com&#038;blog=8467555&#038;post=425&#038;subd=thetestingblog&#038;ref=&#038;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p><strong>VERY IMPORTANT!!! Some attributes in this article are only available in NUnit 2.5 and later.  I would strongly recommend upgrading your NUnit to the newest version.</strong></p>
<p>Okay, so, have you heard about NUnit attributes, and how they&#8217;re awesome?<br />
Sure you&#8217;ve heard of Setup, Test, TestFixture, and TearDown?  But how about Values?  How about Range?</p>
<p>The Values attribute allows you to run the same test several times with different values.  It makes it where you&#8217;re not doing something crazy like copy and pasting the same test, over and over again!  I was close to that situation, but it hurt my soul too much to do that.  So, in order to save my soul, I had to seek a path for redemption.  Here&#8217;s what I found:</p>
<p>Okay, to try this, you may need to set up a sample test.  If you need to start from scratch, check out my End-to-End Example: http://thetestingblog.com/2009/09/10/selenium-rc-in-c-using-nunit-an-end-to-end-example/</p>
<p>My example test verifies that the text &#8220;Daniel Brown&#8221; is present on the main testing blog page&#8211;a simple pass or fail.  But imagine we wanted to run the test 3 times, each time verifying the presence of a different Testing Blog author.  Here&#8217;s how we would do it using the Values attribute:</p>
<p><pre class="brush: csharp;">
        [Test]
        public void ValuesTest([Values(&quot;Daniel Brown&quot;, &quot;Marisa Seal&quot;, &quot;Josh Carroll&quot;)] string textPresent)
        {
            selenium.Open(&quot;http://www.google.com&quot;);
            selenium.Type(&quot;q&quot;, &quot;thetestingblog.com&quot;);
            selenium.Click(&quot;btnI&quot;);
            selenium.WaitForPageToLoad(&quot;60000&quot;);
            Assert.IsTrue(selenium.IsTextPresent(textPresent));
        }
</pre></p>
<p>As you can see, we&#8217;re basically passing the argument &#8220;textPresent&#8221; into the method.  The values are what you want the argument to be.  For each value, run the test once with &#8220;textPresent&#8221; = to that value:<br />
<code>[Values("Daniel Brown", "Marisa Seal", "Josh Carroll")] string stringPresent</code></p>
<p>So, in the case of this test; here&#8217;s how it would run:<br />
SetupTest();<br />
ValuesTest(&#8220;Daniel Brown&#8221;);<br />
TeardownTest();<br />
SetupTest();<br />
ValuesTest(&#8220;Marisa Seal&#8221;);<br />
TeardownTest();<br />
SetupTest();<br />
ValuesTest(&#8220;Josh Carroll&#8221;);<br />
TeardownTest();</p>
<p>This is how it looks in the test runner:<br />
<a href="http://thetestingblog.files.wordpress.com/2010/08/49.jpg"><img class="aligncenter size-full wp-image-435" title="49" src="http://thetestingblog.files.wordpress.com/2010/08/49.jpg?w=544" alt=""   /></a></p>
<p>Okay, that wasn&#8217;t too bad.  Now, let&#8217;s go a crazy.  Let&#8217;s get nuts.  Potentially throwing best practices to the wind.  We&#8217;re going make this example where it pulls the values from a text file instead of hard coding them.  To do that, let&#8217;s add a text file to our project:</p>
<p>Right click on your project (&#8220;TestingBlogSeleniumRc&#8221;) in the Solution Explorer -&gt; <strong>Add </strong>-&gt; <strong>New Item&#8230; </strong></p>
<p>Select Text File and call it ValueList.txt</p>
<p>Open the file in your editor and type the three values into the text file.  One per line:</p>
<div id="_mcePaste">Daniel Brown</div>
<div id="_mcePaste">Marisa Seal</div>
<div id="_mcePaste">Josh Carroll</div>
<div><a href="http://thetestingblog.files.wordpress.com/2010/08/60.jpg"><img class="aligncenter size-full wp-image-440" title="60" src="http://thetestingblog.files.wordpress.com/2010/08/60.jpg?w=544&h=224" alt="" width="544" height="224" /></a></div>
<p>Next we want to make sure that the text file is copied over into the bin folder on build.</p>
<p>Right click on your project (&#8220;TestingBlogSeleniumRc&#8221;) in the Solution Explorer and select <strong>Properties</strong>.  Then select <strong>Build Events</strong>.  Under the <strong>Pre-build event command line: </strong>(or post-build; it doesn&#8217;t matter) paste in:</p>
<p><code>copy "$(ProjectDir)ValueList.txt" "$(TargetDir)"</code></p>
<p><a href="http://thetestingblog.files.wordpress.com/2010/08/59.jpg"><img class="aligncenter size-full wp-image-438" title="59" src="http://thetestingblog.files.wordpress.com/2010/08/59.jpg?w=544&h=272" alt="" width="544" height="272" /></a></p>
<p>Our test is going to be looking for ValueList.txt so that copy command assures that it&#8217;s in the same folder as the test dll.</p>
<p><strong>(FULL CODE EXAMPLE BELOW)</strong></p>
<ul>
<li>We need to add a reference to System.IO</li>
<li>Next we&#8217;re going to add a global string array to our class called <strong>textPresentList</strong></li>
<li>We are going to read the ValueList.txt file into an array in our setup.  As coded, it should only be read in the first time the SetupTest() method is run.  If you&#8217;re a Unit Test purist, you could easily change it to read the file in every time, but I thought it seemed like a waste.</li>
<li>Next we need to add the <span style="color:#33cccc;">Range </span>attribute to a copied and renamed version of our first test.  The range should be hard coded from 0 to 2.  (I tried to do something clever like put it from 0 to textPresentList.Length-1, but the compile wouldn&#8217;t have it.  These NUnit attribute values, it appears have to be somewhat static.  This kludge that I&#8217;m showing is way to get around the static nature if only a little bit.  This way the values can be dynamic even if the number of values can&#8217;t be.  By the way, if anyone has a better idea to make it more dynamic, please post it.)</li>
<li>Change the <strong>selenium.IsTextPresent(textPresent)</strong> to <strong>selenium.IsTextPresent(textPresentList[i])</strong>.</li>
<li>Then Compile and Run.</li>
</ul>
<p><a href="http://thetestingblog.files.wordpress.com/2010/08/63.jpg"><img class="aligncenter size-full wp-image-441" title="63" src="http://thetestingblog.files.wordpress.com/2010/08/63.jpg?w=544" alt=""   /></a></p>
<p>You won&#8217;t be able to see the values from the file in the Test Runner, but you could write the value translations to the console so that you could see which index corresponds to which value:<br />
<code>Console.WriteLine("Index " + i +": " + textPresentList[i]);</code></p>
<p>In the Test Runner, select the <strong>Text Output</strong> tab to view the output:</p>
<p><a href="http://thetestingblog.files.wordpress.com/2010/08/66.jpg"><img class="aligncenter size-full wp-image-444" title="66" src="http://thetestingblog.files.wordpress.com/2010/08/66.jpg?w=544&h=262" alt="" width="544" height="262" /></a></p>
<p>The whole point of this post is not to show you what to do, but instead to open up your mind to possibilities.  NUnit has some cool functionality, and most of us never scrape the surface of it&#8217;s potential.  I challenge you to go and explore the various attributes available for yourself.  Here&#8217;s the link: <a href="http://nunit.org/index.php?p=attributes&amp;r=2.5.7">http://nunit.org/index.php?p=attributes&amp;r=2.5.7</a></p>
<p><strong>Remember upgrade your NUnit to the newest version.  Chances are that you&#8217;re not current.</strong></p>
<p><strong>FULL CODE:</strong></p>
<p><pre class="brush: csharp;">
using System;
using System.Text;
using System.IO;
using System.Text.RegularExpressions;
using System.Threading;
using NUnit.Framework;
using Selenium;

namespace TestingBlogSeleniumRc
{
	[TestFixture]
	public class FirstTest
	{
		private ISelenium selenium;
        private string[] textPresentList;

		[SetUp]
		public void SetupTest()
		{
            if (textPresentList == null)
                textPresentList = File.ReadAllLines(&quot;ValueList.txt&quot;);
			selenium = new DefaultSelenium(&quot;localhost&quot;, 4444, &quot;*iexplore&quot;, &quot;http://www.google.com/&quot;);
			selenium.Start();
		}

		[TearDown]
		public void TeardownTest()
		{
		    selenium.Stop();
		}

        [Test]
        public void DynamicValuesTest([Range(0,2)] int i)
		{
			selenium.Open(&quot;http://www.google.com&quot;);
			selenium.Type(&quot;q&quot;, &quot;thetestingblog.com&quot;);
			selenium.Click(&quot;btnI&quot;);
			selenium.WaitForPageToLoad(&quot;60000&quot;);
            Console.WriteLine(&quot;Index &quot; + i +&quot;: &quot; + textPresentList[i]);
            Assert.IsTrue(selenium.IsTextPresent(textPresentList[i]));
		}
        [Test]
        public void ValuesTest([Values(&quot;Daniel Brown&quot;, &quot;Marisa Seal&quot;, &quot;Josh Carroll&quot;)] string textPresent)
        {
            selenium.Open(&quot;http://www.google.com&quot;);
            selenium.Type(&quot;q&quot;, &quot;thetestingblog.com&quot;);
            selenium.Click(&quot;btnI&quot;);
            selenium.WaitForPageToLoad(&quot;60000&quot;);
            Assert.IsTrue(selenium.IsTextPresent(textPresent));
        }
	}
}</pre></p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/thetestingblog.wordpress.com/425/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/thetestingblog.wordpress.com/425/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/thetestingblog.wordpress.com/425/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/thetestingblog.wordpress.com/425/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/thetestingblog.wordpress.com/425/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/thetestingblog.wordpress.com/425/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/thetestingblog.wordpress.com/425/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/thetestingblog.wordpress.com/425/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/thetestingblog.wordpress.com/425/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/thetestingblog.wordpress.com/425/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/thetestingblog.wordpress.com/425/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/thetestingblog.wordpress.com/425/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/thetestingblog.wordpress.com/425/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/thetestingblog.wordpress.com/425/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=thetestingblog.com&#038;blog=8467555&#038;post=425&#038;subd=thetestingblog&#038;ref=&#038;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://thetestingblog.com/2010/08/31/have-you-heard-about-nunit-attributes-and-how-theyre-awesome/feed/</wfw:commentRss>
		<slash:comments>12</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/43a80f3d05753a9af40a3725839bf178?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">aubrownds</media:title>
		</media:content>

		<media:content url="http://thetestingblog.files.wordpress.com/2010/08/49.jpg" medium="image">
			<media:title type="html">49</media:title>
		</media:content>

		<media:content url="http://thetestingblog.files.wordpress.com/2010/08/60.jpg" medium="image">
			<media:title type="html">60</media:title>
		</media:content>

		<media:content url="http://thetestingblog.files.wordpress.com/2010/08/59.jpg" medium="image">
			<media:title type="html">59</media:title>
		</media:content>

		<media:content url="http://thetestingblog.files.wordpress.com/2010/08/63.jpg" medium="image">
			<media:title type="html">63</media:title>
		</media:content>

		<media:content url="http://thetestingblog.files.wordpress.com/2010/08/66.jpg" medium="image">
			<media:title type="html">66</media:title>
		</media:content>
	</item>
		<item>
		<title>Selenium RC In C# as a Console App: Another End-To-End Example</title>
		<link>http://thetestingblog.com/2010/02/02/selenium-rc-in-console-app/</link>
		<comments>http://thetestingblog.com/2010/02/02/selenium-rc-in-console-app/#comments</comments>
		<pubDate>Tue, 02 Feb 2010 18:26:10 +0000</pubDate>
		<dc:creator>Daniel Brown</dc:creator>
				<category><![CDATA[open source]]></category>
		<category><![CDATA[test automation]]></category>
		<category><![CDATA[Tools]]></category>

		<guid isPermaLink="false">http://thetestingblog.com/?p=364</guid>
		<description><![CDATA[The purpose of this post is to show people how to wrap a Selenium RC test up into a console app (*.exe) so can been executed from the command line.  This is a solution makes it where you don&#8217;t have to have NUnit involved. Déjà vu all over again! Another basic Selenium example. What the [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=thetestingblog.com&#038;blog=8467555&#038;post=364&#038;subd=thetestingblog&#038;ref=&#038;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>The purpose of this post is to show people how to wrap a Selenium RC test up into a console app (*.exe) so can been executed from the command line.  This is a solution makes it where you don&#8217;t have to have NUnit involved.</p>
<p>Déjà vu all over again!  Another basic Selenium example.  What the  heck!?  Can&#8217;t this guy do anything else?</p>
<p>Well, I agree this is somewhat repetitive, but I hope that this sequel will be in the league of Empire Strikes Back or Star Trek: The Wrath of Khan.  Both movies, though they were sequels, were arguably greater than the originals. These sequels introduce us to the likes of Ricardo Montalban playing &#8220;Khan&#8221; and Billy Dee Williams playing &#8220;Lando Calrissian&#8221;.  And of course,  a muppet playing &#8220;Yoda&#8221;.</p>
<p><a href="http://thetestingblog.files.wordpress.com/2010/02/collage1.jpg"><img class="aligncenter size-full wp-image-366" title="collage" src="http://thetestingblog.files.wordpress.com/2010/02/collage1.jpg?w=544&h=450" alt="" width="544" height="450" /></a></p>
<p>Of course, many sequels start off with the desire to be Empire, and instead they end up being:</p>
<ul>
<li>Caddyshack II</li>
<li>Beastmaster 2: Through the Portal of Time</li>
<li>Speed 2: Cruise Control</li>
<li>Batman and Robin (No, we don&#8217;t need nipples on the Batman suit, Joel Schumacher.  But thanks for asking.)</li>
<li>Mannequin: On the Move.</li>
<li>Or the biggest sacrileges of all time Godfather III</li>
<li>And Episode I (Empire, it is not!).</li>
</ul>
<p>My hope is that this post doesn&#8217;t suck like those movies.  At the very least it&#8217;s nipple and Clooney free.</p>
<hr />First off, you need to get all these things (if you don&#8217;t have them):</p>
<ul>
<li><a href="http://release.seleniumhq.org/selenium-remote-control/1.0.1/selenium-remote-control-1.0.1-dist.zip">Selenium RC</a></li>
<li><a href="http://www.mozilla.com/products/download.html?product=firefox-3.5.2&amp;os=win&amp;lang=en-US">Firefox</a></li>
<li><a href="http://release.openqa.org/selenium-ide/1.0.2/selenium-ide-1.0.2.xpi">Selenium IDE</a></li>
<li><a href="http://www.java.com/en/download/index.jsp">Java Runtime Environment</a> (You should already have this)</li>
<li><a href="http://www.microsoft.com/express/Downloads/#2008-Visual-CS">Visual C# 2008 Express Edition </a> (Only get this if you don&#8217;t have a full version of Visual Studio)</li>
</ul>
<hr /><strong>Install instructions for the downloads:</strong></p>
<p><strong>Selenium RC</strong><br />
-No installation necessary. Just find a permanent location and unzip it there. I unzipped mine at <span style="color:#0000ff;">C:\</span> just to make things simple</p>
<p><strong>Firefox, Visual Studio Express, and Java</strong><br />
-Just run the respective installs with all defaults selected.</p>
<p><strong>Selenium IDE</strong><br />
-To install, right click on the file and select &#8220;Open With&#8230;&#8221;<br />
-Select Firefox in the programs list. If it&#8217;s not in the immediate menu, browse to it. (default location should be &#8220;<span style="color:#0000ff;">C:\Program Files\Mozilla Firefox\firefox.exe</span>&#8220;<br />
-When Firefox launches, click button in the dialog box that says &#8220;Install Now&#8221;.<br />
-After the install of the plug-in, hit the &#8220;Restart Firefox&#8221; button when you see it.</p>
<hr /><strong>Phase One: Record a Test using Selenium IDE</strong></p>
<p>Okay, so, now that you have the tools, we&#8217;re going to record a simple test in Selenium IDE. Even though we want to eventually run the test in Selenium RC, Selenium IDE is a great tool for getting the basic test recorded since it&#8217;s all UI point and click.</p>
<ul>
<li>Start up Firefox.</li>
<li>Click on the &#8220;Tools&#8221; menu and click on &#8220;Selenium IDE&#8221;</li>
<li><em>(Take your time to explore the Selenium IDE form)</em></li>
<li>Notice that it&#8217;s already recording.  The red circle button on the right side is pressed in:</li>
<li>Type &#8220;<span style="color:#0000ff;">www.google.com</span>&#8221; the main Firefox browser address bar and navigate to it.</li>
<li>In the search box, type in &#8220;<span style="color:#0000ff;">thetestingblog.com</span>&#8221; and hit the &#8220;I&#8217;m Feeling Lucky&#8221; button.</li>
<li><em>Notice in your Selenium IDE window that steps are being recorded.</em></li>
<li><em>With any luck, you hopefully landed on this blog&#8217;s home page.</em></li>
<li>Highlight the text &#8220;Daniel Brown&#8221; on the page, right click.  You should select the option that says &#8220;VerifyTextPresent Daniel Brown&#8221;.  See below:</li>
</ul>
<p><img class="aligncenter size-full wp-image-194" title="Screenshot_VerifyTextPresent" src="http://thetestingblog.files.wordpress.com/2009/09/screenshot_verifytextpresent.jpg?w=544&h=378" alt="Screenshot_VerifyTextPresent" width="544" height="378" /></p>
<ul>
<li><em>Okay, we got our test recorded.  Now let&#8217;s run it to make sure it passes.</em></li>
<li>Unclick the red circle button to turn off recording.</li>
<li>Click on the green play triangle with the single bar to run the test</li>
</ul>
<p><img class="aligncenter size-full wp-image-197" title="Screenshot_PassedIDETest" src="http://thetestingblog.files.wordpress.com/2009/09/screenshot_passedidetest2.jpg?w=544" alt="Screenshot_PassedIDETest"   /></p>
<ul>
<li>All green, it passed.  Good.</li>
<li>Now we want to convert this test to C#.</li>
<li>Select &#8220;Options -&gt;Format -&gt; C# &#8211; Selenium RC&#8221; from the Selenium IDE window.</li>
</ul>
<p><img class="aligncenter size-full wp-image-198" title="Screenshot_ConvertToCSharp" src="http://thetestingblog.files.wordpress.com/2009/09/screenshot_converttocsharp.jpg?w=544" alt="Screenshot_ConvertToCSharp"   /></p>
<ul>
<li>Next select all the C# code and copy it.</li>
</ul>
<hr /><strong>Phase Two: Setup the C# Console App</strong></p>
<ul>
<li>Open up Visual Studio</li>
<li>Select &#8220;File -&gt;New -&gt;Project&#8221;</li>
<li>In the New Project window under project types, select &#8220;Visual C# -&gt;Windows&#8221;</li>
<li>Select the &#8220;Console Application&#8221; Template and name it something like &#8220;TestingBlogSeleniumTest&#8221; and click &#8220;Ok&#8221;.</li>
<li>It will create the project along with a file called &#8220;Program.cs&#8221;.  Paste your SeleniumIDE test into Notepad.  You&#8217;re going to take pieces out of the test and put it in &#8220;Program.cs&#8221;.</li>
</ul>
<p><a href="http://thetestingblog.files.wordpress.com/2010/02/toppart2.jpg"><img class="aligncenter size-full wp-image-374" title="TopPart" src="http://thetestingblog.files.wordpress.com/2010/02/toppart2.jpg?w=544&h=214" alt="" width="544" height="214" /></a></p>
<ol>
<li>Add the using references from the SeleniumIDE test.  Replace any that are there.</li>
<li>Add the &#8220;ISelenium&#8221; and &#8220;StringBuilder&#8221; object references inside the Main() method.  As you see, I removed the &#8220;private&#8221; access control prefixes.  We don&#8217;t need them.</li>
<li>Add the body of the SetupTest() method after the object references.  (I put a comment to designate that it was part of the setup.)</li>
<li>Change &#8220;*chrome&#8221; to &#8220;*iexplore&#8221; for Internet Explorer.  Use &#8220;*firefox&#8221; for Firefox.  (There are other browser options, but those work best.)</li>
<li>Change the URL to the site you start your test on.  In this case, change that URL to &#8220;http://www.google.com/&#8221; since we&#8217;re starting from Google.</li>
</ol>
<p><a href="http://thetestingblog.files.wordpress.com/2010/02/paste-in-bodies2.jpg"><img class="aligncenter size-full wp-image-375" title="Paste in Bodies" src="http://thetestingblog.files.wordpress.com/2010/02/paste-in-bodies2.jpg?w=544&h=412" alt="" width="544" height="412" /></a></p>
<p>6. Paste body of the TheUntitledTest() method into the Main() method.</p>
<p>7. Paste body of the TeardownTest() method into the Main() method.</p>
<p>8.  Get rid of the Try/Catch blocks on Teardown.</p>
<p>9. Get rid of the StringBuilder references.</p>
<p><a href="http://thetestingblog.files.wordpress.com/2010/02/replacebodytext1.jpg"><img class="aligncenter size-full wp-image-376" title="ReplaceBodyText" src="http://thetestingblog.files.wordpress.com/2010/02/replacebodytext1.jpg?w=544&h=317" alt="" width="544" height="317" /></a></p>
<p>10.  Get rid of the Try/Catch block in the test body, replacing it with an if statement that writes to the console window if true (See my code below).  Notice that I have to cast the Selenium.IsTextPresent statement as a boolean.  I don&#8217;t understand why it doesn&#8217;t work without it because the return type for that method should be boolean.  But whatever.  I&#8217;m just dummy tester; what do I know?</p>
<p><a href="http://thetestingblog.files.wordpress.com/2010/02/closeup.jpg"><img class="aligncenter size-full wp-image-372" title="closeup" src="http://thetestingblog.files.wordpress.com/2010/02/closeup.jpg?w=544&h=120" alt="" width="544" height="120" /></a></p>
<ul>
<li>Next we need to add all the references so this thing will run.</li>
<li>Go to the solution explorer, and right click on the &#8220;References&#8221; and select &#8220;Add Reference&#8230;&#8221;</li>
<li>Hit the &#8220;Browse&#8221; tab and navigate to where you unzipped your SeleniumRC files.  Look in the dotnet client driver folder.  Here&#8217;s the path to mine:</li>
</ul>
<p><span style="color:#0000ff;">C:\selenium-remote-control-1.0.1\selenium-dotnet-client-driver-1.0.1\</span></p>
<ul>
<li>Once you navigate to where the proper *.dlls are, select all of them and click &#8220;OK&#8221; to add them to the project.  (I know you can probably get away with adding less, but let&#8217;s keep it simple.)</li>
</ul>
<p><img class="aligncenter size-full wp-image-203" title="Add References" src="http://thetestingblog.files.wordpress.com/2009/09/add-references1.jpg?w=544&h=292" alt="Add References" width="544" height="292" /></p>
<ul>
<li>Build the project to see if it works.  (Mine worked.  Hopefully yours did too.)</li>
</ul>
<hr /><strong>Phase Three: Running the Selenium RC test Console App</strong></p>
<ul>
<li>In order to run the Selenium RC test, you first have to have the Selenium RC server running.  The Selenium RC server folder should be in the files you unzipped.  Normally, I have a batch file on my desktop created to run the Selenium Server, but for our purposes, we&#8217;ll just run this from the &#8220;Start -&gt; Run&#8221; commandline, using this command:</li>
</ul>
<p><span style="color:#0000ff;">java -jar C:\selenium-remote-control-1.0.1\selenium-server-1.0.1\selenium-server.jar</span></p>
<ul>
<li>You should see some a dos window popup, and you will see something like the screenshot below.  DON&#8217;T CLOSE IT WHILE TESTING; IT NEEDS TO STAY RUNNING.  If you don&#8217;t have Java installed, this won&#8217;t work.  But most people should already have Java.</li>
</ul>
<p><img class="aligncenter size-full wp-image-205" title="SeleniumServer" src="http://thetestingblog.files.wordpress.com/2009/09/seleniumserver.jpg?w=544&h=272" alt="SeleniumServer" width="544" height="272" /></p>
<p>Next you need to select Debug from your Visual Studio menu and select &#8220;Start Without Debugging&#8221;. (I&#8217;m choosing this option because it doesn&#8217;t close the console window after the end of execution.  The debug option does.)</p>
<p><a href="http://thetestingblog.files.wordpress.com/2010/02/start.jpg"><img class="aligncenter size-full wp-image-377" title="Start" src="http://thetestingblog.files.wordpress.com/2010/02/start.jpg?w=544&h=306" alt="" width="544" height="306" /></a></p>
<p>You should see the Selenium window(s) pop-up.  And it should do it&#8217;s thing.  When it&#8217;s finished, you should see something like this:</p>
<p><a href="http://thetestingblog.files.wordpress.com/2010/02/19.jpg"><img class="aligncenter size-full wp-image-378" title="19" src="http://thetestingblog.files.wordpress.com/2010/02/19.jpg?w=544&h=274" alt="" width="544" height="274" /></a></p>
<p>So, where is my test executable?  Well, it&#8217;s in the bin\debug folder of the project.  For me, the path to it looks like this:</p>
<p>C:\Documents and Settings\dbrown\My Documents\Visual Studio 2008\Projects\TestingBlogSeleniumTest\TestingBlogSeleniumTest\bin\Debug\</p>
<p>So, what do I need to run the program?  Just take the executable file and the dll&#8217;s.  Make sure the dll&#8217;s are in the same folder as the test when you execute it, otherwise you will get a big fat error.  If you send the executable to someone, make sure you send the dll&#8217;s too.</p>
<p><a href="http://thetestingblog.files.wordpress.com/2010/02/debugfolder.jpg"><img class="aligncenter size-full wp-image-380" title="debugfolder" src="http://thetestingblog.files.wordpress.com/2010/02/debugfolder.jpg?w=544&h=265" alt="" width="544" height="265" /></a></p>
<p>Remember if you port that executable to another computer, it needs to be a Windows box with the .NET framework installed and Selenium server needs to be running.  I hope this actually helps someone.  I&#8217;m going to post some tricks to &#8220;sex up&#8221; your console app.  Be looking for them shortly. <img src='http://s1.wp.com/wp-includes/images/smilies/icon_wink.gif' alt=';)' class='wp-smiley' /> </p>
<p>Sorry, I still haven&#8217;t figured out Selenium GRID good enough to post on it.  Maybe Marisa could post on it?  She&#8217;s awesome like that.</p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/thetestingblog.wordpress.com/364/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/thetestingblog.wordpress.com/364/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/thetestingblog.wordpress.com/364/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/thetestingblog.wordpress.com/364/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/thetestingblog.wordpress.com/364/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/thetestingblog.wordpress.com/364/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/thetestingblog.wordpress.com/364/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/thetestingblog.wordpress.com/364/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/thetestingblog.wordpress.com/364/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/thetestingblog.wordpress.com/364/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/thetestingblog.wordpress.com/364/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/thetestingblog.wordpress.com/364/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/thetestingblog.wordpress.com/364/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/thetestingblog.wordpress.com/364/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=thetestingblog.com&#038;blog=8467555&#038;post=364&#038;subd=thetestingblog&#038;ref=&#038;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://thetestingblog.com/2010/02/02/selenium-rc-in-console-app/feed/</wfw:commentRss>
		<slash:comments>32</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/43a80f3d05753a9af40a3725839bf178?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">aubrownds</media:title>
		</media:content>

		<media:content url="http://thetestingblog.files.wordpress.com/2010/02/collage1.jpg" medium="image">
			<media:title type="html">collage</media:title>
		</media:content>

		<media:content url="http://thetestingblog.files.wordpress.com/2009/09/screenshot_verifytextpresent.jpg" medium="image">
			<media:title type="html">Screenshot_VerifyTextPresent</media:title>
		</media:content>

		<media:content url="http://thetestingblog.files.wordpress.com/2009/09/screenshot_passedidetest2.jpg" medium="image">
			<media:title type="html">Screenshot_PassedIDETest</media:title>
		</media:content>

		<media:content url="http://thetestingblog.files.wordpress.com/2009/09/screenshot_converttocsharp.jpg" medium="image">
			<media:title type="html">Screenshot_ConvertToCSharp</media:title>
		</media:content>

		<media:content url="http://thetestingblog.files.wordpress.com/2010/02/toppart2.jpg" medium="image">
			<media:title type="html">TopPart</media:title>
		</media:content>

		<media:content url="http://thetestingblog.files.wordpress.com/2010/02/paste-in-bodies2.jpg" medium="image">
			<media:title type="html">Paste in Bodies</media:title>
		</media:content>

		<media:content url="http://thetestingblog.files.wordpress.com/2010/02/replacebodytext1.jpg" medium="image">
			<media:title type="html">ReplaceBodyText</media:title>
		</media:content>

		<media:content url="http://thetestingblog.files.wordpress.com/2010/02/closeup.jpg" medium="image">
			<media:title type="html">closeup</media:title>
		</media:content>

		<media:content url="http://thetestingblog.files.wordpress.com/2009/09/add-references1.jpg" medium="image">
			<media:title type="html">Add References</media:title>
		</media:content>

		<media:content url="http://thetestingblog.files.wordpress.com/2009/09/seleniumserver.jpg" medium="image">
			<media:title type="html">SeleniumServer</media:title>
		</media:content>

		<media:content url="http://thetestingblog.files.wordpress.com/2010/02/start.jpg" medium="image">
			<media:title type="html">Start</media:title>
		</media:content>

		<media:content url="http://thetestingblog.files.wordpress.com/2010/02/19.jpg" medium="image">
			<media:title type="html">19</media:title>
		</media:content>

		<media:content url="http://thetestingblog.files.wordpress.com/2010/02/debugfolder.jpg" medium="image">
			<media:title type="html">debugfolder</media:title>
		</media:content>
	</item>
		<item>
		<title>Wrapping my mind around Slim Query Tables</title>
		<link>http://thetestingblog.com/2009/09/18/slim-query-tables/</link>
		<comments>http://thetestingblog.com/2009/09/18/slim-query-tables/#comments</comments>
		<pubDate>Fri, 18 Sep 2009 19:00:13 +0000</pubDate>
		<dc:creator>Marisa Roman</dc:creator>
				<category><![CDATA[test automation]]></category>

		<guid isPermaLink="false">http://thetestingblog.com/?p=222</guid>
		<description><![CDATA[I started using the Slim test framework (the .NET implementation) about two weeks ago, but had worked primarily with scenario, script , and decision tables up until yesterday. (Scenario tables ROCK btw and I will blog about them soon). Yesterday I started working on an automated test (or, if you prefer, collection of checks) that [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=thetestingblog.com&#038;blog=8467555&#038;post=222&#038;subd=thetestingblog&#038;ref=&#038;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>I started using the <a href="http://fitnesse.org/FitNesse.UserGuide.SliM" target="_blank">Slim test framework</a> (the <a href="http://www.syterra.com/Slim.html" target="_blank">.NET implementation</a>) about two weeks ago, but had worked primarily with scenario, script , and decision tables up until yesterday. (Scenario tables ROCK btw and I will blog about them soon).</p>
<p>Yesterday I started working on an automated test (or, if you prefer, collection of checks) that needed to verify data in a result set, so I started learning about the <a href="http://fitnesse.org/FitNesse.UserGuide.SliM.QueryTable" target="_blank">Slim Query table</a>. The query table example and corresponding fixture code presented in the FitNesse user guide are fairly straightforward. The part that I really had to wrap my head around was the statement &#8220;The fixture class must have a <em>query</em> method that returns a list of rows.  Each row is a list of fields.  Each field is a two-element list composed of the <em>field name</em> and its string value.&#8221; Say whaaat?</p>
<p>Now, maybe for those of you who have more of a programming background than I do, you might have read that statement and immediately pictured what the Query results &#8220;look&#8221; like. I didn&#8217;t. I&#8217;m used to thinking of query results as a table, not as lists of lists. I had to create a visual.</p>
<p>Given this result set:</p>
<p><img class="alignnone size-full wp-image-225" title="SampleTable" src="http://thetestingblog.files.wordpress.com/2009/09/sampletable.png?w=544" alt="SampleTable"   /></p>
<p>Starting at the lowest level, we have &#8220;Each field is a two-element list comprised of the field name and its string value.&#8221; OK, so for row 0 column 0 we&#8217;d have:</p>
<p><img class="alignnone size-full wp-image-241" title="row0Col0" src="http://thetestingblog.files.wordpress.com/2009/09/row0col02.png?w=544" alt="row0Col0"   /></p>
<p>For row 0 column 1 we&#8217;d have:</p>
<p><img class="alignnone size-full wp-image-242" title="row0Col1" src="http://thetestingblog.files.wordpress.com/2009/09/row0col12.png?w=544" alt="row0Col1"   /></p>
<p>etc.</p>
<p>Let&#8217;s go up a level. &#8220;Each row is a list of fields.&#8221; That makes sense now. For row 0 we&#8217;d have:</p>
<p><img class="alignnone size-full wp-image-239" title="row0List" src="http://thetestingblog.files.wordpress.com/2009/09/row0list.png?w=544" alt="row0List"   /></p>
<p>Finally, the Query method &#8220;returns a list of rows.&#8221; Ohhh now it makes sense.</p>
<p><img class="alignnone size-full wp-image-243" title="listOfRowsOfColValPairs" src="http://thetestingblog.files.wordpress.com/2009/09/listofrowsofcolvalpairs.png?w=544" alt="listOfRowsOfColValPairs"   /></p>
<p>Hmm&#8230;but then I had to figure out how to translate a DataTable result set into the list of this format. It was actually pretty simple; iterate through the rows and columns to create what I call column-value pairs, collect each row&#8217;s column-value pairs into a list, then collect the rows into a list.</p>
<p>I&#8217;ve provided my solution below (sorry about the formatting &#8211; this theme&#8217;s code tag sucks).</p>
<p>It&#8217;s a method that takes a DataTable and creates the <em>list of lists of column-value pairs</em> that will work with Slim Query tables. So, in each Slim Query Fixture class, I just call off to the method and pass in the DataTable of results, then return the <em>list of lists of column-value pairs</em> from the Query() method.</p>
<p><code><br />
using System;<br />
using System.Collections.Generic;<br />
using System.Data;<br />
using System.Text;<br />
</code></p>
<p><code>namespace Your.Namespace.Here<br />
{<br />
public static class SlimQueryResultsHelper<br />
{<br />
// Convert a result set in DataTable format to the format required by the Slim Query test table<br />
public static List ConvertDataTableToObjectList(DataTable theTable)<br />
{<br />
List queryResults = new List();<br />
foreach (DataRow row in theTable.Rows)<br />
{<br />
List rowListOfColumnValuePairs = new List();<br />
</code><code>foreach (DataColumn col in theTable.Columns)<br />
{<br />
List columnValuePair = new List();<br />
object val = row[col];<br />
columnValuePair.Add(col.ColumnName);<br />
columnValuePair.Add(val == DBNull.Value ? "null" : val);<br />
rowListOfColumnValuePairs.Add(columnValuePair);<br />
}<br />
queryResults.Add(rowListOfColumnValuePairs);<br />
}<br />
return queryResults;<br />
}<br />
}<br />
}<br />
</code></p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/thetestingblog.wordpress.com/222/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/thetestingblog.wordpress.com/222/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/thetestingblog.wordpress.com/222/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/thetestingblog.wordpress.com/222/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/thetestingblog.wordpress.com/222/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/thetestingblog.wordpress.com/222/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/thetestingblog.wordpress.com/222/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/thetestingblog.wordpress.com/222/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/thetestingblog.wordpress.com/222/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/thetestingblog.wordpress.com/222/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/thetestingblog.wordpress.com/222/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/thetestingblog.wordpress.com/222/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/thetestingblog.wordpress.com/222/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/thetestingblog.wordpress.com/222/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=thetestingblog.com&#038;blog=8467555&#038;post=222&#038;subd=thetestingblog&#038;ref=&#038;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://thetestingblog.com/2009/09/18/slim-query-tables/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/f5524b69490657d7297e7dc63c8cad62?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">marrrisa</media:title>
		</media:content>

		<media:content url="http://thetestingblog.files.wordpress.com/2009/09/sampletable.png" medium="image">
			<media:title type="html">SampleTable</media:title>
		</media:content>

		<media:content url="http://thetestingblog.files.wordpress.com/2009/09/row0col02.png" medium="image">
			<media:title type="html">row0Col0</media:title>
		</media:content>

		<media:content url="http://thetestingblog.files.wordpress.com/2009/09/row0col12.png" medium="image">
			<media:title type="html">row0Col1</media:title>
		</media:content>

		<media:content url="http://thetestingblog.files.wordpress.com/2009/09/row0list.png" medium="image">
			<media:title type="html">row0List</media:title>
		</media:content>

		<media:content url="http://thetestingblog.files.wordpress.com/2009/09/listofrowsofcolvalpairs.png" medium="image">
			<media:title type="html">listOfRowsOfColValPairs</media:title>
		</media:content>
	</item>
		<item>
		<title>Selenium RC in C# using NUnit: An End-to-End Example</title>
		<link>http://thetestingblog.com/2009/09/10/selenium-rc-in-c-using-nunit-an-end-to-end-example/</link>
		<comments>http://thetestingblog.com/2009/09/10/selenium-rc-in-c-using-nunit-an-end-to-end-example/#comments</comments>
		<pubDate>Thu, 10 Sep 2009 21:11:01 +0000</pubDate>
		<dc:creator>Daniel Brown</dc:creator>
				<category><![CDATA[test automation]]></category>
		<category><![CDATA[Tools]]></category>
		<category><![CDATA[.NET testing]]></category>
		<category><![CDATA[C#]]></category>
		<category><![CDATA[NUnit]]></category>
		<category><![CDATA[Selenium]]></category>
		<category><![CDATA[Selenium IDE]]></category>
		<category><![CDATA[Selenium RC]]></category>
		<category><![CDATA[UI Testing]]></category>
		<category><![CDATA[Web testing]]></category>

		<guid isPermaLink="false">http://thetestingblog.com/?p=184</guid>
		<description><![CDATA[This may come as a shock to many of you, but I&#8217;m kinda a dummy. (Collective gasps echoing through the Web.) I know! It&#8217;s hard to believe, but that&#8217;s why I&#8217;m such a great tester: I don&#8217;t take much for granted. I hate technology tutorials that kind of wing the details. The devil is in [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=thetestingblog.com&#038;blog=8467555&#038;post=184&#038;subd=thetestingblog&#038;ref=&#038;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>This may come as a shock to many of you, but I&#8217;m kinda a dummy. <em>(Collective gasps echoing through the Web.)</em> I know! It&#8217;s hard to believe, but that&#8217;s why I&#8217;m such a great tester: I don&#8217;t take much for granted. I hate technology tutorials that kind of wing the details. The devil is in the details, YOU DUMMY! The common sense thing that you omitted might be the one thing that your reader is missing!</p>
<p>Because I love my readers and aspiring software testers, I&#8217;m going to give a dummy tutorial on how to get Selenium RC up and running for C#.NET users using NUnit. I&#8217;m going to cover every <strong>painful </strong>detail. I&#8217;m confident once you have this example running, you should be able to do a whole lot of things (assuming you have some basic coding skills).</p>
<p>First off, you need to get all these things (if you don&#8217;t have them):</p>
<ul>
<li><a href="http://release.seleniumhq.org/selenium-remote-control/1.0.1/selenium-remote-control-1.0.1-dist.zip">Selenium RC</a></li>
<li><a href="http://sourceforge.net/projects/nunit/files/NUnit%20Version%202/NUnit-2.5.2.9222.msi/download">NUnit</a></li>
<li><a href="http://www.mozilla.com/products/download.html?product=firefox-3.5.2&amp;os=win&amp;lang=en-US">Firefox</a></li>
<li><a href="http://release.openqa.org/selenium-ide/1.0.2/selenium-ide-1.0.2.xpi">Selenium IDE</a></li>
<li><a href="http://www.java.com/en/download/index.jsp">Java Runtime Environment</a> (You should already have this)</li>
</ul>
<hr /><strong>Install instructions for the downloads:</strong></p>
<p><strong>Selenium RC</strong><br />
-No installation necessary. Just find a permanent location and unzip it there. I unzipped mine at <span style="color:#0000ff;">C:\</span> just to make things simple</p>
<p><strong>NUnit, Firefox, and Java</strong><br />
-Just run the respective installs with all defaults selected.</p>
<p><strong>Selenium IDE</strong><br />
-To install, right click on the file and select &#8220;Open With&#8230;&#8221;<br />
-Select Firefox in the programs list. If it&#8217;s not in the immediate menu, browse to it. (default location should be &#8220;<span style="color:#0000ff;">C:\Program Files\Mozilla Firefox\firefox.exe</span>&#8220;<br />
-When Firefox launches, click button in the dialog box that says &#8220;Install Now&#8221;.<br />
-After the install of the plug-in, hit the &#8220;Restart Firefox&#8221; button when you see it.</p>
<hr /><strong>Phase One: Record a Test using Selenium IDE</strong></p>
<p>Okay, so, now that you have the tools, we&#8217;re going to record a simple test in Selenium IDE. Even though we want to eventually run the test in Selenium RC, Selenium IDE is a great tool for getting the basic test recorded since it&#8217;s all UI point and click.</p>
<ul>
<li>Start up Firefox.</li>
<li>Click on the &#8220;Tools&#8221; menu and click on &#8220;Selenium IDE&#8221;</li>
<li><em>(Take your time to explore the Selenium IDE form)</em></li>
<li>Notice that it&#8217;s already recording.  The red circle button on the right side is pressed in:</li>
<li>Type &#8220;<span style="color:#0000ff;">www.google.com</span>&#8221; the main Firefox browser address bar and navigate to it.</li>
<li>In the search box, type in &#8220;<span style="color:#0000ff;">thetestingblog.com</span>&#8221; and hit the &#8220;I&#8217;m Feeling Lucky&#8221; button.</li>
<li><em>Notice in your Selenium IDE window that steps are being recorded.</em></li>
<li><em>With any luck, you hopefully landed on this blog&#8217;s home page.</em></li>
<li>Highlight the text &#8220;Daniel Brown&#8221; on the page, right click.  You should select the option that says &#8220;VerifyTextPresent Daniel Brown&#8221;.  See below:</li>
</ul>
<p><img class="aligncenter size-full wp-image-194" title="Screenshot_VerifyTextPresent" src="http://thetestingblog.files.wordpress.com/2009/09/screenshot_verifytextpresent.jpg?w=544&h=378" alt="Screenshot_VerifyTextPresent" width="544" height="378" /></p>
<ul>
<li><em>Okay, we got our test recorded.  Now let&#8217;s run it to make sure it passes.</em></li>
<li>Unclick the red circle button to turn off recording.</li>
<li>Click on the green play triangle with the single bar to run the test</li>
</ul>
<p><img class="aligncenter size-full wp-image-197" title="Screenshot_PassedIDETest" src="http://thetestingblog.files.wordpress.com/2009/09/screenshot_passedidetest2.jpg?w=544" alt="Screenshot_PassedIDETest"   /></p>
<ul>
<li>All green, it passed.  Good.</li>
<li>Now we want to convert this test to C#.</li>
<li>Select &#8220;Options -&gt;Format -&gt; C# &#8211; Selenium RC&#8221; from the Selenium IDE window.</li>
</ul>
<p><img class="aligncenter size-full wp-image-198" title="Screenshot_ConvertToCSharp" src="http://thetestingblog.files.wordpress.com/2009/09/screenshot_converttocsharp.jpg?w=544" alt="Screenshot_ConvertToCSharp"   /></p>
<ul>
<li>Next select all the C# code and copy it.</li>
</ul>
<hr /><strong>Phase Two: Setup the C# Test Project</strong></p>
<ul>
<li>Open up Visual Studio</li>
<li>Select &#8220;File -&gt;New -&gt;Project&#8221;</li>
<li>In the New Project window under project types, select &#8220;Visual C# -&gt;Windows&#8221;</li>
<li>Select the &#8220;Class Library&#8221; Template and name it something like &#8220;TestingBlogSeleniumRc&#8221; and click &#8220;Ok&#8221;.</li>
<li>It will create the project along with a file called &#8220;Class1.cs&#8221;.  Paste your SeleniumIDE test into that file.</li>
</ul>
<ol>
<li>Rename &#8220;Class1.cs&#8221; to &#8220;FirstTest.cs&#8221;.</li>
<li>In the code, change the namespace from &#8220;SeleniumTests&#8221; to &#8220;TestingBlogSeleniumRc&#8221;:</li>
<li>Modify the class name from &#8220;Untitled&#8221; to &#8220;FirstTest&#8221;.  It&#8217;s good to change this so that if you add other tests, there won&#8217;t be any duplicated class names in the namespace (This has gotten me before, causing compile errors.).</li>
<li>We also have to modify the Selenium instantiation to launch Internet Explorer.  Where it has &#8220;*chrome&#8221;, change it to &#8220;*iehta&#8221;.</li>
<li>Where it has &#8220;http://change-this-to-the-site-you-are-testing/&#8221;, change it to &#8220;http://www.google.com&#8221;.</li>
</ol>
<p><img class="aligncenter size-full wp-image-207" title="ModifySeleniumTestFile" src="http://thetestingblog.files.wordpress.com/2009/09/modifyseleniumtestfile.jpg?w=544&h=199" alt="ModifySeleniumTestFile" width="544" height="199" /></p>
<ul>
<li>Next we need to add all the references so this thing will run.</li>
<li>Go to the solution explorer, and right click on the &#8220;References&#8221; and select &#8220;Add Reference&#8230;&#8221;</li>
<li>Hit the &#8220;Browse&#8221; tab and navigate to where you unzipped your SeleniumRC files.  Look in the dotnet client driver folder.  Here&#8217;s the path to mine:</li>
</ul>
<p><span style="color:#0000ff;">C:\selenium-remote-control-1.0.1\selenium-dotnet-client-driver-1.0.1\</span></p>
<ul>
<li>Once you navigate to where the proper *.dlls are, select all of them and click &#8220;OK&#8221; to add them to the project.  (I know you can probably get away with adding less, but let&#8217;s keep it simple.)</li>
</ul>
<p><img class="aligncenter size-full wp-image-203" title="Add References" src="http://thetestingblog.files.wordpress.com/2009/09/add-references1.jpg?w=544&h=292" alt="Add References" width="544" height="292" /></p>
<ul>
<li>Build the project to see if it works.  (Mine worked.  Hopefully yours did too.)</li>
</ul>
<hr /><strong>Phase Three: Running the Selenium RC test</strong></p>
<ul>
<li>In order to run the Selenium RC test, you first have to have the Selenium RC server running.  The Selenium RC server folder should be in the files you unzipped.  Normally, I have a batch file on my desktop created to run the Selenium Server, but for our purposes, we&#8217;ll just run this from the &#8220;Start -&gt; Run&#8221; commandline, using this command:</li>
</ul>
<p><span style="color:#0000ff;">java -jar C:\selenium-remote-control-1.0.1\selenium-server-1.0.1\selenium-server.jar</span></p>
<ul>
<li>You should see some a dos window popup, and you will see something like the screenshot below.  DON&#8221;T CLOSE IT WHILE TESTING; IT NEEDS TO STAY RUNNING.  If you don&#8217;t have Java installed, this won&#8217;t work.  But most people should already have Java.</li>
</ul>
<p><img class="aligncenter size-full wp-image-205" title="SeleniumServer" src="http://thetestingblog.files.wordpress.com/2009/09/seleniumserver.jpg?w=544&h=272" alt="SeleniumServer" width="544" height="272" /></p>
<ul>
<li>Next you need to launch the NUnit GUI to run the test from.  Since you installed NUnit, you should be able to navigate to it &#8220;Start -&gt; All Programs -&gt; NUnit 2.4.7 -&gt; NUnit GUI (.NET 2.0)&#8221;</li>
<li>Once you open the NUnit runner, Click &#8220;File -&gt; Open Project&#8230;&#8221; and navigate to the compiled dll from your test project.  For me, the path looks like this:</li>
</ul>
<p><span style="color:#0000ff;">C:\Documents and Settings\dbrown1\My Documents\Visual Studio 2008\Projects\TestingBlogSeleniumRc\TestingBlogSeleniumRc\bin\Debug\TestingBlogSeleniumRc.dll</span></p>
<ul>
<li>Once it loads, click on &#8220;Run&#8221; to start the test.</li>
</ul>
<p><img class="aligncenter size-full wp-image-208" title="NUnit runner" src="http://thetestingblog.files.wordpress.com/2009/09/nunit-runner.jpg?w=544&h=518" alt="NUnit runner" width="544" height="518" /></p>
<p>If you got all green, congrats!  You just got your first passing Selenium RC test!  From here we can definitely get more complex. I&#8217;m sorry if I was too verbose, but I didn&#8217;t want to leave out any important details.  If you have any specific issues, please post a question; I&#8217;ll be happy to answer it.  Thanks for reading!</p>
<p><strong>UPDATE  10/14/2009:</strong></p>
<p>Thank you for your comment, Ron.  You pointed out something that I completely spaced on.  There&#8217;s one more step you need to complete before your test is ready.  You must get rid of the try-catch exception block.  As long as you have that block in your test, your test will never fail.  Nunit counts on an exception being thrown when an assert statement fails.  If that exception gets caught, then Nunit thinks that the test passed.  Why does Selenium IDE put that try-catch in when coverting the test to C#?  I have no idea.  I just know that it doesn&#8217;t need to be in there in our example.</p>
<p>BEFORE Try-Catch is removed:</p>
<p><img class="aligncenter size-full wp-image-314" title="18" src="http://thetestingblog.files.wordpress.com/2009/09/18.jpg?w=544" alt="18"   /></p>
<p>AFTER Try-Catch is removed:</p>
<p><img class="aligncenter size-full wp-image-316" title="20" src="http://thetestingblog.files.wordpress.com/2009/09/20.jpg?w=544" alt="20"   /></p>
<p>Just because I want to prove that it works, I will show you an example where I have two tests in the file.  One looks for the text &#8220;Jello Pudding&#8221;, and one looks for the text &#8220;Daniel Brown&#8221;.  Here&#8217;s code for the tests:</p>
<p><img class="aligncenter size-full wp-image-317" title="21" src="http://thetestingblog.files.wordpress.com/2009/09/21.jpg?w=544" alt="21"   /></p>
<p>(Helpful Note to Nunit beginners: when Nunit runs, it executes the [<span style="color:#33cccc;">SetUp</span>]  method before each [<span style="color:#33cccc;">Test</span>] and [<span style="color:#33cccc;">TearDown</span>] method after each [<span style="color:#33cccc;">Test</span>] .)   After running the two tests, I have very contrasting results (as I figured I would).  The test that looks for &#8220;Daniel Brown&#8221; passed like a charm, but the test for &#8220;Jelly Pudding&#8221; failed:</p>
<p><img class="aligncenter size-full wp-image-319" title="23" src="http://thetestingblog.files.wordpress.com/2009/09/231.jpg?w=544&h=222" alt="23" width="544" height="222" /></p>
<p>The bar is solid red because one failure at any level of the tree is a failed test run.  THANKS RON!  Sorry to leave out something so important.</p>
<p>Another order of business is I didn&#8217;t mention in my article, as granular as it is, that you need Visual Studio!  THANKS DAWN!  I guess I just kind of assumed that you might have it if you are interested in running Selenium in C#.  Well, I hate to assume so if you don&#8217;t have Visual Studio, you can download a free copy of Visual C# 2008 Express Edition: <a href="http://www.microsoft.com/express/download/">http://www.microsoft.com/express/download/</a> I believe you can run this example using the express edition, but I haven&#8217;t tested it.  If you do test it, give me some feedback.  I&#8217;d like to hear how it works.  Also, instead of the Visual C# Express Edition, you may also be able to use the Microsoft Visual Web Developer, but again I haven&#8217;t tested it.  I don&#8217;t know for sure.</p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/thetestingblog.wordpress.com/184/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/thetestingblog.wordpress.com/184/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/thetestingblog.wordpress.com/184/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/thetestingblog.wordpress.com/184/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/thetestingblog.wordpress.com/184/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/thetestingblog.wordpress.com/184/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/thetestingblog.wordpress.com/184/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/thetestingblog.wordpress.com/184/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/thetestingblog.wordpress.com/184/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/thetestingblog.wordpress.com/184/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/thetestingblog.wordpress.com/184/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/thetestingblog.wordpress.com/184/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/thetestingblog.wordpress.com/184/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/thetestingblog.wordpress.com/184/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=thetestingblog.com&#038;blog=8467555&#038;post=184&#038;subd=thetestingblog&#038;ref=&#038;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://thetestingblog.com/2009/09/10/selenium-rc-in-c-using-nunit-an-end-to-end-example/feed/</wfw:commentRss>
		<slash:comments>95</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/43a80f3d05753a9af40a3725839bf178?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">aubrownds</media:title>
		</media:content>

		<media:content url="http://thetestingblog.files.wordpress.com/2009/09/screenshot_verifytextpresent.jpg" medium="image">
			<media:title type="html">Screenshot_VerifyTextPresent</media:title>
		</media:content>

		<media:content url="http://thetestingblog.files.wordpress.com/2009/09/screenshot_passedidetest2.jpg" medium="image">
			<media:title type="html">Screenshot_PassedIDETest</media:title>
		</media:content>

		<media:content url="http://thetestingblog.files.wordpress.com/2009/09/screenshot_converttocsharp.jpg" medium="image">
			<media:title type="html">Screenshot_ConvertToCSharp</media:title>
		</media:content>

		<media:content url="http://thetestingblog.files.wordpress.com/2009/09/modifyseleniumtestfile.jpg" medium="image">
			<media:title type="html">ModifySeleniumTestFile</media:title>
		</media:content>

		<media:content url="http://thetestingblog.files.wordpress.com/2009/09/add-references1.jpg" medium="image">
			<media:title type="html">Add References</media:title>
		</media:content>

		<media:content url="http://thetestingblog.files.wordpress.com/2009/09/seleniumserver.jpg" medium="image">
			<media:title type="html">SeleniumServer</media:title>
		</media:content>

		<media:content url="http://thetestingblog.files.wordpress.com/2009/09/nunit-runner.jpg" medium="image">
			<media:title type="html">NUnit runner</media:title>
		</media:content>

		<media:content url="http://thetestingblog.files.wordpress.com/2009/09/18.jpg" medium="image">
			<media:title type="html">18</media:title>
		</media:content>

		<media:content url="http://thetestingblog.files.wordpress.com/2009/09/20.jpg" medium="image">
			<media:title type="html">20</media:title>
		</media:content>

		<media:content url="http://thetestingblog.files.wordpress.com/2009/09/21.jpg" medium="image">
			<media:title type="html">21</media:title>
		</media:content>

		<media:content url="http://thetestingblog.files.wordpress.com/2009/09/231.jpg" medium="image">
			<media:title type="html">23</media:title>
		</media:content>
	</item>
		<item>
		<title>Grid Interaction in Selenium Tests with XPath</title>
		<link>http://thetestingblog.com/2009/08/27/selenium-xpath/</link>
		<comments>http://thetestingblog.com/2009/08/27/selenium-xpath/#comments</comments>
		<pubDate>Thu, 27 Aug 2009 07:47:50 +0000</pubDate>
		<dc:creator>Marisa Roman</dc:creator>
				<category><![CDATA[test automation]]></category>

		<guid isPermaLink="false">http://thetestingblog.com/?p=151</guid>
		<description><![CDATA[Even though I have been using SeleniumRC for a few years now, I never actually had the need to write xpath expressions. I knew that xpath was one option for locating UI controls in Selenium, but I was always able to use control IDs, names, or text&#8230;until recently. I&#8217;m working on automating tests for a [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=thetestingblog.com&#038;blog=8467555&#038;post=151&#038;subd=thetestingblog&#038;ref=&#038;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>Even though I have been using <a href="http://seleniumhq.org/projects/remote-control/" target="_blank">SeleniumRC</a> for a few years now, I never actually had the need to write xpath expressions. I knew that xpath was one option for locating UI controls in Selenium, but I was always able to use control IDs, names, or text&#8230;until recently.</p>
<p>I&#8217;m working on automating tests for a web app that has a lot settings configuration features, and many settings are managed in the UI via interactive grid controls. As the details of this app are proprietary, I will of course use a fake example. Since I&#8217;m on a Beatles kick, let&#8217;s <em>imagine</em> (har  har sorry for the bad pun and yes I know that was Lennon solo) I&#8217;m testing an album ranking control that looks like this:</p>
<p><img class="alignnone size-full wp-image-162" title="SampleGrid" src="http://thetestingblog.files.wordpress.com/2009/08/samplegrid2.png?w=544" alt="SampleGrid"   /></p>
<p>If I record my interactions with the grid using Selenium IDE, the output is something like this:</p>
<p><img class="alignnone size-full wp-image-164" title="GridInteraction" src="http://thetestingblog.files.wordpress.com/2009/08/gridinteraction2.png?w=544" alt="GridInteraction"   /></p>
<p>Notice anything? I notice a couple things.</p>
<ol>
<li>Aside from the fact that I see &#8220;grdBeatlesAlbums&#8221; in the locator string, there is no context to the rest of it &#8211; &#8220;//tr[4]&#8221; doesn&#8217;t appear to correspond to <span style="text-decoration:underline;">Abbey Road</span> which was the album I was moving up in the ranks.</li>
<li>Yikes &#8211; am I really going to have to figure out the table row number for the album I want to act on in every test involving this grid?</li>
</ol>
<p>My first inclination was to write a method that would determine the row position of an album with a given name. Then I realized that would involve parsing HTML. Yuck. I thought to myself, there <em>has</em> to be an easier way.  I went back to the Selenium docs to read about control location strategies a little more closely and saw that xpath would probably do the trick.  As so succinctly put on <a href="http://www.w3schools.com/xpath/default.asp" target="_blank">w3school&#8217;s page</a>, &#8220;XPath is used to navigate through elements and attributes in an XML document.&#8221;</p>
<p>Now my problem was figuring out how to write an xpath expression that would locate a control in a column &#8220;next to&#8221; a given album name.</p>
<p>I wrote an almost-plain-English sentence to describe what I needed.</p>
<p>Version 1: Locate the &#8220;Move Up&#8221; link in the column <em>adjacent to</em> &#8220;Abbey Road.&#8221;</p>
<p>I thought &#8220;adjacent&#8221; would be a difficult concept but after Googling for a bit, I found information about the <em>following </em>and <em>preceding </em><a href="http://www.w3schools.com/xpath/xpath_axes.asp" target="_blank">xpath axes</a>.</p>
<p>Version 2: Locate the &#8220;Move Up&#8221; link <em>following </em>the cell containing the string &#8220;Abbey Road.&#8221;</p>
<p>OK, so now to translate this to xpath &#8211; the Move Up link is just an HTML link, a.k.a. an &#8220;a&#8221; element.</p>
<p><strong>a[.='Move Up']</strong> translates to: <em>a</em> element whose inner text exactly matches &#8216;<em>Move Up</em>&#8216;</p>
<p>And the cell containing &#8220;Abbey Road&#8221; &#8211; well, that&#8217;s just a table cell, or &#8220;td&#8221; element.</p>
<p><strong>td[.='Abbey Road']</strong> translates to: <em>td </em>element whose inner text exactly matches &#8216;<em>Abbey Road</em>&#8216;</p>
<p>Next step: relate the two.</p>
<p><strong>td[.='Abbey Road']/following::a[.='Move Up']</strong> translates to: <em>a</em> element whose inner text exactly matches &#8216;<em>Move Up</em>&#8216;, which follows a <em>td </em>element whose inner text exactly matches &#8216;<em>Abbey Road</em>&#8216;</p>
<p>We just need one more thing: since the td element is not the first element on the page, we need to prepend the statement with // to indicate that the entire document (page source) should be searched to find the element.</p>
<p><strong><strong>//</strong>td[.='Abbey Road']/following::a[.='Move Up']</strong></p>
<p>Even though the end result isn&#8217;t exactly plain English, it&#8217;s a lot more clear to me than &#8220;/tr[3]/td[4]/a&#8221; which is what the IDE recorded. It could also be reusable, providing the album name is passed via a variable instead of hard-coded.</p>
<p>Using xpath, you can also locate elements whose attributes (e.g. id or name) match certain criteria, and there are some handy functions like contains() to help in situations where a control&#8217;s full id or name is not known beforehand.</p>
<p>I&#8217;d still prefer the convenience of using control IDs, but there are just some situations where that either not possible or practical &#8211; xpath is now my fallback for tricky UI.</p>
<p><em><strong>Update 8/28/09 </strong></em></p>
<p>Since I didn’t include this originally, the way to write an expression to find an element based on attribute values is</p>
<p><strong>elementtype[@attributename='attribute value'] </strong></p>
<p>e.g. //table[@id='someTableID']</p>
<p>An example with contains():</p>
<p><strong>elementtype[contains(@attributename, 'attribute substring')]</strong></p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/thetestingblog.wordpress.com/151/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/thetestingblog.wordpress.com/151/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/thetestingblog.wordpress.com/151/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/thetestingblog.wordpress.com/151/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/thetestingblog.wordpress.com/151/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/thetestingblog.wordpress.com/151/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/thetestingblog.wordpress.com/151/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/thetestingblog.wordpress.com/151/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/thetestingblog.wordpress.com/151/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/thetestingblog.wordpress.com/151/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/thetestingblog.wordpress.com/151/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/thetestingblog.wordpress.com/151/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/thetestingblog.wordpress.com/151/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/thetestingblog.wordpress.com/151/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=thetestingblog.com&#038;blog=8467555&#038;post=151&#038;subd=thetestingblog&#038;ref=&#038;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://thetestingblog.com/2009/08/27/selenium-xpath/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/f5524b69490657d7297e7dc63c8cad62?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">marrrisa</media:title>
		</media:content>

		<media:content url="http://thetestingblog.files.wordpress.com/2009/08/samplegrid2.png" medium="image">
			<media:title type="html">SampleGrid</media:title>
		</media:content>

		<media:content url="http://thetestingblog.files.wordpress.com/2009/08/gridinteraction2.png" medium="image">
			<media:title type="html">GridInteraction</media:title>
		</media:content>
	</item>
		<item>
		<title>Here it is. My first post. (a.k.a. Why automate sub-UI?)</title>
		<link>http://thetestingblog.com/2009/08/14/marisa-first-post/</link>
		<comments>http://thetestingblog.com/2009/08/14/marisa-first-post/#comments</comments>
		<pubDate>Fri, 14 Aug 2009 05:21:21 +0000</pubDate>
		<dc:creator>Marisa Roman</dc:creator>
				<category><![CDATA[test automation]]></category>

		<guid isPermaLink="false">http://thetestingblog.com/?p=8</guid>
		<description><![CDATA[...all was going well until I said something (I thought to be) pretty benign - something along the lines of "Well, I'm hoping that the architecture of the app is such that most of these test actions and verifications can be performed sub-UI."

I heard brakes screech...

...Well, why DO we want to automate tests primarily at the sub-UI level?<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=thetestingblog.com&#038;blog=8467555&#038;post=8&#038;subd=thetestingblog&#038;ref=&#038;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>As someone who has extremely high standards for oneself, I have majorly procrastinated in writing my first post here on <a href="http://thetestingblog.com">thetestingblog.com</a>. Tonight I&#8217;ve decided to go ahead and do it already. If the information is not earth-shattering; if my wit and humor do not make you literally laugh out loud; if (gasp!) you do not agree with me &#8211; that&#8217;s OK. I have come to terms with that.</p>
<p>Now on to the real topic&#8230;I&#8217;ve been working with a software development team to guide them in their implementation of agile and automated testing techniques for about a month now. At the first sprint demo (yes &#8211; the team practices <a href="http://en.wikipedia.org/wiki/Scrum_%28development%29" target="_blank">Scrum</a>), I wanted to show the team a couple of examples of simple automated tests I had created for one of their applications. I demonstrated a GUI-driven test and a sub-GUI test. The demo went off without a hitch and the team seemed eager to start automating their tests in these manners.</p>
<p>The next day, I was to conduct a more detailed meeting with the testers regarding my suggestions for implementing automated tests to cover a particular application. Again, all was going well until I said something (I thought to be) pretty benign &#8211; something along the lines of &#8220;Well, I&#8217;m hoping that the architecture of the app is such that most of these test actions and verifications can be performed sub-UI.&#8221;</p>
<p>I heard brakes screech.</p>
<p>All of a sudden, a debate ensued about how driving the application some other way than through the UI was not a &#8220;real&#8221; acceptance test (after all, &#8220;real&#8221; users have no choice but to use the application via the UI). I stumbled and fumbled to explain; I was so used to automating 90% of a test suite at the sub-UI level that I actually had to stop and ask myself the question: &#8220;Well, why DO we want to automate test actions and verifications primarily at the sub-UI level?&#8221;</p>
<p>Here are my primary reasons:</p>
<ul>
<li>A verification being performed on the UI may not actually be verifying what the tester intended to verify.
<p>For example, if I want to verify that a folder monitoring process has swept a test file and read the data from the file correctly, verifying that the file name appears in a &#8220;Processed OK&#8221; list on a screen <strong>only tells me that the file name is appearing in that list</strong> &#8211; NOT that the file was processed correctly (whatever &#8220;correctly&#8221; means with respect to the AUT).</p>
<p>Ask yourself the question &#8220;How can I confirm that X action produced Y results?&#8221;</li>
<li>Verification that information and data are presented correctly in the UI <strong>doesn&#8217;t mean the data stored in the database is correct!</strong>
<p>I actually once found a bug where the UI populated the Last Name text box correctly, but this was because both the insert and retrieve stored procedures were referencing the Middle Name column. In other words, the Last Name data was being stored in and retrieved from the Middle Name column, so it &#8220;looked like&#8221; the Last Name data was being saved and retrieved correctly.</p>
<p>Ask yourself the question &#8220;Where are all of the &#8216;outputs&#8217; of action X?&#8221;</li>
<li>(Hopefully) it is not the UI&#8217;s job to &#8220;do&#8221; most of the application processing, but rather to transfer information to and fro the business logic layer.</li>
<p>Ask yourself the question: &#8220;Am I testing the code that&#8217;s actually responsible for action X?&#8221;</ul>
<p>There are other reasons commonly posited, such as:</p>
<ul>
<li>The UI is fragile and therefore UI tests are more likely to break</li>
<li>UI tests are much slower than sub-UI tests (and if we have a lot of slow tests, we&#8217;re less likely to want to run them)</li>
<li>If we have to automate a test via the UI, we have to wait until the UI is done, and typically the UI is the last component to be completed (even within a sprint/iteration)</li>
</ul>
<p>Do I still automate UI tests? Yes, but typically only to confirm that UI behavior is as expected &#8211; e.g. buttons are enabled/disabled given certain circumstances, fields or data are hidden for certain users, etc. I also automate 1 or 2 &#8220;all the way through&#8221; tests &#8211; from UI to backend &#8211; but leave detailed business logic tests for the sub-UI suite.</p>
<p>Those are most of the reasons why I typically prefer to automate most integration/acceptance tests at the sub-UI level &#8211; but don&#8217;t take my word for it &#8211; the Google Testing blog has a <a href="http://googletesting.blogspot.com/2007/10/automating-tests-vs-test-automation.html" target="_blank">thorough and interesting post</a> on this same topic.</p>
<p>There we have it. My first blog post. Ever. Please, respond to the poll if appropriate and comment as you wish (unless you disagree with me). Just kidding of course. <img src='http://s0.wp.com/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
<a name="pd_a_1874268"></a>
<div class="PDS_Poll" id="PDI_container1874268" data-settings="{&quot;url&quot;:&quot;http:\/\/static.polldaddy.com\/p\/1874268.js&quot;}" style="display:inline-block;"></div>
<div id="PD_superContainer"></div>
<noscript><a href="http://polldaddy.com/poll/1874268">Take Our Poll</a></noscript>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/thetestingblog.wordpress.com/8/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/thetestingblog.wordpress.com/8/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/thetestingblog.wordpress.com/8/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/thetestingblog.wordpress.com/8/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/thetestingblog.wordpress.com/8/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/thetestingblog.wordpress.com/8/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/thetestingblog.wordpress.com/8/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/thetestingblog.wordpress.com/8/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/thetestingblog.wordpress.com/8/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/thetestingblog.wordpress.com/8/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/thetestingblog.wordpress.com/8/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/thetestingblog.wordpress.com/8/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/thetestingblog.wordpress.com/8/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/thetestingblog.wordpress.com/8/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=thetestingblog.com&#038;blog=8467555&#038;post=8&#038;subd=thetestingblog&#038;ref=&#038;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://thetestingblog.com/2009/08/14/marisa-first-post/feed/</wfw:commentRss>
		<slash:comments>9</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/f5524b69490657d7297e7dc63c8cad62?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">marrrisa</media:title>
		</media:content>
	</item>
	</channel>
</rss>
