# Ranorex

A functional test is applied in the context of a test case in aqua. Therefore, the user has to create a new test case first. By selecting the *Automation* tab, the *Step Designer* switches to test automation. Now, create the necessary test steps in the *Step Designer*. An automated test may consist of multiple test steps and may contain multiple automation scripts, which are executed in the order of the test step index. Test scripts that were previously created, may be reused by using the *Script Library*. Initially, a single test step is sufficient.&#x20;

Select your single test step by clicking into the white area in the column *Automation*. To create a Ranorex-Test script, click on *New Script* and then select *Ranorex*.&#x20;

<figure><img src="http://aquawiki.andagon.com/pictures/drex_ranorex_rich_client_custom.png" alt=""><figcaption></figcaption></figure>

A test script template is now created and can be edited using the *External Editor - Ranorex Studio. Ranorex Studio*, for example, allows you to create a new automation by recording user interactions.

&#x20;&#x20;

<figure><img src="http://aquawiki.andagon.com/pictures/drex_ranorex_rich_client_custom_2.png" alt=""><figcaption></figcaption></figure>

{% hint style="warning" %}
NOTE:   <img src="http://aquawiki.andagon.com/pictures/drex_ranorex_rich_client_custom_3.png" alt="" data-size="original">

If you have not already worked with the automation tool, aqua will point out that the path to Ranorex needs to be configured. The corresponding menu is offered to you by the system. In this case click on "*Open Configuration*". Then select the path to the *Ranorex application*.
{% endhint %}

&#x20;&#x20;

Test cases must be saved before they can be transferred. If you have saved the test case, you can open Ranorex with the "*Continue*" button.&#x20;

<figure><img src="http://aquawiki.andagon.com/pictures/drex_ranorex_rich_client_custom_4.png" alt=""><figcaption></figcaption></figure>

By clicking on *External Editor*, a blank project will be opened in *Ranorex*. Test cases can be recorded and edited here. aqua is on hold, until the external editor is closed. If the automation is completed and the editor is closed, aqua offers the option of saving the new test case.&#x20;

By saving the new test case, it will be automatically added to the database. If you don’t want to accept the changes, do not save the test case. To run an automated test, the test case must be executed in the same way as the manual tests. Open the test case and click on the *Run* button. If this is an automated test, and if agents are available in the network, then a selection of possible test systems will be displayed. &#x20;

<figure><img src="http://aquawiki.andagon.com/pictures/drex_ranorex_rich_client_custom_5.png" alt=""><figcaption></figcaption></figure>

The results will be automatically transferred to aqua and then displayed to the user.

## **Parameterize** <a href="#parameterize" id="parameterize"></a>

You can parameterize your Ranorex test cases by using aqua parameters. To do so, open the Variable Manager and insert some variables. &#x20;

<figure><img src="http://aquawiki.andagon.com/pictures/drex_parameterize_custom.png" alt=""><figcaption></figcaption></figure>

Go into Ranorex and add a new Action as shown below:&#x20;

<figure><img src="http://aquawiki.andagon.com/pictures/drex_parameterize_custom_2.png" alt=""><figcaption></figcaption></figure>

