<?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>
	<atom:link href="http://www.ranorex.com/blog/feed" rel="self" type="application/rss+xml" />
	<link>http://www.ranorex.com/blog</link>
	<description>Software Automation &amp; Automated Testing Blog</description>
	<pubDate>Fri, 13 Mar 2009 12:54:54 +0000</pubDate>
	<generator>http://wordpress.org/?v=2.7.1</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<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. That way, 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>
		<item>
		<title>Ranorex automates Ranorex</title>
		<link>http://feedproxy.google.com/~r/ranorex-blog/~3/rt6bZuBWFmM/ranorex-automates-ranorex</link>
		<comments>http://www.ranorex.com/blog/ranorex-automates-ranorex#comments</comments>
		<pubDate>Tue, 10 Jun 2008 11:57:53 +0000</pubDate>
		<dc:creator>cpreschern</dc:creator>
		
		<category><![CDATA[Test Automation]]></category>

		<guid isPermaLink="false">http://www.ranorex.com/blog/?p=81</guid>
		<description><![CDATA[Does Ranorex test their own products with Ranorex?
Yes, they do, as following sample describes. The Ranorex WebSpy tool is one of the user interfaces provided by the Automation Framework for analyzing web applications.

To start with, when you use Ranorex Spy to examine WebSpy it looks as if it will be quite easy to automate the [...]]]></description>
			<content:encoded><![CDATA[<p>Does Ranorex test their own products with Ranorex?<br />
Yes, they do, as following sample describes. The Ranorex WebSpy tool is one of the user interfaces provided by the Automation Framework for analyzing web applications.<br />
<span id="more-81"></span><br />
To start with, when you use Ranorex Spy to examine WebSpy it looks as if it will be quite easy to automate the GUI controls (.NET Controls). Not surprisingly, you will notice that Ranorex leads by example here as all GUI controls in WebSpy have unique identifiers. Below is some of our simple automation code …</p>
<pre name="code" class="c-sharp">// Search for WebSpy application
 Form webSpyForm = Application.FindFormTitle("Ranorex WebSpy", SearchMatchMode.MatchExact, true);
// Test 'Options' menu
MenuStrip menu = webSpyForm.FindMenuStrip("menuStripMain");

// Open 'Start page' dialog
menu.SelectItemText("Options", "Set start page ...");

Form startPage = Application.FindFormTitle("Start page", SearchMatchMode.MatchExact, true);
TextBox startUrlTextBox = startPage.FindTextBox("startPageUrlTextBox");
startUrlTextBox.Text = "www.google.com";

// Click 'Default' button
Button useDefaultButton = startPage.FindButton("useDefaultButton");
Mouse.ClickControl(useDefaultButton);

// Click 'OK' button
Button okButton = startPage.FindButton("okButton");
Mouse.ClickControl(okButton);

TextBox textBoxAddress = webSpyForm.FindTextBox("textBoxAddress");
Mouse.ClickControl(textBoxAddress);

// Navigate to www.ranorex.com
textBoxAddress.Text = "www.ranorex.com";
Application.Sleep(500);
Application.SendKeys("{ENTER}");</pre>
<p>Not a big challenge until now. But not only the typical GUI elements (menus, buttons, tab controls, &#8230;) have to be tested automatically.<br />
The most complex control is the integrated browser control which has to be tested, too. So the key target of our test is to validate the interaction of .NET controls with the web elements of a web site.</p>
<p><a href="http://www.ranorex.com/blog/wp-content/uploads/2008/06/screenshot.png"><img class="aligncenter size-medium wp-image-82" title="screenshot" src="http://www.ranorex.com/blog/wp-content/uploads/2008/06/screenshot-300x209.png" alt="WebSpy analyzed with Ranorex Spy Pro" width="300" height="209" /></a></p>
<pre name="code" class="c-sharp">// Search for integrated browser
Control browserControl = webSpyForm.FindClassName("Internet Explorer_Server", 1);

// Find link 'Products' within website and move mouse cursor to web element
WebDocument doc = WebDocument.GetDocument(browserControl,2000);
WebElement productLink = doc.FindSingle("//a[text()='Products']");
Mouse.MoveToWebElement(productLink);

// Simulate hot key
Application.SendKeys("{CTRLDOWN}{CTRLUP}", 570);

// Click tabs from WebSpy
Control tabControl = webSpyForm.FindControlName("tabControlElement");
Element[] tabs = tabControl.Element.FindChildren(Role.PageTab);
foreach (Element tab in tabs)
{
    Mouse.ClickElement(tab);
}

// Select 'MouseMoveTo' link item
Element actionsTab = tabControl.Element.FindChild(Role.PageTab, "Actions");
Element link = actionsTab.FindChild(Role.Link, "MouseMoveTo");
Mouse.ClickElement(link);</pre>
<p>The big advantage with RanorexNet is that there is no difference between testing web sites with Internet Explorer or testing web sites which are integrated in other applications as shown with Ranorex WebSpy.</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%20automates%20Ranorex&amp;linkurl=http%3A%2F%2Fwww.ranorex.com%2Fblog%2Franorex-automates-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/rt6bZuBWFmM" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://www.ranorex.com/blog/ranorex-automates-ranorex/feed</wfw:commentRss>
		<feedburner:origLink>http://www.ranorex.com/blog/ranorex-automates-ranorex</feedburner:origLink></item>
		<item>
		<title>Global GUI map for automation with VS.NET</title>
		<link>http://feedproxy.google.com/~r/ranorex-blog/~3/8HG-8Y9rQIo/global-gui-map-for-automation-with-vsnet</link>
		<comments>http://www.ranorex.com/blog/global-gui-map-for-automation-with-vsnet#comments</comments>
		<pubDate>Thu, 10 Apr 2008 08:31:31 +0000</pubDate>
		<dc:creator>cpreschern</dc:creator>
		
		<category><![CDATA[Test Automation]]></category>

		<guid isPermaLink="false">http://www.ranorex.com/blog/?p=66</guid>
		<description><![CDATA[Writing test code based on RanoreXPath is not a big challenge. In fact, it&#8217;s always the same procedure. First, find the element within a web page. After that, automate it (click, set value,&#8230;). Two simple steps. Nevertheless, the bigger your test code the more structured and well designed it should be.

RanoreXPath allows many different ways [...]]]></description>
			<content:encoded><![CDATA[<p>Writing test code based on RanoreXPath is not a big challenge. In fact, it&#8217;s always the same procedure. First, find the element within a web page. After that, automate it (click, set value,&#8230;). Two simple steps. Nevertheless, the bigger your test code the more structured and well designed it should be.<br />
<span id="more-66"></span><br />
RanoreXPath allows many different ways of searching for web elements within a web page. The use of       Ranorex WebSpy could tempt someone to always copy &amp; paste RanoreXPaths from WebSpy into the test automation code. What an easy job. But consider that searching elements from scratch permanently could be time consuming, especially if using optimized RanoreXPaths. Moreover, the resulting test automation code is not as readable as we would like to have it. Take a look at following code lines:</p>
<pre name="code" class="c-sharp">using System;
using System.Collections.Generic;
using System.Text;
using Ranorex;
using Ranorex.Web;

namespace WebTestDont
{
&nbsp;   class Program
&nbsp;   {
&nbsp;       static void Main(string[] args)
&nbsp;       {
&nbsp;           // Resource based identification of web elements
&nbsp;           WebDocument exampleDoc = WebDocument.OpenDocument("www.ranorex.com/web-testing-examples", true);

&nbsp;           // Find 'Name' textbox within form
&nbsp;           WebElement name = exampleDoc.FindSingle("//input[@id='testname']");
&nbsp;           Mouse.MoveToWebElement(name);
&nbsp;           name.Value = "Mr. XYZ";

&nbsp;           // Find 'Color' drop down box within form
&nbsp;           WebElement colorSelector = exampleDoc.FindSingle("//select[@id='testcolor']");
&nbsp;           Mouse.MoveToWebElement(colorSelector);
&nbsp;           colorSelector.Value = "blue";

&nbsp;           // ... search for next elements ...
&nbsp;       }
&nbsp;   }
}</pre>
<p>I know, the few code lines above don&#8217;t give a good example for a long and unreadable test code. But what we can see, is that the example always starts the element search from scratch by calling the method &#8216;FindSingle&#8217; from the &#8216;exampleDoc&#8217; object. Another problem is the use of hard-coded RanoreXPath expressions. Due to changes within your AUT (application under test) you may need to update your code lines with new RanoreXPath expressions, to ensure your test is still workable .</p>
<p>For that reason it&#8217;s advisable to extract and separate your RanoreXPath search strings from your test codes. There are many different types to generate global mapping/resource information. The next section concentrates on the use of resource files provided by Microsoft Visual Studio.</p>
<p><a title="Visual Studio resource table for GUI mapping" href="http://www.ranorex.com/blog/wp-content/uploads/2008/04/guimappingresource3.png" mce_href="http://www.ranorex.com/blog/wp-content/uploads/2008/04/guimappingresource3.png"><img src="http://www.ranorex.com/blog/wp-content/uploads/2008/04/guimappingresource3.thumbnail.png" mce_src="http://www.ranorex.com/blog/wp-content/uploads/2008/04/guimappingresource3.thumbnail.png" alt="Visual Studio resource table for GUI mapping"></a></p>
<p>Visual Studio provides resource files for storing several types of objects (Images, Icons, Strings, &#8230;). Our use case only requires a resource table of type string. Simple add a new resource file called &#8216;GuiMapping&#8217; to your Visual Studio project.</p>
<p>To add a resource file please</p>
<ul>
<li>open your Visual Studio project properties and</li>
<li>add a new resource within the &#8216;Resource&#8217; tab.</li>
</ul>
<p><a title="Resource based GUI mapping" href="http://www.ranorex.com/blog/wp-content/uploads/2008/04/guimapping.png" mce_href="http://www.ranorex.com/blog/wp-content/uploads/2008/04/guimapping.png"><img src="http://www.ranorex.com/blog/wp-content/uploads/2008/04/guimapping.thumbnail.png" mce_src="http://www.ranorex.com/blog/wp-content/uploads/2008/04/guimapping.thumbnail.png" alt="Resource based GUI mapping"></a></p>
<p>The use of resource files extracts complex search strings from test code and concentrates searching information at one single location. The static &#8216;GuiMapping&#8217; object is easy to use during coding and provides all necessary RanoreXPath expressions. In addition to that, the following implementation speeds up the search of web elements: In the first step we search for the web element of type &#8216;form&#8217;. After that, each search for web elements located within this form can be done by calling the method &#8216;FindSingle&#8217; on the form object.</p>
<pre name="code" class="c-sharp">using System;
using System.Collections.Generic;
using System.Text;

using Ranorex;
using Ranorex.Web;

namespace WebTest
{
&nbsp;   // Using 'Properties' namespace to access
&nbsp;   // Resource elements
&nbsp;   using Properties;

&nbsp;   class Program
&nbsp;   {
&nbsp;       [STAThread]
&nbsp;       static void Main(string[] args)
&nbsp;       {
&nbsp;           // Resource based identification of web elements
&nbsp;           WebDocument exampleDoc = WebDocument.OpenDocument(GuiMapping.WebTestUrl, true);
&nbsp;           WebElement form = exampleDoc.FindSingle(GuiMapping.WebTestForm);

&nbsp;           // Find 'Name' textbox within form
&nbsp;           WebElement name = form.FindSingle(GuiMapping.WebTestName);
&nbsp;           Mouse.MoveToWebElement(name);
&nbsp;           name.Value = "Mr. XYZ";

&nbsp;           // Find 'Color' drop down box within form
&nbsp;           WebElement colorSelector = form.FindSingle(GuiMapping.WebTestColors);
&nbsp;           Mouse.MoveToWebElement(colorSelector);
&nbsp;           colorSelector.Value = "blue";
&nbsp;       }
&nbsp;   }
}</pre>
<p>For that reason, outsourcing of searching criteria enhances readability and coding maintenance for future extensions.</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=Global%20GUI%20map%20for%20automation%20with%20VS.NET&amp;linkurl=http%3A%2F%2Fwww.ranorex.com%2Fblog%2Fglobal-gui-map-for-automation-with-vsnet"><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/8HG-8Y9rQIo" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://www.ranorex.com/blog/global-gui-map-for-automation-with-vsnet/feed</wfw:commentRss>
		<feedburner:origLink>http://www.ranorex.com/blog/global-gui-map-for-automation-with-vsnet</feedburner:origLink></item>
		<item>
		<title>Web Automation with Python for .NET</title>
		<link>http://feedproxy.google.com/~r/ranorex-blog/~3/u4w12GRvIaM/web-automation-with-python-for-net</link>
		<comments>http://www.ranorex.com/blog/web-automation-with-python-for-net#comments</comments>
		<pubDate>Fri, 04 Apr 2008 12:31:58 +0000</pubDate>
		<dc:creator>ahoisl</dc:creator>
		
		<category><![CDATA[Test Automation]]></category>

		<category><![CDATA[python]]></category>

		<category><![CDATA[python for .net]]></category>

		<category><![CDATA[web automation]]></category>

		<guid isPermaLink="false">http://www.ranorex.com/blog/web-automation-with-python-for-net</guid>
		<description><![CDATA[Unlike the traditional Ranorex API, the new Web Automation API is natively provided only for .NET languages. However, there are two easy ways how you can still use Python with Ranorex Web Automation.

IronPython
The first option is IronPython, a new implementation of the Python programming language for the .NET framework. Basically, this is a new Python [...]]]></description>
			<content:encoded><![CDATA[<p>Unlike the traditional Ranorex API, the new Web Automation API is natively provided only for .NET languages. However, there are two easy ways how you can still use Python with Ranorex Web Automation.</p>
<p><span id="more-64"></span></p>
<h4>IronPython</h4>
<p>The first option is <a href="http://www.codeplex.com/IronPython" target="_blank" title="IronPython">IronPython</a>, a new implementation of the Python programming language for the .NET framework. Basically, this is a new Python compiler producing .NET intermediate language code. It claims to be fully compatible with the <a href="http://www.python.org/doc/ref/" target="_blank" title="Python Language Reference">Python Language Reference</a>, but code written for the original <a href="http://www.python.org/" target="_blank" title="CPython">CPython </a>may not produce the same output if run with IronPython (see <a href="http://www.codeplex.com/IronPython/Wiki/View.aspx?title=Differences&amp;referringTitle=Home" target="_blank" title="Differences between IronPython 1.0 and CPython 2.4.3">Differences between IronPython 1.0 and CPython 2.4.3</a>).</p>
<h4>Python for .NET</h4>
<p>The second option is the one I will concentrate on in this blog: <a href="http://pythonnet.sourceforge.net/" target="_blank" title="Python for .NET">Python for .NET</a>. This package provides a bridge for CPython to .NET assemblies (framework as well as user written ones). Python users continue to use the CPython interpreter and classes they are familiar with while additionally gaining access to classes written in any .NET language, e.g the classes in the Ranorex Web Automation API.</p>
<h3>Installation</h3>
<p>Unfortunately, since the latest release of Python for .NET more than half a year has gone by and some crucial bugs have been fixed meanwhile. That&#8217;s why we use the latest version from the <a href="https://pythonnet.svn.sourceforge.net/svnroot/pythonnet/trunk/" target="_blank" title="SVN repository">SVN repository</a> instead.</p>
<ol>
<li>
<div>Check out and build the latest version of Python for .NET from the <a href="https://pythonnet.svn.sourceforge.net/svnroot/pythonnet/trunk/" target="_blank" title="SVN repository">SVN repository</a>. You need to set the <em>Conditional compilation symbols</em> in the <strong>Properties</strong> of the <strong>Python.Runtime project</strong> to match your CPython version (e.g. &#8220;PYTHON24,UCS2&#8243; for CPython version 2.4 and &#8220;PYTHON25,UCS2&#8243; for version 2.5).<br />
<strong>NOTE</strong>: For CPython version 2.3, 2.4, or 2.5 we have done that step for you, so you can <a href="http://www.ranorex.com/blog/wp-content/uploads/2008/04/pythonfornet-20080404.zip" title="Download Python for .NET binaries">download</a> built binaries from the Ranorex web server.</div>
</li>
<li>
<div><strong>Copy</strong> the generated/downloaded <strong>Python.Runtime.dll</strong> file to your CPython installation folder (e.g. C:\Python24) and the <strong>clr.pyd</strong> file to the DLLs folder of the CPython installation (e.g. C:\Python24\DLLs).</div>
</li>
<li>
<div><em>(Optional)</em> <strong>Copy</strong> the RanorexCore.dll, RanorexNet.dll, RanorexSpy.dll, SHDocVw.dll, and Microsoft.mshtml.dll files from the <em>bin\Net2.0-Pro</em> folder of your Ranorex installation into the DLLs folder of the CPython installation. Moreover, <strong>copy</strong> the RanorexPython.dll from <em>bin\Python2.X-Pro</em> folder (where &#8216;X&#8217; corresponds to the version of your CPython installation) of your Ranorex installation to the same DLLs folder of the CPython installation and rename it to <strong>RanorexPython.pyd</strong>. If you omit this step, these <strong>six files</strong> need to reside in the same directory as the Python scripts you execute.</div>
</li>
</ol>
<ul>
<li><a href="http://www.ranorex.com/blog/wp-content/uploads/2008/04/pythonfornet-20080404.zip" title="Download Python for .NET binaries"><strong>Download Python for .NET (built binaries)</strong></a></li>
<li><a href="http://www.ranorex.com/download.html"><strong>Download Ranorex</strong></a></li>
</ul>
<p><a href="http://www.ranorex.com/download.html"> </a></p>
<p><a href="http://www.ranorex.com/blog/wp-content/uploads/2008/04/pythonfornet-20080404.zip" title="Download Python for .NET binaries"></a></p>
<h3>Scripting</h3>
<p>In order to access Ranorex .NET from your Python scripts, you need to add the following statements at the beginning of each script (in the exact order as shown below):</p>
<pre name="code" class="python">import RanorexPython
import clr
clr.AddReference("RanorexNet")
from Ranorex import *
from Ranorex.Web import *</pre>
<p>You can now access all classes and methods in the Ranorex and RanorexWeb namespaces using the <strong>RanorexNet API</strong>. Consequently, please refer to the <a href="http://www.ranorex.com/Documentation/Net" target="_blank" title="RanorexNet API documentation">RanorexNet API documentation</a> for the available classes and methods. To get an introduction to Ranorex Web automation please read the corresponding chapter in the <a href="http://www.ranorex.com/gui-testing-guide/web-testing.html" target="_blank" title="Web Automation User Guide">Ranorex User Guide</a>.</p>
<p>The following <strong>sample</strong> code opens the Ranorex web site and navigates to the web automation chapter in the Ranorex User Guide. The RanoreXPaths in this sample have been generated by using the RanorexWebSpy.</p>
<pre name="code" class="python">document = WebDocument.OpenDocument("www.ranorex.com", True)                      

#  click on 'User Guide' on main page top menu
Mouse.MoveToWebElement(document.FindSingle("//a[text()='Support']"))
Mouse.ClickWebElement(document.FindSingle("//a[text()='User Guide']"), MouseButtonType.LeftButton, Alignment.CenterLeft)                      

# click on 'Web Testing' in left menu
document.WaitForDocumentLoaded()
Mouse.ClickWebElement(document.FindSingle("//li[@class='NO']/a[text()='Web Testing']"))                      

# set background color of Web Testing header and move mouse to it
document.WaitForDocumentLoaded()
header = document.FindSingle("//h2[text()='Ranorex Web Testing']")
header.SetStyleAttribute("background-color", "red")
Mouse.MoveToWebElement(header)</pre>
<h3>See Also</h3>
<p>For more information on Python for .NET visit the <a href="http://pythonnet.sourceforge.net/" target="_blank" title="Python for .NET Homepage">project homepage</a> and <a href="http://pythonnet.sourceforge.net/readme.html" target="_blank" title="Python for .NET Readme">Readme</a> page.</p>
<p>For the API documentation refer to the <a href="http://www.ranorex.com/Documentation/Net" target="_blank" title="RanorexNet API documentation">RanorexNet API documentation</a>.</p>
<h4>Good luck automating your web sites with Python and Ranorex!</h4>
<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=Web%20Automation%20with%20Python%20for%20.NET&amp;linkurl=http%3A%2F%2Fwww.ranorex.com%2Fblog%2Fweb-automation-with-python-for-net"><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/u4w12GRvIaM" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://www.ranorex.com/blog/web-automation-with-python-for-net/feed</wfw:commentRss>
		<feedburner:origLink>http://www.ranorex.com/blog/web-automation-with-python-for-net</feedburner:origLink></item>
		<item>
		<title>Making 3rd party controls fit for automation</title>
		<link>http://feedproxy.google.com/~r/ranorex-blog/~3/5v-c9PTotr4/making-3rd-party-controls-fit-for-automation</link>
		<comments>http://www.ranorex.com/blog/making-3rd-party-controls-fit-for-automation#comments</comments>
		<pubDate>Fri, 29 Feb 2008 23:01:21 +0000</pubDate>
		<dc:creator>jherget</dc:creator>
		
		<category><![CDATA[Test Automation]]></category>

		<guid isPermaLink="false">http://www.ranorex.com/blog/making-3rd-party-controls-fit-for-automation</guid>
		<description><![CDATA[Automating 3rd party controls can be a hard work. If the control does not support standard mechanisms like windows messages or active accessibility, it cannot be automated without adding some code to the application under test. But how does this trick work?
Using .NET, it’s very simple. You create a new class in the application under [...]]]></description>
			<content:encoded><![CDATA[<p>Automating 3rd party controls can be a hard work. If the control does not support standard mechanisms like windows messages or active accessibility, it cannot be automated without adding some code to the application under test. But how does this trick work?</p>
<p>Using .NET, it’s very simple. You create a new class in the application under test, which inherits from the control class you want to automate and add some properties or methods you need for automation. Be sure that you instantiate the new class in the form designer instead of the old one.</p>
<p>The new version of Ranorex (V1.4 or higher) allows you to get/set properties and call methods of objects from a test application. This technique can be used with all kinds of 3rd party or custom .NET controls.<span id="more-57"></span></p>
<p>Let’s demonstrate this approach with a simple sample.</p>
<h3>Step 1: Creating a simple application under test.</h3>
<h4>Create a new Visual Studio C# project</h4>
<p><a href="http://www.ranorex.com/blog/wp-content/uploads/2008/02/newproject.PNG" title="New Visual Studio C# project dialog"><img src="http://www.ranorex.com/blog/wp-content/uploads/2008/02/newproject.thumbnail.PNG" alt="New Visual Studio C# project dialog" /></a></p>
<h4>Extend the form with a TextBox</h4>
<p>Drag the TextBox in the ToolBox and drop it into the form.<br />
<img src="http://www.ranorex.com/blog/wp-content/uploads/2008/02/form1.PNG" alt="Form1" /><a href="http://www.ranorex.com/blog/wp-content/uploads/2008/02/form1.PNG" title="Form1"><br />
</a></p>
<h4>Add a new class to the project and let it inherit from System.Windows.Forms.TextBox (or from the base class of the control you want to automate)</h4>
<pre name="code" class="c-sharp:nocontrols">class MyTextBox : System.Windows.Forms.TextBox { }</pre>
<h4>Add a new property you want to call from your test application to the class.</h4>
<pre name="code" class="c-sharp">
class MyTextBox : System.Windows.Forms.TextBox
{
    public String MyValue
    {
        get
        {
            return this.Text;
        }
        set
        {
            this.Text = value;
        }
    }
}</pre>
<h4>Change the class name from TextBox to MyTextBox in the Form.Designer.cs file</h4>
<p>(Instantiate the new class instead of the old one)</p>
<pre name="code" class="c-sharp">
private MyTextBox textBox1;</pre>
<pre name="code" class="c-sharp">
private void InitializeComponent()
{
    this.textBox1 = new MyTextBox();
    ...
}</pre>
<h4>Compile and start the application under test.</h4>
<h3>Step 2: Checking the properties with RanorexSpyPro.</h3>
<p>Start RanorexSpyPro and select the textbox of the form with the finder tool .<br />
You should see the new property “MyValue” in the RanorexSpyPro application.<br />
<a href="http://www.ranorex.com/blog/wp-content/uploads/2008/02/spypro.PNG" title="Dragging RanorexSpyPro to TextBox"><img src="http://www.ranorex.com/blog/wp-content/uploads/2008/02/spypro.thumbnail.PNG" alt="Dragging RanorexSpyPro to TextBox" /></a></p>
<h3>Step 3: Automating the control in a test application.</h3>
<p>Find the form and set the property MyValue of the TextBox as follows:</p>
<pre name="code" class="c-sharp">
Form form = Application.FindFormTitle("Form1");
TextBox textBox = form.FindTextBox("textBox1");
for (int i = 0; i &lt; 20; i++)
{
    textBox.SetPropertyValue("MyValue", i.ToString());
    Application.Sleep(1000);  

}</pre>
<h3>Step 4: Calling a method of the control.</h3>
<p>You can also extend your control class “MyTextBox” with methods and call them from the test application:</p>
<pre name="code" class="c-sharp">
class MyTextBox : System.Windows.Forms.TextBox
{
    public void SetValue(String text)
    {
         this.Text = text;  

    }
}</pre>
<p>Use InvokeMethod(“MethodName”, params, …) for calling the method from your test script:</p>
<pre name="code" class="c-sharp:nocontrols">textBox.InvokeMethod("SetValue", “22”);</pre>
<p>This article describes a simple but general way for automating 3rd party controls.<br />
Developers and testers can work together to make am application fit for automation.<br />
We have tested this approach with several kind of 3rd party controls (Infragistics, DevExpress, DevComponents,…).</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=Making%203rd%20party%20controls%20fit%20for%20automation&amp;linkurl=http%3A%2F%2Fwww.ranorex.com%2Fblog%2Fmaking-3rd-party-controls-fit-for-automation"><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/5v-c9PTotr4" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://www.ranorex.com/blog/making-3rd-party-controls-fit-for-automation/feed</wfw:commentRss>
		<feedburner:origLink>http://www.ranorex.com/blog/making-3rd-party-controls-fit-for-automation</feedburner:origLink></item>
		<item>
		<title>“Design for Testability” - Smooth 3rd party control automation</title>
		<link>http://feedproxy.google.com/~r/ranorex-blog/~3/EW4ZELhWwvk/design-for-testability-smooth-3rd-party-control-automation</link>
		<comments>http://www.ranorex.com/blog/design-for-testability-smooth-3rd-party-control-automation#comments</comments>
		<pubDate>Tue, 26 Feb 2008 08:08:27 +0000</pubDate>
		<dc:creator>cpreschern</dc:creator>
		
		<category><![CDATA[Test Automation]]></category>

		<guid isPermaLink="false">http://www.ranorex.com/blog/design-for-testability-smooth-3rd-party-control-automation</guid>
		<description><![CDATA[GUI automation always depends on the type of used controls and technologies within applications. An increasing use of 3rd party controls in applications also makes GUI automation more and more addicted to identification information provided by the 3rd party control. In most cases providers of 3rd party controls support enough information to get a control&#8217;s [...]]]></description>
			<content:encoded><![CDATA[<p>GUI automation always depends on the type of used controls and technologies within applications. An increasing use of 3rd party controls in applications also makes GUI automation more and more addicted to identification information provided by the 3rd party control. In most cases providers of 3rd party controls support enough information to get a control&#8217;s elements identified and automated. Nevertheless, there are  sometimes more complex ways required to simulate user actions. That type of test automation code is not that &#8220;readable&#8221; as we would like to have.</p>
<p>Ranorex V1.4 supports accessing properties and methods of .NET derived controls. Following &#8220;Design for Testability&#8221; sample explains the way of making testing more comfortable. By using the 3rd party UltraTree control from Infragistics the example describes how to access user defined methods for test automation.<span id="more-45"></span></p>
<p><a href="http://www.ranorex.com/blog/wp-content/uploads/2008/02/invoking.png" title="Invoke overview"><img src="http://www.ranorex.com/blog/wp-content/uploads/2008/02/invoking.thumbnail.png" alt="Invoke overview" /></a><a href="http://www.ranorex.com/blog/wp-content/uploads/2008/02/designft.png" title="designft.png"> </a></p>
<p>In fact there should only be 3 steps required to expand or select a specific node within the tree view control.</p>
<ol>
<li>Searching for the application</li>
<li>Finding tree view control within form</li>
<li>Invoking method with simple string path <strong>&#8220;Root/Child_02/&#8221;</strong></li>
</ol>
<pre name="code" class="c-sharp:nocontrols">Form form = Application.FindFormTitle("Design for Testability",
				           SearchMatchMode.MatchFromStart);
Control tree = form.FindControlName("ultraTree1");
tree.InvokeMethod("ExpandNode", null, "Root/Child_02/");</pre>
<p>To invoke a method called &#8220;ExpandNode&#8221; we only have to provide this method within a class derived from the Infragistics UltraTreeView control:</p>
<pre name="code" class="c-sharp:nocontrols">/// Derived class from Infragistics UltraTree control
public class MyTreeView : Infragistics.Win.UltraWinTree.UltraTree
{
    public MyTreeView()
    {}
    /// This method steps through each sub node of
    /// the tree view control.
    public void ExpandNode(UltraTreeNode node, string path)
    {
        string[] nodeList = path.Split('/');
        UltraTreeNode currentNode = null;
        TreeNodesCollection treeNodes = null;
        // Start from controls node list if null
        if (node == null)
            treeNodes = this.Nodes;
        else
            treeNodes = node.Nodes;
        foreach (UltraTreeNode n in treeNodes)
        {
            if (n.Text == nodeList[0])
            {
                currentNode = n;
                // Expand node
                n.Toggle();
                // Select node
                n.Selected = true;
                break;
            }
        }
        if (currentNode == null)
            return;
        // start expanding for sub nodes
        ExpandNode(currentNode,path.Remove(0,currentNode.Text.Length+1));
    }
}</pre>
<p>Invoking methods or properties can be a powerful mechanism to simplify automation of 3rd party controls, if developers consider testability during their software design and implementation process.</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=%26%238220%3BDesign%20for%20Testability%26%238221%3B%20-%20Smooth%203rd%20party%20control%20automation&amp;linkurl=http%3A%2F%2Fwww.ranorex.com%2Fblog%2Fdesign-for-testability-smooth-3rd-party-control-automation"><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/EW4ZELhWwvk" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://www.ranorex.com/blog/design-for-testability-smooth-3rd-party-control-automation/feed</wfw:commentRss>
		<feedburner:origLink>http://www.ranorex.com/blog/design-for-testability-smooth-3rd-party-control-automation</feedburner:origLink></item>
	</channel>
</rss>
