<?xml version="1.0" encoding="UTF-8"?>
<rss 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:feedburner="http://rssnamespace.org/feedburner/ext/1.0" version="2.0">

<channel>
	<title>Ranorex Blog</title>
	
	<link>http://www.ranorex.com/blog</link>
	<description>Software Automation &amp; Automated Testing Blog</description>
	<pubDate>Fri, 29 Jan 2010 12:45:20 +0000</pubDate>
	<generator>http://wordpress.org/?v=2.7.1</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<atom10:link xmlns:atom10="http://www.w3.org/2005/Atom" rel="self" type="application/rss+xml" href="http://feeds.feedburner.com/ranorex-blog" /><feedburner:info uri="ranorex-blog" /><atom10:link xmlns:atom10="http://www.w3.org/2005/Atom" rel="hub" href="http://pubsubhubbub.appspot.com" /><item>
		<title>Manage test data and execute automated test scenarios with FitNesse and Ranorex</title>
		<link>http://feedproxy.google.com/~r/ranorex-blog/~3/_90cHLAeH34/manage-test-data-and-execute-automtated-test-scenarios-with-fitnesse-and-ranorex</link>
		<comments>http://www.ranorex.com/blog/manage-test-data-and-execute-automtated-test-scenarios-with-fitnesse-and-ranorex#comments</comments>
		<pubDate>Fri, 29 Jan 2010 12:30:40 +0000</pubDate>
		<dc:creator>cpreschern</dc:creator>
		
		<category><![CDATA[Test Management]]></category>

		<guid isPermaLink="false">http://www.ranorex.com/blog/manage-test-data-and-execute-automtated-test-scenarios-with-fitnesse-and-ranorex</guid>
		<description><![CDATA[Writing test scripts is more time consuming than maintaining already existing test scripts. One way to minimize the time needed to implement test scripts is to keep test data separated from test code. The less test data the test code contains, the more reusable it is. Another advantage of separating test data from test code [...]]]></description>
			<content:encoded><![CDATA[<p class="MsoNormal">Writing test scripts is more time consuming than maintaining already existing test scripts. One way to minimize the time needed to implement test scripts is to keep test data separated from test code. The less test data the test code contains, the more reusable it is. Another advantage of separating test data from test code is that testers – in most cases non-programmers – are able to generate and execute tests or test suits without thorough the deeper knowledge of test script implementation.</p>
<p class="MsoNormal">
<p>The following example describes how FitNesse and Ranorex can be combined to automate GUI testing without having static test scripts. Moreover, it gives a quick overview as to how to manage, maintain and execute test scripts using FitNesse.</p>
<p><img class="alignleft size-full wp-image-427" title="fitnessandranorex" src="http://www.ranorex.com/blog/wp-content/uploads/2008/01/fitnessandranorex.png" alt="fitnessandranorex" width="503" height="206" /><br />
 <span id="more-10"></span></p>
<p class="MsoNormal">
<p class="MsoNormal">
<p class="MsoNormal">
<p class="MsoNormal">
<p class="MsoNormal">
<p class="MsoNormal">
<p class="MsoNormal">First, download and install FitNesse from <a href="http://fitnesse.org/FrontPage.FitNesseDevelopment.DownLoad">http://fitnesse.org/FrontPage.FitNesseDevelopment.DownLoad</a>. More information about installing and getting started with FitNesse is provided by the following document written by Gojko Adzic: <a href="http://gojko.net/FitNesse/book/">http://gojko.net/FitNesse/book/</a>. He describes how one implements and executes .NET test cases using FitNesse and demonstrates how one can create human-readable test cases.</p>
<p class="MsoNormal">
<h3>Creating Automation Base Library</h3>
<p><b>UPDATED: This example is based on Ranorex 2.2.</b><br />
<span lang="EN-US">To automate and test the VIP application with FitNesse it is necessary to implement a .NET fixture class which does all the GUI automation work.<br />
</span></p>
<pre name="code" class="c-sharp">using System;
using System.Collections.Generic;
using System.Text;
using Ranorex;
namespace NetFit
{
   public class AddVIPTest : fit.ColumnFixture
   {
	///
	/// UI Repository instance for VIP Application
        ///
	private VIPRepo repo = VIPRepo.Instance;
	private string gender;
	private string lastName;
	private string firstName;
	///
	/// Property for FirstName parameter.
	/// By setting the property Ranorex directly clicks
	/// the text box and simulates the keyboard events
	/// Returns the current text value of the text box.
	///
	public string FirstName
	{
	   set
	       	{
	       		this.firstName = value;
	       		repo.VIPApplication.FirstName.Click();
	       		Ranorex.Keyboard.Press(firstName);
	       	}
	       	get
	       	{
	       		return repo.VIPApplication.FirstName.TextValue;
	       	}
	    }
	    ///
	    /// Property for FirstName parameter.
	    /// By setting the property Ranorex directly clicks
	    /// the text box and simulates the keyboard events
	    /// Returns the current text value of the text box.
	    ///
	    public string LastName
	    {
	       	set
	       	{
	       		this.lastName = value;
	       		repo.VIPApplication.LastName.Click();
	       		Ranorex.Keyboard.Press(lastName);
	       	}
	       	get
	       	{
	       		return repo.VIPApplication.LastName.TextValue;
	       	}
	    }
	    ///
	    /// Property for Gender parameter.
	    /// Depending on the given value Ranorex selects
	    /// the right radio button.
	    /// Returns the currently selected gender
	    ///
	    public string Gender
	    {
	    	set
	    	{
	    		gender = value;
	    		if (gender.Equals("Female"))
	    		    repo.VIPApplication.Gender.Female.Click();
	    		else if (gender.Equals("Male"))
	    			repo.VIPApplication.Gender.Male.Click();
	    	}
	    	get
	    	{
	    		if (repo.VIPApplication.Gender.Female.Checked)
	    			return "Female";
	    		else
	    			return "Male";
	    	}
	    }
	    /// Method is used to simulate a click on
	    /// specified button.
	    ///
	    ///
	    /// Specifies the label of the button to press
	    ///
	    public void Action(string button)
	    {
	    	repo.VIPApplication.Self.FindChild(button).Click();
	    }
	    ///
	    ///
	    /// Returns the current text value of
	    /// the status bar.
	    ///
	    public string ValidateStatusBox()
	    {
	         return repo.VIPApplication.StatusBar.TextValue;
	    }
}</pre>
<p><span lang="EN-US">The “AddVIPTest” class is derived from a simple FitNesse <strong>fit.ColumnFixture</strong> class. All public declared fields within this class  are accessible through a FitNesse test case as follows:</span><br />
<span style="font-family: Courier" lang="EN-US">!|NetFit.AddVIPTest|<br />
|FirstName|LastName|Gender|Action|ValidateStatusBox?|<br />
|Marylin|Monroe|Female|Add|VIP count: 1|<br />
|Bill|Gates|Male|Add|VIP count: 2|<br />
|Hillary|Clinton|Female|Add|VIP count: 3|</p>
<p></span><br />
All test data is specified in columns and rows, and “FirstName”, “LastName”, “Gender”, and “Action” are declared as <strong>test input data</strong>. Read <strong>test output data</strong> by adding the question mark <strong>‘?’</strong> to the “ValidateStatusBox” column. The last column in our example is used to call our &#8220;ValidateStatusBox&#8221; method and to compare the returned value with an expected value.</p>
<p>FitNesse uses so called “Test Pages” to execute test tables as described above. The next steps describe how to create “Test Pages” with FitNesse using its web application server.</p>
<p>After downloading and installing FitNesse, just start “run.bat”. Start your preferred browser and enter <strong>http://localhost/AddVipTest</strong> in the address field to create a new FitNesse test called AddVIPTest.</p>
<h3>Specifying test</h3>
<p>Edit the page and define the command patterns, the test runner and the Ranorex based .NET library as follows:</p>
<p><span style="font-family: Courier" lang="EN-US">!!define COMMAND_PATTERN {%m -r fitnesse.fitserver.FitServer,C:\Ranorex\Fitnesse\dotnet2\fit.dll, -c C:\Ranorex\Fitnesse\dotnet2\myConfig.xml %p}<br />
!define TEST_RUNNER {C:\Ranorex\Fitnesse\dotnet2\Runner.exe}<br />
!path C:\Ranorex\Fitnesse\HelloWorld\HelloWorld\bin\Debug\NetFit.dll<br />
<br/><br />
!|NetFit.AddVIPTest|<br />
|FirstName|LastName|Gender|Action|ValidateStatusBox?|<br />
|Marylin|Monroe|Female|Add|VIP count: 1|<br />
|Bill|Gates|Male|Add|VIP count: 2|<br />
|Hillary|Clinton|Female|Add|VIP count: 3|</span></p>
<p><span lang="EN-US">Save the &#8220;AddVipTest&#8221; page. To enable a &#8220;Test&#8221; button, set up the page properties within the properties menu. </span><br />
Now you can start your FitNesse-managed Ranorex automated test script.</p>
<p><img class="alignnone size-medium wp-image-428" title="addviptestexecuted" src="http://www.ranorex.com/blog/wp-content/uploads/2008/01/addviptestexecuted-546x425.png" alt="addviptestexecuted" width="546" height="425" /></p>
<p>Each test case should be passed successfully. Try to force an error by changing one of the expected values. Restart the test and see what happens.<br />
<span style="font-size: 9pt; line-height: 115%; font-family: Courier" lang="EN-US"><br />
</span></p>
<p class="addtoany_share_save_container">
    <a class="a2a_dd addtoany_share_save" href="http://www.addtoany.com/share_save?sitename=Ranorex%20Blog&amp;siteurl=http%3A%2F%2Fwww.ranorex.com%2Fblog%2F&amp;linkname=Manage%20test%20data%20and%20execute%20automated%20test%20scenarios%20with%20FitNesse%20and%20Ranorex&amp;linkurl=http%3A%2F%2Fwww.ranorex.com%2Fblog%2Fmanage-test-data-and-execute-automtated-test-scenarios-with-fitnesse-and-ranorex"><img src="http://www.ranorex.com/blog/wp-content/plugins/add-to-any/share_save_120_16.png" width="120" height="16" alt="Share/Save/Bookmark"/></a>

	</p><img src="http://feeds.feedburner.com/~r/ranorex-blog/~4/_90cHLAeH34" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://www.ranorex.com/blog/manage-test-data-and-execute-automtated-test-scenarios-with-fitnesse-and-ranorex/feed</wfw:commentRss>
		<feedburner:origLink>http://www.ranorex.com/blog/manage-test-data-and-execute-automtated-test-scenarios-with-fitnesse-and-ranorex</feedburner:origLink></item>
		<item>
		<title>Enabling automation for 3rd party controls by adding Accessibility</title>
		<link>http://feedproxy.google.com/~r/ranorex-blog/~3/JP0AvPHg74g/enabling-automation-by-adding-accessibility-to-windows-forms-controls</link>
		<comments>http://www.ranorex.com/blog/enabling-automation-by-adding-accessibility-to-windows-forms-controls#comments</comments>
		<pubDate>Mon, 26 Oct 2009 10:25:36 +0000</pubDate>
		<dc:creator>mgissing</dc:creator>
		
		<category><![CDATA[Test Automation]]></category>

		<guid isPermaLink="false">http://www.ranorex.com/blog/?p=334</guid>
		<description><![CDATA[In many cases, custom Windows Forms or 3rd party provided controls are not built with accessibility in mind. It is often overlooked that by adding this functionality one does not only help those who are dependent on good accessibility, but that it also enables automation (and automated testing) of the control in question.
In the following [...]]]></description>
			<content:encoded><![CDATA[<p>In many cases, custom Windows Forms or 3rd party provided controls are not built with accessibility in mind. It is often overlooked that by adding this functionality one does not only help those who are dependent on good accessibility, but that it also enables automation (and automated testing) of the control in question.</p>
<p>In the following example, I would like to show that in Windows Forms it is quite easy to add accessibility functions to an existing control, even to a rather complex control like a tree view. The control used in the example is the <a href="http://sourceforge.net/projects/treeviewadv/">TreeViewAdv</a>, a quite popular open source tree/list control. But please consider that also other complex controls like data grids or list views from other 3rd party vendors (Infragistics, DevExpress, Syncfusion, ComponentOne, Telerik, Janus, &#8230;) can be extended the same way as described within the following scenario.</p>
<p>Although it is quite nice to use, it lacks an accessibility implementation, rendering its content totally opaque to most automation tools. (Using Ranorex&#8217; remote invocation capability, one can still extract data from the control, though.)</p>
<p>Here is an example of the control filled with some test data. You can see that in addition to a standard TreeView the TreeViewAdv can have columns as well:<br />
<img class="size-full wp-image-352" title="tv_demo" src="http://www.ranorex.com/blog/wp-content/uploads/2009/10/tv_demo.png" alt="TreeView Adv with example data" width="389" height="302" /><span id="more-334"></span></p>
<p>In its original form no information about the content of the control is available. To support automation, we are going to add the following accessibility features:</p>
<ul>
<li>Every tree node is represented in the accessibility tree.</li>
<li>Every column cell is represented in the accessibility tree.</li>
<li>Every node or cell has geometry and visibility information.</li>
<li>Every node has a name (for identification) and a value (content for validation).</li>
</ul>
<p>Let&#8217;s have a look at the necessary code. First, a reference to the &#8220;Accessibility&#8221; assembly, which is part of the .NET framework, has to be added. This assembly provides a managed wrapper and a number of utility classes around the COM-based <em>Microsoft Active Accessibility</em> (MSAA) layer.</p>
<p>MSAA has been around for some time now and is understood by most screen readers and automation tools. It has been superseded by <em>UI Automation</em>, which is especially suited for WPF applications, but still comes in handy for Windows Forms and MFC/ATL applications.</p>
<p>To provide a custom accessibility implementation for a control, the CreateAccessibilityInstance method has to be overridden and has to return a custom AccessibleObject implementation.</p>
<pre name="code" class="c-sharp:nocontrols">// overridden to return custom accessibility object instance
protected override AccessibleObject CreateAccessibilityInstance()
{
    return new TreeViewAdvAccessibleObject(this);
}</pre>
<p>For our tree we will provide three classes, all deriving from <em>AccessibleObject</em>:</p>
<ol>
<li><strong>TreeViewAdvAccessibleObject</strong> which represents the tree itself and acts as the top-level container. This actually derives from <em>Control.ControlAccessibleObject</em><br />
which provides a basic accessibility implementation for control classes, e.g. for its location, size and visibility.</li>
<li><strong>AdvNodeAccessibleObject</strong> represents a tree node.</li>
<li><strong>AdvNodeCellAccessibleObject</strong> represents a cell of a certain node column.</li>
</ol>
<p>Accessibility functionality is then implemented by overriding a number of properties and methods to provide useful information and functionality to an external application. Here is a short overview of the most important properties which need to be implemented:</p>
<ul>
<li> Properties:
<ul>
<li><strong>Role: </strong>An enumeration of different kinds of GUI objects, for example buttons, checkboxes, listitems, etc. In our example, we use Outline (which represents a tree) and OutlineItem (which represents a tree node) as well as Cell (which represents a table cell).</li>
<li><strong>Name: </strong>A representative name for the object. It is usually used for (re-)identification purposes (e.g. &#8220;SaveAs&#8221; button), should not be content dependent, and might even be language-invariant.</li>
<li><strong>Value: </strong> Represents the object&#8217;s content if it has any. For example the text in a text box, the Checked property of a check box, or the contents of a data cell.</li>
<li><strong>State: </strong>A flag enumeration containing a number of states a GUI object can have, like <em>Selected</em>, <em>Invisible</em>, <em>Expanded</em>, <em>Collapsed </em>or <em>Focused</em>. In our example, <em>Selected</em>, <em>Expanded </em>and <em>Collapsed </em>are especially useful for tree nodes.</li>
<li><strong>Bounds: </strong> A rectangle representing the bounding box of an object in screen coordinates. This property is very important for correct automation and capture/replay.</li>
<li><strong>Parent: </strong>The parent of the accessible object. This must be implemented if the object is returned as a child of another accessible object (for consistency; see below).</li>
</ul>
</li>
<li> Methods:
<ul>
<li><strong>GetChild() and GetChildCount(): </strong> Returns a child/the number of children of the object. In our example, tree nodes return their child nodes and tables return cells as child objects. Make sure to implement the <em>Parent</em> property for objects returned by this functions!</li>
<li><strong>Select(): </strong>Selects an object, if applicable. This method is a bit weird as it takes <em>AccessibleSelection</em> as a parameter which describes what kind of selection to perform. <em>AccessibleSelection.Focus</em> is very useful for automation if implemented, regardless whether an object is selectable or not.</li>
<li><strong>HitTest(x,y): </strong>Returns the object at coordinates (x,y). This is useful for fast capture/replay and is easily implemented in our example, because TreeViewAdv already has built-in functionality for returning a tree node by coordinates.</li>
</ul>
</li>
</ul>
<p>Here is a part of the AdvNodeAccessibleObject implementation:</p>
<pre name="code" class="c-sharp:nocontrols">public class AdvNodeAccessibleObject : AccessibleObject
{
	TreeNodeAdv advNode;
	AdvNodeAccessibleObject parent;
	TreeViewAdvAccessibleObject owner;

	public AdvNodeAccessibleObject(TreeNodeAdv advNode, AdvNodeAccessibleObject parent,
									TreeViewAdvAccessibleObject owner) : base()
	{
		...
	}

	public override AccessibleRole Role
	{
		get { return AccessibleRole.OutlineItem; }
	}

	public override Rectangle Bounds
	{
		get
		{
			if (!advNode.IsVisible)
				return Rectangle.Empty;

                        // we need to convert client -&gt; screen here
			Rectangle bounds = advNode.Tree.GetNodeBounds(advNode);
			Point p = advNode.Tree.ScrollPosition;

			int colHeaderY = advNode.Tree.UseColumns ? advNode.Tree.ColumnHeaderHeight : 0;

			bounds.Offset(-p.X, -p.Y * advNode.Tree.RowHeight + colHeaderY);
			return advNode.Tree.RectangleToScreen(bounds);
		}
	}

	public override string Name
	{
		get
		{
			foreach (NodeControlInfo info in advNode.Tree.GetNodeControls(advNode))
			{
				BindableControl ctrl = info.Control as BindableControl;
				if (ctrl != null)
				{
					string val = ctrl.GetValue(advNode) as string;
					if (val != null)
						return val;
				}
			}
			return null;
		}
	}

	public override AccessibleObject GetChild(int index)
	{
		int ctrlCount = advNode.Tree.Columns.Count;

		if (index &lt; ctrlCount)
			return new AdvNodeCellAccessibleObject(advNode, index, this);
		else return new AdvNodeAccessibleObject(advNode.Nodes[index-ctrlCount], this, owner);
	}

	public override int GetChildCount()
	{
		return advNode.Nodes.Count + advNode.Tree.Columns.Count;
	}

	public override AccessibleObject Parent
	{
		get
		{
			if (advNode.Parent != advNode.Tree.Root)
				return parent != null ? parent : new AdvNodeAccessibleObject(advNode.Parent, null, owner);
			else return owner;
		}
	}

	...
}</pre>
<p>This might look a bit complicated, but if you are familiar with the control you are extending, most accessibility properties and methods can be implemented in a rather straightforward manner.</p>
<p>The whole implementation for the TreeViewAdv control accessibility support is only about 300 lines of code and a few hours of coding time, but it makes a huge difference in terms of automation.</p>
<p>Here are two screenshots of Ranorex Spy analyzing the newly accessible tree control:<br />
<img class="alignnone size-medium wp-image-376" title="tv_spy1" src="http://www.ranorex.com/blog/wp-content/uploads/2009/10/tv_spy1-479x500.png" alt="tv_spy1" width="479" height="500" /><br />
<img class="alignnone size-full wp-image-377" title="tv_spy2" src="http://www.ranorex.com/blog/wp-content/uploads/2009/10/tv_spy2.png" alt="tv_spy2" width="448" height="346" /></p>
<p>As you can see from the highlighted area on the first screenshot, it is now possible to look &#8220;inside&#8221; the control. This helps a lot when performing automated data entry, content validation, behavior checking, screen scraping, etc.</p>
<p>You can grab the source package with the accessibility addon for TreeViewAdv and the simple demo app here:</p>
<p><a href="http://www.ranorex.com/blog/wp-content/uploads/2009/10/treeviewadv_rev76_acc.zip">Source package for TreeViewAdv (svn rev 76) with accessibility</a><br />
<a href="http://www.ranorex.com/blog/wp-content/uploads/2009/10/treeviewdemo.zip">TreeViewAdv demo binaries</a></p>
<p>More information about the Windows Automation APIs can be found <a href="http://msdn.microsoft.com/en-us/windows/bb735024.aspx">here</a>.<a href="http://msdn.microsoft.com/en-us/windows/bb735024.aspx"><br />
</a></p>
<p class="addtoany_share_save_container">
    <a class="a2a_dd addtoany_share_save" href="http://www.addtoany.com/share_save?sitename=Ranorex%20Blog&amp;siteurl=http%3A%2F%2Fwww.ranorex.com%2Fblog%2F&amp;linkname=Enabling%20automation%20for%203rd%20party%20controls%20by%20adding%20Accessibility&amp;linkurl=http%3A%2F%2Fwww.ranorex.com%2Fblog%2Fenabling-automation-by-adding-accessibility-to-windows-forms-controls"><img src="http://www.ranorex.com/blog/wp-content/plugins/add-to-any/share_save_120_16.png" width="120" height="16" alt="Share/Save/Bookmark"/></a>

	</p><img src="http://feeds.feedburner.com/~r/ranorex-blog/~4/JP0AvPHg74g" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://www.ranorex.com/blog/enabling-automation-by-adding-accessibility-to-windows-forms-controls/feed</wfw:commentRss>
		<feedburner:origLink>http://www.ranorex.com/blog/enabling-automation-by-adding-accessibility-to-windows-forms-controls</feedburner:origLink></item>
		<item>
		<title>Using NUnit for test execution</title>
		<link>http://feedproxy.google.com/~r/ranorex-blog/~3/RltxNUYknN0/using-nunit-for-test-execution</link>
		<comments>http://www.ranorex.com/blog/using-nunit-for-test-execution#comments</comments>
		<pubDate>Fri, 31 Jul 2009 08:12:15 +0000</pubDate>
		<dc:creator>cschmid</dc:creator>
		
		<category><![CDATA[Test Automation]]></category>

		<guid isPermaLink="false">http://www.ranorex.com/blog/?p=222</guid>
		<description><![CDATA[NUnit is an open source testing framework for .NET languages. It´s based on the XUnit testing design which contains powerful functionality for test execution. In this article I want to show how to make your Ranorex Tests fit for NUnit.
Requirements:
NUnit -  http://www.nunit.org/index.php?p=download
(preferred version &#62;= 2.5)
1.) Add the NUnit reference to your project
Right-click on your project and choose [...]]]></description>
			<content:encoded><![CDATA[<p>NUnit is an open source testing framework for .NET languages. It´s based on the XUnit testing design which contains powerful functionality for test execution. In this article I want to show how to make your Ranorex Tests fit for NUnit.<span id="more-222"></span></p>
<p><strong>Requirements:</strong></p>
<p>NUnit -  <a href="http://www.nunit.org/index.php?p=download">http://www.nunit.org/index.php?p=download</a><br />
(preferred version &gt;= 2.5)</p>
<p><strong>1.) Add the NUnit reference to your project</strong><br />
Right-click on your project and choose &#8216;Add Reference&#8217;<br />
Select &#8216;nunit.framework&#8217; from the &#8216;GAC&#8217; tab</p>
<p><strong>2.) Create a new NUnit testcase class<br />
</strong>Right-click on your project and choose &#8216;Add-&gt;New Item&#8217;<br />
Select &#8216;new empty file&#8217; and click create</p>
<p><strong>3.) Add the following lines of code:</strong></p>
<pre name="code" class="c-sharp:nocontrols">using NUnit.Framework;

[TestFixture, RequiresSTA]
public class TestCase1
{
	[TestFixtureSetUp]
	public void Init()
	{
	}

	[Test]
	public void Test1()
	{
	}

	[TestFixtureTearDown]
	public void Dispose()
	{
	}
}</pre>
<p><strong>4.) Insert the recorded or manual test calls</strong><br />
Write your automation code into the Test1 method<br />
Use the &#8216;TestFixtureSetUp&#8217; and &#8216;TearDown&#8217; methods to initialize and set you Software Under Test (SUT) back to its original state</p>
<p><strong>5.) Open your dll/exe with the &#8216;NUnit GUI Runner&#8217; and start your tests</strong><br />
Navigate to a specific test in the test tree<br />
Right-click on the file node and click &#8216;Run&#8217; or &#8216;Run all&#8217;</p>
<p><img class="aligncenter size-full wp-image-232" title="NUnit GUI Test Runner" src="http://www.ranorex.com/blog/wp-content/uploads/2009/07/nunit-gui4.png" alt="NUnit GUI Test Runner" width="570" height="418" /></p>
<p><strong></strong></p>
<p><strong></strong></p>
<p><strong>Or:</strong></p>
<p><strong>If you want to call your existing recordings directly, declare them as NUnit tests:</strong></p>
<p><strong></strong></p>
<p><strong>1.) Open the &#8216;Recording.UserCode&#8217; file</strong><br />
Navigate to the recording node in Project Browser and open the &#8216;.usercode&#8217; file</p>
<p><strong>2.) Declare your Recording class as &#8216;[TestFixture]&#8216;</strong><br />
Set the &#8216;TestFixture&#8217; attribute at the top of the class (see code below)</p>
<p><strong>3.) Create a new NUnit test method</strong><br />
Insert a new method &#8216;StartRecording&#8217; into the usercode (&#8221;Recording1.UserCode.cs&#8221; file, see code below)</p>
<p>e.g.</p>
<pre name="code" class="c-sharp:nocontrols">[TestFixture, RequiresSTA]
public partial class Recording1
{
         /*
        ...
        */

        [Test]
        public void StartRecording()
        {
             Recording1.Start();
        }

        /*
        ....
        */
}</pre>
<p>Now we are able to call every single test method from the NUnit Test Runner and we don´t have to worry about the build and cleanup of our testing environment. We are also free to choose which test methods we want to execute for each test run.</p>
<p class="addtoany_share_save_container">
    <a class="a2a_dd addtoany_share_save" href="http://www.addtoany.com/share_save?sitename=Ranorex%20Blog&amp;siteurl=http%3A%2F%2Fwww.ranorex.com%2Fblog%2F&amp;linkname=Using%20NUnit%20for%20test%20execution&amp;linkurl=http%3A%2F%2Fwww.ranorex.com%2Fblog%2Fusing-nunit-for-test-execution"><img src="http://www.ranorex.com/blog/wp-content/plugins/add-to-any/share_save_120_16.png" width="120" height="16" alt="Share/Save/Bookmark"/></a>

	</p><img src="http://feeds.feedburner.com/~r/ranorex-blog/~4/RltxNUYknN0" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://www.ranorex.com/blog/using-nunit-for-test-execution/feed</wfw:commentRss>
		<feedburner:origLink>http://www.ranorex.com/blog/using-nunit-for-test-execution</feedburner:origLink></item>
		<item>
		<title>Use the Ranorex Recorder to execute recurring tasks and simplify your everyday life</title>
		<link>http://feedproxy.google.com/~r/ranorex-blog/~3/DZNiWHZSSOc/use-the-ranorex-recorder-to-execute-recurring-tasks-and-simplify-your-everyday-life</link>
		<comments>http://www.ranorex.com/blog/use-the-ranorex-recorder-to-execute-recurring-tasks-and-simplify-your-everyday-life#comments</comments>
		<pubDate>Mon, 27 Jul 2009 09:16:40 +0000</pubDate>
		<dc:creator>gherget</dc:creator>
		
		<category><![CDATA[Test Automation]]></category>

		<guid isPermaLink="false">http://www.ranorex.com/blog/?p=182</guid>
		<description><![CDATA[Beside the powerful UI testing functionality of the Ranorex Recorder you can also use it to record and replay recurring tasks on your computer. These recordings can be started  directly using keyboard shortcuts and without popping up the Ranorex Recorder Editor.
The Recorder will run the recording and save the Ranorex Report file to the [...]]]></description>
			<content:encoded><![CDATA[<p>Beside the powerful UI testing functionality of the Ranorex Recorder you can also use it to record and replay recurring tasks on your computer. These recordings can be started  directly using keyboard shortcuts and without popping up the Ranorex Recorder Editor.</p>
<p>The Recorder will run the recording and save the Ranorex Report file to the directory where the recording file is located.</p>
<p style="text-align: center;"><img class="size-full wp-image-197 aligncenter" title="startrecording1" src="http://www.ranorex.com/blog/wp-content/uploads/2009/07/startrecording1.jpg" alt="startrecording1" width="125" height="117" /><span id="more-182"></span></p>
<ol>
<li>Open the Recorder, capture your recurring task and save the recording file (e.g. C:\Recordings\Recording1.rxrec)</li>
<li>Open start menu and select &#8220;<strong>All Programs</strong>&#8220;-&gt;&#8221;<strong>Ranorex 2.X</strong>&#8220;</li>
<li>Drag and drop (with the right mouse button) the &#8220;Ranorex Recorder&#8221; shortcut to your desktop and choose &#8220;Copy Here&#8221;</li>
<li>Rename your shortcut file (e.g. &#8220;Start Recording1&#8243;) and open the properties by right-clicking and choosing &#8220;Properties&#8221;</li>
<li>Append following parameters to <strong>Target </strong>&#8220;/quiet /play&#8221; and the path of your recording1 file. The Target property should look like then:
<pre name="code" class="csharp:nocontrols">"C:\Program Files\Ranorex 2.1\Bin\Ranorex.Recorder.exe" /quiet /play "C:\Recordings\Recording1.rxrec"</pre>
</li>
<li>Define a shortcut key by clicking into <strong>Shortcut Key</strong> and press your key combination (e.g. CTRL + ALT + R).</li>
<li>You can start your recording by double-clicking on the shortcut or pressing the global shortcut key</li>
</ol>
<p class="addtoany_share_save_container">
    <a class="a2a_dd addtoany_share_save" href="http://www.addtoany.com/share_save?sitename=Ranorex%20Blog&amp;siteurl=http%3A%2F%2Fwww.ranorex.com%2Fblog%2F&amp;linkname=Use%20the%20Ranorex%20Recorder%20to%20execute%20recurring%20tasks%20and%20simplify%20your%20everyday%20life&amp;linkurl=http%3A%2F%2Fwww.ranorex.com%2Fblog%2Fuse-the-ranorex-recorder-to-execute-recurring-tasks-and-simplify-your-everyday-life"><img src="http://www.ranorex.com/blog/wp-content/plugins/add-to-any/share_save_120_16.png" width="120" height="16" alt="Share/Save/Bookmark"/></a>

	</p><img src="http://feeds.feedburner.com/~r/ranorex-blog/~4/DZNiWHZSSOc" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://www.ranorex.com/blog/use-the-ranorex-recorder-to-execute-recurring-tasks-and-simplify-your-everyday-life/feed</wfw:commentRss>
		<feedburner:origLink>http://www.ranorex.com/blog/use-the-ranorex-recorder-to-execute-recurring-tasks-and-simplify-your-everyday-life</feedburner:origLink></item>
		<item>
		<title>Resizing windows and dialogs with Ranorex</title>
		<link>http://feedproxy.google.com/~r/ranorex-blog/~3/S4Pa1nppIJA/resize-window</link>
		<comments>http://www.ranorex.com/blog/resize-window#comments</comments>
		<pubDate>Mon, 13 Jul 2009 07:44:40 +0000</pubDate>
		<dc:creator>cpreschern</dc:creator>
		
		<category><![CDATA[Test Automation]]></category>

		<guid isPermaLink="false">http://www.ranorex.com/blog/?p=163</guid>
		<description><![CDATA[In cases of .NET forms it’s possible to set the size value of an application form directly using the Ranorex invoke mechanism. But if you’d like to change the size of forms which are not of type .NET WinForms you need to simulate mouse move actions to point it exactly to the lower right corner. [...]]]></description>
			<content:encoded><![CDATA[<p>In cases of .NET forms it’s possible to set the size value of an application form directly using the Ranorex invoke mechanism. But if you’d like to change the size of forms which are not of type .NET WinForms you need to simulate mouse move actions to point it exactly to the lower right corner. The following short code snippet describes how to resize all kind of windows by simulating mouse actions with Ranorex.</p>
<pre name="code" class="c-sharp:nocontrols">
int x=0;
int y=0;

// Find 'Notepad' application using RanoreXPath
Ranorex.Form form = "/form[@title='Untitled - Notepad']";
form.Activate();
x = form.ScreenRectangle.Width - 2;
y = form.ScreenRectangle.Height - 2; 

Report.Log(ReportLevel.Info,"",Mouse.CursorName);
Mouse.MoveTo(form,new Location(x,y));
Report.Log(ReportLevel.Info,"",Mouse.CursorName);

// Check if the application window allows it
// resize the form using the ‘CursorName’ property
if (Mouse.CursorName.Equals("SizeNWSE"))
{
	Mouse.ButtonDown(MouseButtons.Left);
	Mouse.MoveTo(form.ScreenRectangle.Right+30,form.ScreenRectangle.Bottom+30);
	Mouse.ButtonUp(MouseButtons.Left);
}
</pre>
<p class="addtoany_share_save_container">
    <a class="a2a_dd addtoany_share_save" href="http://www.addtoany.com/share_save?sitename=Ranorex%20Blog&amp;siteurl=http%3A%2F%2Fwww.ranorex.com%2Fblog%2F&amp;linkname=Resizing%20windows%20and%20dialogs%20with%20Ranorex&amp;linkurl=http%3A%2F%2Fwww.ranorex.com%2Fblog%2Fresize-window"><img src="http://www.ranorex.com/blog/wp-content/plugins/add-to-any/share_save_120_16.png" width="120" height="16" alt="Share/Save/Bookmark"/></a>

	</p><img src="http://feeds.feedburner.com/~r/ranorex-blog/~4/S4Pa1nppIJA" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://www.ranorex.com/blog/resize-window/feed</wfw:commentRss>
		<feedburner:origLink>http://www.ranorex.com/blog/resize-window</feedburner:origLink></item>
		<item>
		<title>Using Ranorex 1.5 And 2.X Together in the Same Project</title>
		<link>http://feedproxy.google.com/~r/ranorex-blog/~3/IT84nl2X8IM/using-ranorex-15-and-2x-together-in-the-same-project</link>
		<comments>http://www.ranorex.com/blog/using-ranorex-15-and-2x-together-in-the-same-project#comments</comments>
		<pubDate>Fri, 13 Mar 2009 12:54:29 +0000</pubDate>
		<dc:creator>rkeele</dc:creator>
		
		<category><![CDATA[Test Automation]]></category>

		<guid isPermaLink="false">http://www.ranorex.com/blog/?p=133</guid>
		<description><![CDATA[Download Sample Project (11KB)
Requirements:

Ranorex 1.5 and 2.x installed on same machine.
 .NET 3.5 if you are using Ranorex Studio.

Steps:

Open an existing project that uses (References) the RanorexNet.DLL (
.csproj)
Select the RanorexNet reference and open the properties. Give it a new alias for example RanorexNet .
In all code files where the Ranorex namespace is used add
extern alias [...]]]></description>
			<content:encoded><![CDATA[<p><a href="http://www.ranorex.com/blog/wp-content/uploads/2009/03/calc15and2x1.zip">Download Sample Project (11KB)</a></p>
<p><strong>Requirements:</strong></p>
<ul>
<li>Ranorex 1.5 and 2.x installed on same machine.</li>
<li> .NET 3.5 if you are using Ranorex Studio.<span id="more-133"></span></li>
</ul>
<p><strong>Steps:</strong></p>
<ol>
<li>Open an existing project that uses (References) the RanorexNet.DLL (<br />
.csproj)</li>
<li>Select the RanorexNet reference and open the properties. Give it a new alias for example RanorexNet .<img class="alignnone size-full wp-image-145" title="ranorex15-reference" src="http://www.ranorex.com/blog/wp-content/uploads/2009/03/ranorex15-reference.gif" alt="ranorex15-reference" width="527" height="135" /></li>
<li>In all code files where the Ranorex namespace is used add
<pre name="code" class="c-sharp:nocontrols">extern alias &lt;new alias name&gt;;</pre>
<p>for example</p>
<pre name="code" class="c-sharp:nocontrols">extern alias RanorexNet;</pre>
<p>to the top of the file before all using statements. Then change</p>
<pre name="code" class="c-sharp:nocontrols">using Ranorex;</pre>
<p>to</p>
<pre name="code" class="c-sharp:nocontrols">using RanorexNet.Ranorex;</pre>
<p><img class="alignnone size-full wp-image-150" title="ranorex15-alias-namespace2" src="http://www.ranorex.com/blog/wp-content/uploads/2009/03/ranorex15-alias-namespace2.gif" alt="ranorex15-alias-namespace2" width="516" height="183" /><a href="http://www.ranorex.com/blog/wp-content/uploads/2009/03/ranorex15-alias-namespace.gif"><br />
</a></li>
<li>To use the Ranorex namespace from both the RanorexNet.dll and the Ranorex.Core.dll together in the same code file you will also need to alias the namespace for example
<pre name="code" class="c-sharp:nocontrols">using RX15 = RanorexNet::Ranorex;</pre>
</li>
<li>If you alias the name space in a code file you will also need to update the code to use the new qualified name. For example, change from
<pre name="code" class="c-sharp:nocontrols">Logger.LogFileTitle = "Ranorex Log File";</pre>
<p>to</p>
<pre name="code" class="c-sharp:nocontrols">RX15.Logger.LogFileTitle = "Ranorex Log File";</pre>
</li>
<li>Add a reference to the Ranorex.Core.dll from the GAC. Important, it is not recommended that you alias the Ranorex.Core.dll because the generated code doesn’t add the “extern alias” statement. However, feel free to alias the namespace whenever you need to.</li>
</ol>
<p><a href="http://www.ranorex.com/blog/wp-content/uploads/2009/03/calc15and2x1.zip">Download Sample Project (11KB)</a></p>
<p class="addtoany_share_save_container">
    <a class="a2a_dd addtoany_share_save" href="http://www.addtoany.com/share_save?sitename=Ranorex%20Blog&amp;siteurl=http%3A%2F%2Fwww.ranorex.com%2Fblog%2F&amp;linkname=Using%20Ranorex%201.5%20And%202.X%20Together%20in%20the%20Same%20Project&amp;linkurl=http%3A%2F%2Fwww.ranorex.com%2Fblog%2Fusing-ranorex-15-and-2x-together-in-the-same-project"><img src="http://www.ranorex.com/blog/wp-content/plugins/add-to-any/share_save_120_16.png" width="120" height="16" alt="Share/Save/Bookmark"/></a>

	</p><img src="http://feeds.feedburner.com/~r/ranorex-blog/~4/IT84nl2X8IM" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://www.ranorex.com/blog/using-ranorex-15-and-2x-together-in-the-same-project/feed</wfw:commentRss>
		<feedburner:origLink>http://www.ranorex.com/blog/using-ranorex-15-and-2x-together-in-the-same-project</feedburner:origLink></item>
		<item>
		<title>A first look at Windows 7</title>
		<link>http://feedproxy.google.com/~r/ranorex-blog/~3/ufJHJ2Mx-Xs/a-first-look-at-windows-7</link>
		<comments>http://www.ranorex.com/blog/a-first-look-at-windows-7#comments</comments>
		<pubDate>Fri, 27 Feb 2009 10:09:32 +0000</pubDate>
		<dc:creator>mgissing</dc:creator>
		
		<category><![CDATA[Test Automation]]></category>

		<guid isPermaLink="false">http://www.ranorex.com/blog/?p=93</guid>
		<description><![CDATA[With the new version of windows on the horizon, we had a first look at how Ranorex performs in the new environment. As it turns out, it works quite well. In the following, I want to point out a few interesting differences I found between Vista and Windows 7.
The first stop is the new taskbar. [...]]]></description>
			<content:encoded><![CDATA[<p>With the new version of windows on the horizon, we had a first look at how Ranorex performs in the new environment. As it turns out, it works quite well. In the following, I want to point out a few interesting differences I found between Vista and Windows 7.</p>
<p>The first stop is the new taskbar. Running programs are now represented with large icons instead of a labeled small icon.  Although it feels very different,  it is exactly the same from an automation point of view as in XP or Vista. Tasks are still represented as child items (or buttons)  of a toolbar:</p>
<p><img class="alignnone size-medium wp-image-97" title="toolbar1" src="http://www.ranorex.com/blog/wp-content/uploads/2009/02/toolbar1-546x430.png" alt="toolbar1" width="546" height="430" /><span id="more-93"></span></p>
<p>An interesting thing to note is that the &#8220;Start&#8221;-Button has been promoted to a top-level window and is no longer part of the task bar (In this case the RanorexPath is now &#8220;/button&#8221; instead of &#8220;/menubar/button&#8221;).</p>
<p>Most of the built-in tools also received an overhaul. As an example, let&#8217;s have a look at the Calculator:</p>
<p><img class="alignnone size-medium wp-image-94" title="calc1" src="http://www.ranorex.com/blog/wp-content/uploads/2009/02/calc1-546x239.png" alt="calc1" width="546" height="239" /></p>
<p>It looks like it has been rebuilt from scratch. If you are interested in details, you can have a look at a  <a href="http://www.ranorex.com/blog/wp-content/uploads/2009/02/calc.rxsnp">Calculator Ranorex Snapshot</a> file (Right click -&gt; Save As and open with Ranorex Spy).</p>
<p>Last but not least, Windows 7 also comes with Internet Explorer 8.  While this browser will also be available for the older Windows versions, it is definitely an integral part of Windows 7:</p>
<p><img class="alignnone size-medium wp-image-95" title="ie8" src="http://www.ranorex.com/blog/wp-content/uploads/2009/02/ie8-546x341.png" alt="ie8" width="546" height="341" /></p>
<p>The good news it that automation works just the same way as it does with IE6 or IE7, so running web tests should not pose a problem.</p>
<p class="addtoany_share_save_container">
    <a class="a2a_dd addtoany_share_save" href="http://www.addtoany.com/share_save?sitename=Ranorex%20Blog&amp;siteurl=http%3A%2F%2Fwww.ranorex.com%2Fblog%2F&amp;linkname=A%20first%20look%20at%20Windows%207&amp;linkurl=http%3A%2F%2Fwww.ranorex.com%2Fblog%2Fa-first-look-at-windows-7"><img src="http://www.ranorex.com/blog/wp-content/plugins/add-to-any/share_save_120_16.png" width="120" height="16" alt="Share/Save/Bookmark"/></a>

	</p><img src="http://feeds.feedburner.com/~r/ranorex-blog/~4/ufJHJ2Mx-Xs" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://www.ranorex.com/blog/a-first-look-at-windows-7/feed</wfw:commentRss>
		<feedburner:origLink>http://www.ranorex.com/blog/a-first-look-at-windows-7</feedburner:origLink></item>
		<item>
		<title>Ranorex V2.0 - Working with the new core</title>
		<link>http://feedproxy.google.com/~r/ranorex-blog/~3/iuklGcEDZ9g/ranorex-v20-working-with-the-new-core</link>
		<comments>http://www.ranorex.com/blog/ranorex-v20-working-with-the-new-core#comments</comments>
		<pubDate>Fri, 07 Nov 2008 15:03:38 +0000</pubDate>
		<dc:creator>cpreschern</dc:creator>
		
		<category><![CDATA[Test Automation]]></category>

		<guid isPermaLink="false">http://www.ranorex.com/blog/?p=89</guid>
		<description><![CDATA[Based on the current online available preview version of Ranorex V2.0 following blog post describes how to do test automation based on the new Ranorex elements and RanoreXPath.
Download Infragistics Ultragrid Sample (5KB)
The test automation code requires a running DynamicStyling application provided through the Infragistics NetAdvantage demo kit.
Ranorex V2.0 comes with a totally redesigned core automation [...]]]></description>
			<content:encoded><![CDATA[<p>Based on the current online available preview version of Ranorex V2.0 following blog post describes how to do test automation based on the new Ranorex elements and RanoreXPath.</p>
<p><strong><a href="http://www.ranorex.com/blog/wp-content/uploads/2008/11/infragisticsultragridsample.zip">Download Infragistics Ultragrid Sample (5KB)</a></strong><br />
<em>The test automation code requires a running DynamicStyling application provided through the Infragistics NetAdvantage demo kit.</em></p>
<p>Ranorex V2.0 comes with a totally redesigned core automation library. Based on the new possibilities of the core, the features of Ranorex tools like Ranorex Recorder have grown extremely to provide a more comfortable way of UI test automation. But not only the Ranorex tool set benefits from the new core library as following example shows.<span id="more-89"></span></p>
<p>The code gives a brief overview of how to work with Ranorex V2.0 core library directly. The example describes how to iterate through a 3rd party Infragistics UltraGrid control.</p>
<p><a href="http://www.ranorex.com/blog/wp-content/uploads/2008/11/spyinfragistics.png"><img class="aligncenter size-medium wp-image-90" title="spyinfragistics" src="http://www.ranorex.com/blog/wp-content/uploads/2008/11/spyinfragistics-546x273.png" alt="Ranorex V2.0 Spy with Infragistics UltraGrid" width="546" height="273" /></a></p>
<pre name="code" class="c-sharp:nocontrols">InfragisticsObj guiObj = InfragisticsObj.Instance;
guiObj.InfragisticsApp.Window.EnsureVisible();
Mouse.MoveTo(guiObj.InfragisticsApp.Window.Element);

foreach (Row  row in guiObj.InfragisticsApp.UltraGridTable.Rows)
{
  // Checks whether current row (node) is collapsed or not
  //System.Windows.Forms.AccessibleStates states = (System.Windows.Forms.AccessibleStates)row.Element.GetAttributeValue("accessiblestate");
  Accessible accObj = row.Element;

  if ( (accObj.State &#038; System.Windows.Forms.AccessibleStates.Collapsed) != 0)
  {
    row.Focus();
    // Using relative coordinates to expand
    // collapsed node
    Mouse.Click(row.Element, new Location(new System.Drawing.Point(8, 8)));
 }

 // Request all cells of the current row
 // using the children property
 foreach (Cell cell in row.Cells)
 {
   cell.Focus();
   Mouse.Click(cell.Element, 2, new TimeSpan(0,0,0,0,10));
   // Simulate select all using keyboard actions
   Keyboard.Press(System.Windows.Forms.Keys.Home);
   Keyboard.Press("{LShiftKey down}{End}{LShiftKey up}");
   Accessible accCell = cell.Element;
   Keyboard.Press(accCell.Value);
 }

 // Request all cells from the subrows
 // using RanoreXPath
 IList<Element> allSubCells = row.Element.Find(new RxPath("row/cell"));

 foreach (Cell cell in allSubCells)
 {
   cell.Focus(); // ensures visibility
   // prepare text to set
   // using parent information
   Accessible accCell = cell.Element;

   string cellText = String.Format("Cell ({0},{1})",
                                    ((Accessible)cell.Element.Parent).Name,
                        			((Accessible)cell.Element).Name);

   accCell.Value = cellText;
 }
}</pre>
<p>Normally, the previous code should be quite easy to understand. Maybe the code line</p>
<pre name="code" class="c-sharp:nocontrols"> IList allSubCells = row.Element.Find(new RxPath("row/cell"));</pre>
<p>requires a more detailed description.</p>
<p>RanoreXPath could be seen as a query string to search for UI elements within the Ranorex element tree shown by RanorexSpy. In case of the current example the search starts from a specific Ranorex.Row item named &#8216;row&#8217; to retrieve all sub cells regardless to which sub row element they belong.</p>
<p><a href="http://www.ranorex.com/blog/wp-content/uploads/2008/11/ranorexpath_cells.png"><img class="alignnone size-medium wp-image-91" title="ranorexpath_cells" src="http://www.ranorex.com/blog/wp-content/uploads/2008/11/ranorexpath_cells.png" alt="Returned cells from RanoreXPath query string" width="238" height="357" /></a></p>
<p>The use of RanoreXPath allows not only a more flexible search or filtering for UI elements, but also some kind of validation to check attributes or current states of a control. In addition there is always the standard way of automation supported through Ranorex adapters (Tables, Rows, Columns, Cells, &#8230;) representing role specific UI elements providing access to their children again. In short, everything you see with RanorexSpy is accessible and available through the Ranorex core interface.</p>
<p class="addtoany_share_save_container">
    <a class="a2a_dd addtoany_share_save" href="http://www.addtoany.com/share_save?sitename=Ranorex%20Blog&amp;siteurl=http%3A%2F%2Fwww.ranorex.com%2Fblog%2F&amp;linkname=Ranorex%20V2.0%20-%20Working%20with%20the%20new%20core&amp;linkurl=http%3A%2F%2Fwww.ranorex.com%2Fblog%2Franorex-v20-working-with-the-new-core"><img src="http://www.ranorex.com/blog/wp-content/plugins/add-to-any/share_save_120_16.png" width="120" height="16" alt="Share/Save/Bookmark"/></a>

	</p><img src="http://feeds.feedburner.com/~r/ranorex-blog/~4/iuklGcEDZ9g" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://www.ranorex.com/blog/ranorex-v20-working-with-the-new-core/feed</wfw:commentRss>
		<feedburner:origLink>http://www.ranorex.com/blog/ranorex-v20-working-with-the-new-core</feedburner:origLink></item>
		<item>
		<title>Data driven test automation with Excel</title>
		<link>http://feedproxy.google.com/~r/ranorex-blog/~3/0lhyD6W5a00/data-driven-test-automation-with-excel</link>
		<comments>http://www.ranorex.com/blog/data-driven-test-automation-with-excel#comments</comments>
		<pubDate>Wed, 23 Jul 2008 09:08:05 +0000</pubDate>
		<dc:creator>cpreschern</dc:creator>
		
		<category><![CDATA[Test Automation]]></category>

		<guid isPermaLink="false">http://www.ranorex.com/blog/?page_id=85</guid>
		<description><![CDATA[Download Ranorex
Download Ranorex Studio Excel Sample for Ranorex 2.0 (15KB)
Microsoft Excel is often used to store and manage test cases and test data. Why? Because Excel is a widespread tool. Nearly every Windows based machine has installed Microsoft Office.
Following example describes how to feed a Ranorex test automation process with test data stored within an [...]]]></description>
			<content:encoded><![CDATA[<p><a href="http://www.ranorex.com/download.html">Download Ranorex</a></p>
<p><strong><a href="http://www.ranorex.com/blog/wp-content/uploads/2008/07/ExcelTestDataConnectorV2.0.zip">Download Ranorex Studio Excel Sample for Ranorex 2.0 (15KB)</a></strong></p>
<p>Microsoft Excel is often used to store and manage test cases and test data. Why? Because Excel is a widespread tool. Nearly every Windows based machine has installed Microsoft Office.<span id="more-85"></span><br />
Following example describes how to feed a Ranorex test automation process with test data stored within an Excel table. The example consists of 3 main parts:</p>
<ul>
<li>Excel sheet containing test data</li>
<li>Ranorex automation project</li>
<li>Excel connector to read test data from Excel</li>
</ul>
<p><a href="http://www.ranorex.com/blog/wp-content/uploads/2008/07/tdd-with-excel.png"><img class="alignnone size-medium wp-image-86" title="Data driven testing with Excel" src="http://www.ranorex.com/blog/wp-content/uploads/2008/07/tdd-with-excel-546x298.png" alt="Data driven testing with Excel" width="546" height="298" /></a></p>
<p><strong>Excel Sheet</strong></p>
<p>As usual, we use the Windows calculator in this example of data driven testing. Each row defines a single test case with test data <strong>inputs </strong>and expected <strong>outputs</strong>. In addition, each test case has a short <strong>description</strong>.</p>
<p><strong>ExcelConnector class</strong></p>
<p>To provide a user-friendly interface for retrieving test data from an Excel sheet, we implement an ExcelConnector. This class wraps the functionality of a Microsoft COM library to access rows and cells in a data sheet. Thus we have to add the COM library as reference object to our project.</p>
<p><a href="http://www.ranorex.com/blog/wp-content/uploads/2008/07/addexcelreference.png"><img class="alignnone size-medium wp-image-87" title="Add Excel Reference" src="http://www.ranorex.com/blog/wp-content/uploads/2008/07/addexcelreference-546x402.png" alt="Add Excel Reference" width="546" height="402" /></a></p>
<pre name="code" class="c-sharp">public class ExcelConnector
{
    private string excelFile = null;
    private Excel.Application excelObj = null;
    private Excel.Workbook workBook = null;
    private Excel.Worksheet worksheet = null;
    private UInt16 currentRowIndex = 0;
    private string[] inputs;
    private string[] outputs;

    public string ExcelFile
    {
        get
        {
            return this.excelFile;
        }
    }
    public UInt16 CurrentRowIndex
    {
        get
        {
            return this.currentRowIndex;
        }
    }       

    public ExcelConnector(string excelFile, string[] inputs, string[] outputs, bool load, UInt16 startRow)
    {
        this.excelFile = excelFile;
        this.inputs = inputs;
        this.outputs = outputs;
        if (load)
           this.LoadFile();
        currentRowIndex = startRow;
    }

    public void LoadFile()
    {
        excelObj = new Excel.Application();
        System.Threading.Thread.CurrentThread.CurrentCulture = new
                                             System.Globalization.CultureInfo("en-US");
        workBook = excelObj.Workbooks.Open(this.excelFile, 0, true, 5, "", "", true,
                                             Excel.XlPlatform.xlWindows, "\t", false, false, 0, true, false, false);
        Excel.Sheets sheets = workBook.Worksheets;
        worksheet = (Excel.Worksheet)sheets.get_Item(1);
    }

    public TestData GetNext()
    {
        string[] arrInputs = new string[inputs.Length];
        string[] arrOutputs = new string[outputs.Length];

        for (int i = 1; i &lt; this.inputs.Length+1; i++)
        {
            Excel.Range cell = (Excel.Range)worksheet.Cells[currentRowIndex, i];
            if ( ((string)cell.Text).Length == 0 )
            	return null;
            arrInputs[i - 1] = (string)cell.Text;
        }
        for (int i = 0; i &lt; this.outputs.Length ; i++)
        {
            Excel.Range cell = (Excel.Range)worksheet.Cells[currentRowIndex, i + inputs.Length + 1];
            if ( ((string)cell.Text).Length == 0 )
             	return null;
            arrOutputs[i] = (string)cell.Text;
        }

        Excel.Range cellComment = (Excel.Range)worksheet.Cells[currentRowIndex,
                                                        inputs.Length+outputs.Length+1];
        currentRowIndex++;
        return new TestData(arrInputs, arrOutputs, (string)cellComment.Text);
    }

    public void Dispose()
    {
        excelObj.Quit();
    }
}</pre>
<p>The constructor of the class &#8216;ExcelConnector&#8217; specifies the name of the Excel file, the amount of in- and outputs defined by each test case and where to start reading test data. The &#8216;GetNext()&#8217; method returns a simple TestData object representing a single row from the excel sheet.</p>
<p><strong>Ranorex test automation code</strong></p>
<p>The following code shows how to use the &#8216;ExcelConnector&#8217; class to read test data from the excel sheet.</p>
<pre name="code" class="c-sharp">TestData testData;

openFileDialog.DefaultExt = "xlsx";

openFileDialog.Filter = "XLS file (*.xls)|*.xls|XLSX file (*.xlsx)|*.xlsx|All files (*.*)|*.*";
if ( openFileDialog.ShowDialog() == System.Windows.Forms.DialogResult.OK )
{
    this.tbExcelFile.Text = openFileDialog.FileName;
}

void InitExcelConnection()
{
    string[] testDataInputs = new string[] { "Input1", "Input2", "Input3", "Input4" };
    string[] testDataOutputs = new string[] { "Output1" };
    if (System.IO.File.Exists(tbExcelFile.Text))
         excelConnector = new ExcelConnector(this.tbExcelFile.Text,
                                    testDataInputs, testDataOutputs, true,2);
    else
         throw new RanorexException(null,"Specified file does not exist!");
}

InitExcelConnection();

while ((testData = excelConnector.GetNext()) != null )
{
    Ranorex.Control bt = null;
    foreach (string str in testData.Inputs)
    {
        foreach (char c in str)
        {
            bt = calcForm.FindChildText(c.ToString());
            Mouse.ClickControl(bt);
        }
    }
    bt = calcForm.FindControlId(403);
    // Compare calculator output with expected value
    Ranorex.Validate.HasText(bt, testData.Outputs[0] + ", ",testData.Description + " validation",false);
}</pre>
<p>An Excel connector could be a smart solution to reuse existing manual tests stored in excel sheets and to provide an easy to use test case data base, especially for those testers without deeper Ranorex test automation knowledge.</p>
<p class="addtoany_share_save_container">
    <a class="a2a_dd addtoany_share_save" href="http://www.addtoany.com/share_save?sitename=Ranorex%20Blog&amp;siteurl=http%3A%2F%2Fwww.ranorex.com%2Fblog%2F&amp;linkname=Data%20driven%20test%20automation%20with%20Excel&amp;linkurl=http%3A%2F%2Fwww.ranorex.com%2Fblog%2Fdata-driven-test-automation-with-excel"><img src="http://www.ranorex.com/blog/wp-content/plugins/add-to-any/share_save_120_16.png" width="120" height="16" alt="Share/Save/Bookmark"/></a>

	</p><img src="http://feeds.feedburner.com/~r/ranorex-blog/~4/0lhyD6W5a00" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://www.ranorex.com/blog/data-driven-test-automation-with-excel/feed</wfw:commentRss>
		<feedburner:origLink>http://www.ranorex.com/blog/data-driven-test-automation-with-excel</feedburner:origLink></item>
		<item>
		<title>Transfering data to and from a .NET control</title>
		<link>http://feedproxy.google.com/~r/ranorex-blog/~3/IPsDVRIEJUM/transfering-data-to-and-from-a-net-control</link>
		<comments>http://www.ranorex.com/blog/transfering-data-to-and-from-a-net-control#comments</comments>
		<pubDate>Mon, 14 Jul 2008 09:38:40 +0000</pubDate>
		<dc:creator>ahoisl</dc:creator>
		
		<category><![CDATA[Test Automation]]></category>

		<category><![CDATA[.NET Controls]]></category>

		<category><![CDATA[InvokeRemotely]]></category>

		<category><![CDATA[Serializable]]></category>

		<category><![CDATA[System.Windows.Forms]]></category>

		<guid isPermaLink="false">http://www.ranorex.com/blog/?p=84</guid>
		<description><![CDATA[Whenever you want to retrieve data from a .NET control using Ranorex, the data needs to be marshalled across process boundaries. In the Control class Ranorex provides methods - like the GetPropertyValue, SetPropertyValue, InvokeMethod, and InvokeRemotely - that handle the cross process marshalling of data for you. However, to be transferable, the data (parameters and [...]]]></description>
			<content:encoded><![CDATA[<p>Whenever you want to retrieve data from a .NET control using Ranorex, the data needs to be marshalled across process boundaries. In the <em>Control </em>class Ranorex provides methods - like the <em>GetPropertyValue</em>, <em>SetPropertyValue</em>, <em>InvokeMethod</em>, and <em>InvokeRemotely </em>- that handle the cross process marshalling of data for you. However, to be transferable, the data (parameters and return objects) need to be serializable. All the primitive data types of the .NET framework (<em>int</em>, <em>double</em>, <em>string</em>) and many complex types are serializable, but what if the data you want is not?<br />
<span id="more-84"></span><br />
First of all, how do we know whether data is serializable or not? If the type of the data object is marked with a <em>SerializableAttribute</em>, then there&#8217;s a pretty good chance that the object is serializable; otherwise it is not. Consequently, when you use the <em>GetPropertyValue</em>, <em>SetPropertyValue</em>, or <em>InvokeMethod </em>methods, you have to check if the types of all the parameters and of the return value are serializable. The only exceptions are container and collections types that are themselves serializable (they are marked with the <em>SerializableAttribute</em>), but contain instances of types that aren&#8217;t.</p>
<p>So, if your data are all serializable, then just use the methods listed above. Everything will work just fine and there&#8217;s absolutely no sense in writing a blog post about that. &#8230; Well, usually most of the control developers don&#8217;t care if the types their control properties are serializable or not. That&#8217;s why we sometimes need to use a workaround to transfer our data from/to the control.</p>
<p>Ranorex V1.5 introduces a new method called <strong><em>Control</em></strong>.<strong><em>InvokeRemotely </em></strong>that allows us to execute code in the process of the control we want to exchange data with. (Note: This method is also available in Ranorex 2.X. This post and the sample code in it apply both to Ranorex 1.5 and 2.X versions.) Using that method, we can break up the unserializable data into serializable chunks in one process, transfer them, and finally reassemble them at the other process.</p>
<p>Assume that we want to get the text of all items in a <em>ListView</em>. Then we can call <em>InvokeRemotely </em>passing a delegate that collects the text values and stores them in a list (which is serializable):</p>
<pre name="code" class="c-sharp">string[] itemTextValues = (string[])listView.InvokeRemotely(
    delegate(System.Windows.Forms.Control control)
    {
        System.Windows.Forms.ListView remoteListView = (System.Windows.Forms.ListView)control;
        List values = new List();
        foreach (System.Windows.Forms.ListViewItem item in remoteListView.Items)
        {
            values.Add(item.Text);
        }
        return values.ToArray();
    });</pre>
<p>If you want to retrieve more info about each list item, then you need to create a serializable data container:</p>
<pre name="code" class="c-sharp">[Serializable]
private class SerializableOutputData
{
    public bool Checked;
    public string Text;
}

private static object GetListViewData(System.Windows.Forms.Control control)
{
    System.Windows.Forms.ListView remoteListView = (System.Windows.Forms.ListView)control;
    List&lt;SerializableOutputData&gt; remoteOutputData = new List&lt;SerializableOutputData&gt;();
    foreach (System.Windows.Forms.ListViewItem item in remoteListView.Items)
    {
        SerializableOutputData data = new SerializableOutputData();
        data.Checked = item.Checked;
        data.Text = item.Text;
        remoteOutputData.Add(data);
    }
    return remoteOutputData.ToArray();
}
...
// call the GetListViewData method from the main method
SerializableOutputData[] outputData = (SerializableOutputData[])listView.InvokeRemotely(GetListViewData);</pre>
<p>If you are not using anonymous methods, make sure to declare the delegate method static like in the example above. Or make the method member of a serializable type. This is actually necessary if you want to transfer data to the control. For instance, if you want to get information on all the list items which text property begins with a certain prefix:</p>
<pre name="code" class="c-sharp">[Serializable]
private class SerializableInputData
{
    public string Prefix;
    public object GetListViewData(System.Windows.Forms.Control control)
    {
        System.Windows.Forms.ListView remoteListView = (System.Windows.Forms.ListView)control;
        List&lt;SerializableOutputData&gt; remoteOutputData = new List&lt;SerializableOutputData&gt;();
        foreach (System.Windows.Forms.ListViewItem item in remoteListView.Items)
        {
            if (item.Text.StartsWith(Prefix))
            {
                SerializableOutputData data = new SerializableOutputData();
                data.Checked = item.Checked;
                data.Text = item.Text;
                remoteOutputData.Add(data);
            }
        }
        return remoteOutputData.ToArray();
    }
}
... // in the main method
SerializableInputData inputData = new SerializableInputData();
inputData.Prefix = "i";
SerializableOutputData[] outputData = (SerializableOutputData[])listView.InvokeRemotely(inputData.GetListViewData);</pre>
<p>I hope that this post illustrates when and how to use the <em>Control</em>.<em>InvokeRemotely </em>method. If the desired data is not serializable, the <em>GetPropertyValue</em>, <em>SetPropertyValue</em>, and <em>InvokeMethod </em>methods won&#8217;t work. The <em>InvokeRemotely </em>method provides a convenient way to split the unserializable data into serializable parts and transfer the data that way.</p>
<p class="addtoany_share_save_container">
    <a class="a2a_dd addtoany_share_save" href="http://www.addtoany.com/share_save?sitename=Ranorex%20Blog&amp;siteurl=http%3A%2F%2Fwww.ranorex.com%2Fblog%2F&amp;linkname=Transfering%20data%20to%20and%20from%20a%20.NET%20control&amp;linkurl=http%3A%2F%2Fwww.ranorex.com%2Fblog%2Ftransfering-data-to-and-from-a-net-control"><img src="http://www.ranorex.com/blog/wp-content/plugins/add-to-any/share_save_120_16.png" width="120" height="16" alt="Share/Save/Bookmark"/></a>

	</p><img src="http://feeds.feedburner.com/~r/ranorex-blog/~4/IPsDVRIEJUM" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://www.ranorex.com/blog/transfering-data-to-and-from-a-net-control/feed</wfw:commentRss>
		<feedburner:origLink>http://www.ranorex.com/blog/transfering-data-to-and-from-a-net-control</feedburner:origLink></item>
	</channel>
</rss>