Now, you can add your variable to URL by clicking on  ![](http://aquawiki.andagon.com/pictures/drex_parameterize_custom_3.png)  in the URL and selecting *As new variable*. A window will open where you can enter the name of the variable. This must correspond to the spelling of the variable name in aqua (in our case "URL").  &#x20;

<figure><img src="http://aquawiki.andagon.com/pictures/drex_parameterize_custom_4.png" alt=""><figcaption></figcaption></figure>

Your test case is now parameterized. The result is displayed below.&#x20;

<figure><img src="http://aquawiki.andagon.com/pictures/drex_parameterize_custom_5.png" alt=""><figcaption></figcaption></figure>

You can also use the "*Variables*" button to add new variables in Ranorex and use them within the actions. To replace the variables with the aqua variables, the naming must always be the same in both tools.You can also use variables in the Ranorex repository in the same way (e.g. to open certain windows or to control buttons on an application depending on the variables). These variables can be replaced by aqua variables as well, if the naming is the same.&#x20;

Below is an example for the use of variables at different places: &#x20;

<figure><img src="http://aquawiki.andagon.com/pictures/drex_parameterize_custom_6.png" alt=""><figcaption></figcaption></figure>

<figure><img src="http://aquawiki.andagon.com/pictures/drex_parameterize_custom_7.png" alt=""><figcaption></figcaption></figure>

## **Configuring the Agent** <a href="#configuring_the_agent" id="configuring_the_agent"></a>

Extract the RanorexAgent-\*.zip and open aquaAgentRanorexGui.exe.config.&#x20;

Here you have to set the Agent Code and the aquaServiceUrl. In the following, you will find an example:

```xml
<?xml version="1.0"?>
<configuration>
     <appSettings>
          <add key="agentCode" value="pvq6wrb70huknv47ji39"/>
          <add key="aquaServiceUrl" value="http://youraquaserver/aquaAPI/aquaagentwebservice.asmx"/>
          <add key="keepAliveSendingFrequencyMs" value="30000"/>
          <add key="compilerTimeoutMs" value="60000"/>
          <add key="tempDirectory" value="temp"/>
          <add key="ranorexVersion" value="7"/>
          <add key="proxyHost" value=""/>
          <add key="proxyPort" value=""/>
          <add key="proxyUsername" value=""/>
          <add key="proxyPassword" value=""/>
          <add key="maxGUILogEntries" value="30"/>
     </appSettings>
     <startup>
     <supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.0"/></startup>
</configuration>
```

## **Working with Ranorex** <a href="#working_with_ranorex" id="working_with_ranorex"></a>

Here are some best practice tips for working with Ranorex and aqua. This page will show how to use one repository in several test cases. First, create a new test case in aqua and add a test step with a Ranorex script. This script will contain the repository.

<figure><img src="http://aquawiki.andagon.com/pictures/drex_working_with_ranorex_custom.png" alt=""><figcaption></figcaption></figure>

Create a namespace to identify the repository.&#x20;

<figure><img src="http://aquawiki.andagon.com/pictures/drex_working_with_ranorex_custom_2.png" alt=""><figcaption></figcaption></figure>

Open Ranorex as external editor and create a new repository in Ranorex.

<figure><img src="http://aquawiki.andagon.com/pictures/drex_working_with_ranorex_custom_3.png" alt=""><figcaption></figcaption></figure>

Save the repository in the module folder.

<figure><img src="http://aquawiki.andagon.com/pictures/drex_working_with_ranorex_custom_4.png" alt=""><figcaption></figcaption></figure>

Take note of the folder where the repository is saved. The path should look like this:\<some path>\aqua\_Automation\TCxxxxxx\\\_001\_CommonRepository\CommonRepository.rxrepHover over the repository to see the path (see screenshot below).

<figure><img src="http://aquawiki.andagon.com/pictures/drex_working_with_ranorex_custom_5.png" alt=""><figcaption></figcaption></figure>

This repository can be used in another test step as follows: first add a new test step in aqua. Now open *Ranorex* with the *External Editor* button.&#x20;

In Ranorex choose Open from Disk to select the repository created earlier.

<figure><img src="http://aquawiki.andagon.com/pictures/drex_working_with_ranorex_custom_6.png" alt=""><figcaption></figcaption></figure>

Browse to the path where the repository file was saved.

<figure><img src="http://aquawiki.andagon.com/pictures/drex_working_with_ranorex_custom_7.png" alt=""><figcaption></figcaption></figure>

Now we want to also use our repository in another test case. To do so, we add the script containing the repository to the aqua script library.

<figure><img src="http://aquawiki.andagon.com/pictures/drex_working_with_ranorex_custom_8.png" alt=""><figcaption></figcaption></figure>

Now, we create a new test case and open the script library (*Show Library* button). Then, just drag the script to the white area in the test step.

<figure><img src="http://aquawiki.andagon.com/pictures/drex_working_with_ranorex_custom_9.png" alt=""><figcaption></figcaption></figure>

Add another step with a *Ranorex* script to the new test case and open this step in *Ranorex*. Use the repository by selecting *Open from Disk* and browsing to the folder where the repository is stored (note: This is the folder of the first test case).

<figure><img src="http://aquawiki.andagon.com/pictures/drex_working_with_ranorex_custom_10.png" alt=""><figcaption></figcaption></figure>

Ranorex will ask you to choose a reference for the repository. *Choose Link* repository to project. The repository is now shared between the two test cases. Any changes you make to the repository within this test case will be reflected in the other test case.

<figure><img src="http://aquawiki.andagon.com/pictures/drex_working_with_ranorex_custom_11.png" alt=""><figcaption></figcaption></figure>

In this way, one repository can be used in all your test cases being tested in the same system under test.&#x20;

{% hint style="info" %}
Note: If more than one test case referencing the repository is opened in aqua, it will be write-protected.
{% endhint %}

## **Troubleshooting** <a href="#troubleshooting" id="troubleshooting"></a>

### **Troubleshooting with Administrator Rights** <a href="#troubleshooting_with_administrator_rights" id="troubleshooting_with_administrator_rights"></a>

Ranorex starts with elevated rights per default. If you do not use aqua with elevated rights, this might lead to unexpected behaviour. To avoid this, open the settings of your ranorex studio and deactivate the following option. &#x20;

<figure><img src="http://aquawiki.andagon.com/pictures/drex_troubleshooting_1_custom.png" alt=""><figcaption></figcaption></figure>

### **Troubleshooting with Environment** <a href="#troubleshooting_with_environment" id="troubleshooting_with_environment"></a>

Build started 12.04.2016 09:27:08.

Project "C:\Users\\\*\Desktop\aquaRanorexAgent-16.1.2.0\aquaRanorexAgent\temp\PEE42\aquaProject.csproj" on node 1 (Clean;Build target(s)).C:\windows\Microsoft.NET\Framework\v4.0.30319\Microsoft.Common.targets(609,5): error : The OutputPath property is not set for project 'aquaProject.csproj'. &#x20;

Please check to make sure that you have specified a valid combination of Configuration and Platform for this project.  Configuration='Debug'  Platform='BPC'.  You may be seeing this message because you are trying to build a project without a solution file, and have specified a non-default Configuration or Platform that doesn't exist for this project.&#x20;

\[C:\Users\\\*\Desktop\aquaRanorexAgent-16.1.2.0\aquaRanorexAgent\temp\PEE42\aquaProject.csproj]Done Building Project "C:\Users\\\*\Desktop\aquaRanorexAgent-16.1.2.0\aquaRanorexAgent\temp\PEE42\aquaProject.csproj" (Clean;Build target(s)) -- FAILED.&#x20;

Build FAILED.&#x20;

"C:\Users\\\*\Desktop\aquaRanorexAgent-16.1.2.0\aquaRanorexAgent\temp\PEE42\aquaProject.csproj" (Clean;Build target) (1) ->(\_CheckForInvalidConfigurationAndPlatform target) ->  C:\windows\Microsoft.NET\Framework\v4.0.30319\Microsoft.Common.targets(609,5): error :&#x20;

The OutputPath property is not set for project 'aquaProject.csproj'.  Please check to make sure that you have specified a valid combination of Configuration and Platform for this project.  Configuration='Debug'  Platform='BPC'.  You may be seeing this message because you are trying to build a project without a solution file, and have specified a non-default Configuration or Platform that doesn't exist for this project. \[C:\Users\\\*\Desktop\aquaRanorexAgent-16.1.2.0\aquaRanorexAgent\temp\PEE42\aquaProject.csproj]&#x20;

<mark style="color:green;">**Solution**</mark>

Delete platform environment variable BPC on the windows os, where agent is running. [http://stackoverflow.com/questions/2507856/why-is-my-platform-environment-variable-defined-as-bnb](https://stackoverflow.com/questions/2507856/why-is-my-platform-environment-variable-defined-as-bnb) \
&#x20;<br>

## **Referencing External Assemblies (.dll-Files)** <a href="#referencing_external_assemblies___dll_files" id="referencing_external_assemblies___dll_files"></a>

The csproj-file for editing and execution of test steps is built new every time according to the given test steps, to ensure the re-usability (keyword: script library) of test steps by aqua. Since several test steps are edited at once, it is hard to identify which reference belongs to which test step.&#x20;

To solve that problem, please proceed as follows:&#x20;

1. &#x20;Localize the assembly in your file system, path will be like:

C:\Program Files (x86)\Microsoft Visual Studio 12.0\Visual Studio Tools for Office\PIA\Office15\Microsoft.Office.Interop.Word.dll)&#x20;

2. Open the affected Ranorex test case in aqua&#x20;
3. Copy the .dll-files into the test step

<figure><img src="http://aquawiki.andagon.com/pictures/drex_referencing_external_assemblies_dll_files_custom.png" alt=""><figcaption></figcaption></figure>

4. &#x20;Add the reference to the local .dll-file in the test step, using the 'Browse...' button &#x20;

<figure><img src="http://aquawiki.andagon.com/pictures/drex_referencing_external_assemblies_dll_files_custom_2.png" alt=""><figcaption></figcaption></figure>

5. Save and close the Ranorex project
6. Save the test case in aqua&#x20;

When saving the test case in aqua the reference to the local assembly is automatically recognized and the assembly is saved in aqua.&#x20;

To simplify such references, you can use so-called utility scripts in script items. These are additional script items which can be added to scripts via the '*Usage*' button. Alternatively, place the reference script in the first test step.&#x20;

<figure><img src="http://aquawiki.andagon.com/pictures/drex_referencing_external_assemblies_dll_files_custom_3.png" alt=""><figcaption></figcaption></figure>

The helper script for the references can contain more than one reference. Thus, you can build a whole library of references which are referenced multiple times. You do not need to create or link multiple scripts for each reference.&#x20;

## **Migrating a project** <a href="#migrating_a_project" id="migrating_a_project"></a>

This manual describes how to migrate test cases which are automated with Ranorex from one aqua Server to another. &#x20;

1. Create the same scripts (Same Name and Namespace!) on your target system, like on your source system.
2. Create dependencies between the scripts. This makes sense, especially to reuse the repository and the user code module.

&#x20; &#x20;

<figure><img src="http://aquawiki.andagon.com/pictures/drex_migrating_a_project_custom.png" alt=""><figcaption></figcaption></figure>

<figure><img src="http://aquawiki.andagon.com/pictures/drex_migrating_a_project_custom_2.png" alt=""><figcaption></figcaption></figure>

3. &#x20;Create a test case which contains all scripts on both aqua environments.  &#x20;

<figure><img src="http://aquawiki.andagon.com/pictures/drex_migrating_a_project_custom_3.png" alt=""><figcaption></figcaption></figure>

4. Export the variables of the original test cases via the variable manager on the source system
5. Open the external editor (Ranorex) on your source system and open the folder, which contains the solution (Right-click on solution --> Open folder).
6. Copy this folder and delete the Main.cs file in all sub folders which contain scripts.\
   &#x20;&#x20;

   <figure><img src="http://aquawiki.andagon.com/pictures/drex_migrating_a_project_custom_4.png" alt=""><figcaption></figcaption></figure>
7. Open the test case you created in step 3 on your target system.
8. Open the folder which contains the solution and copy the folder you copied in step 6 to this destination (without Main.cs files!).
9. If the correct recordings are not found, show them via the button *Show all* files and add them to the project (Right click --> Include in Project).&#x20;

<figure><img src="http://aquawiki.andagon.com/pictures/drex_migrating_a_project_custom_5.png" alt=""><figcaption></figcaption></figure>

10. Edit the following to lines in the Main.cs files, so that the correct Recordings are called (yellow marked)  &#x20;

<figure><img src="http://aquawiki.andagon.com/pictures/drex_migrating_a_project_custom_6.png" alt=""><figcaption></figcaption></figure>

11. Compile the project in Ranorex. Close Ranorex and save the test case in aqua.
12. Create all test cases with the scripts in your target system and import the variables you exported in step 4 via variable manager.<br>
