Visual Studio integration
Microsoft Visual Studio is an integrated development environment (IDE) by Microsoft. It is used to develop computer programs for Microsoft Windows, as well as websites, web apps, web services and mobile apps. This chapter introduces and explains how to use Ranorex Studio in a simple Visual Studio C# console application. It shows how to create a new Visual Studio C# console application and how to start and automate the Windows Calculator.
The sample in this chapter works with with Microsoft Visual Studio 2005 and later.
Create a new Visual Studio project
Start Microsoft Visual Studio.
Go to File > New Project.
Select .NET Framework 4.5.2 or higher and choose your programming language. We will be using Visual C# in this example.
Select Console Application from the list.
Enter a name for the project and click OK.
Creating a new Console Application with Microsoft Visual Studio
Add Ranorex core assemblies as references
In the project’s Solution Explorer, right click the References folder and select Add Reference… .
Select Browse in the menu on the left.
Browse to the Bin folder of your Ranorex installation (default: C:Program Files (x86)Ranorex Bin).
Add Ranorex.Bootstrapper, Ranorex.Common, Ranorex.Core, Ranorex.Core.Resolver, and all Ranorex.Plugin assemblies.
Write some Ranorex automation code
It is crucial that the Ranorex.Core.Resolver assembly is initialized before any other Ranorex core functionalities are used. It is the assembly that finds all other Ranorex assemblies at runtime.
To do so, add the following code to the Main routine of the class Program. Your test automation code goes in the Run section. In our example, we perform a simple calculation in the Windows calculator. Once you’ve added the code, press F5 to build and start your project.
For reference purposes, this is what the code looked like for Ranorex versions before 8.0.