Automation of Desktop Application using Robot Framework

Robot Framework is traditionally intended for Web Automation However desktop automation can be achieved with Robot Framework AutoItLibrary. AutoItLibrary comes with a tool to spy desktop application elements.

A Typical Client-Server Architecture:

In a client-server architecture, the relationship of the computers are separated into two roles:

  • The client, which requests specific services or resources
  • The server, which is dedicated to fulfilling requests by responding (or attempting to respond) with requested services or resources


An easy-to-understand example of a client-server relationship is seen when using the Internet. When using an Internet browser to access a Web site, the client would be the computer running the browser software, which would request a Web page from a Web server. The Web server receives this request and then responds to it by sending the Web page to the client computer.

In VoIP, the same relationship can be seen when a client sends a request to register with a Registrar server, or makes a request to a Proxy Server or Redirect Server that allows it to connect with another user agent. In all these cases, the client’s role is to request services and resources, and the server’s role is to listen to the network and await requests than it can process or pass onto other servers.

The servers that are used on a network acquire their abilities to service requests by the programs installed on it. Because a server may run a number of services or have multiple server applications installed on it, a computer dedicated to the role of being a server may provide several functions on a network. For example, a Web server might also act as an e-mail server.

In the same way, SIP servers also may provide different services. A Registrar can register clients and also run the location service that allows clients and other servers to locate other users who have registered on the network. In this way, a single server may provide diverse functionality to a network that would otherwise be unavailable.

Another important function of the server is that, unlike clients that may be disconnected from the Internet or shutdown on a network when the person using it is done, a server is generally active and awaiting client requests. Problems and maintenance aside, a dedicated server is up and running, so that it is accessible. The IP address of the server generally doesn’t change, meaning that clients can always find it on a network, making it important for such functions as finding other computers on the network.

GitHub with Robot Framework Flight Application

Installation of AutoIt Library in Robot Framework

AutoItLibrary is a Robot Framework keyword library wrapper for the freeware AutoIt tool using AutoIt ’s AutoItX.dll COM object. The AutoItLibrary class provides a proxy for the AutoIt keywords callable on the AutoIt COM object and provides additional high-level keywords implemented as methods in this class.

To install this AutoIt library into our system, we need two prerequisites :

  • We need to run the command prompt as Administrator
  • We need to set the HOMEDRIVE=C:

Open the start menu in the system and type cmd, right-click on the command prompt icon and press enter, the command prompt will open as an administrator.


The command prompt is now opened as administrator, now set HOMEDRIVE=C: and press enter


Now, install the Autoit library by using the command pip install robotframework-autoitlibrary , copy and paste the above command into the command prompt and press enter, If AutoIt library has successfully installed, then we will see the below message


The Autoit library will be present inside the Extension folder in the C drive. The spy will be present inside the Autoit library. The spy is used to identify the element on desktop application.


Working with Robot Framework Jenkins

Invoke Desktop Application in Robot Framework

The first step of the desktop application is to invoke the application, and the main keyword required to open a desktop application is Run. The required parameters are Filename and working directory.

If we are invoking any windows applications like Desktop, Notepad, these are the applications which are by default installed by windows and hence the default working directory is C:Windowssystem32>

Now go to ride editor and create a new test suite as PracticeCalculator and then create a new test case as Opencalculator . The next step is to import the Autoit library into the new test suite.


Now, go to the test case and enter the keyword run and the filename calc.exe as a parameter


Now, select the test case and run, once the test case starts executing, the calculator will be open on the window.


Web Elements of Robot Framework

Relevant Keywords of AutoItLibrary in Robot Framework

The AutoIt Library has Lot of keywords, let us discuss some of the important keywords one by one

WinWaitActive : This keyword waits for the application to be present, and it has a by default timeout of -1 sec.

The arguments required are: application title

To find the application title of the calculator, Open calculator, and AutoIt spy simultaneously and select the finder tool and click on the calculator tab, it will display the title of the calculator in the AutoIt spy.


Open the ride editor and enter the keyword as win wait active and the argument as the calculator


Now, select the test case and run, once the test case starts executing the calculator application will be opened on the window

Control-Click: This keyword is the most important keyword in the AutoIt library, if you want to click on any particular element/button in the calculator, this keyword is very useful in this case.

Arguments: [ strTitle= | strText= | strControl= | strButton=LEFT | nNumClicks=1 | nX=-2147483647 | nY=-2147483647 ]

To perform actions in the calculator we required strTitle and strControl,

To find the strControl of the calculator: open the calculator and the AutoIt spy, select the finder tool and click on any number in the calculator so that it will show the classnameNN as ApplicationFrameInputSinkWindow1

Goto the tets case and enter the keyword control-click and the parameter as ApplicationFrameInputSinkWindow1 and select the test case and run.


WinClose: This keyword is used to close the application

Arguments:[ strTitle= | strText= ]

Go to the Ride editor and enter the keyword as win close and the parameter as a calculator


The ControlSetText, ControlSend, and Send are used to send the text to the edit area, let us create a new test case and use these keywords to send the text by using notepad.

Open the ride editor and create a new test case as OpenNotepad

ControlSetText: The ControlSetText is used to send the text, the arguments required are

[ strTitle= | strText= | strControl= | strControlText= ]

We need to find the Title of the notepad and the control, open the notepad and the spy and move the spy on the notepad header, you will find the title as Untitled and the control is nothing but a class, which is an Edit as shown in the below image


Now, go to the ride editor and enter the keyword as ControlSetTest and the parameters, as shown in the below image.


Now, select the test case and run. The note will open, and it will contain a text. This is my automation desktop.


ControlSend: The arguments required to send the test to the notepad are

[ strTitle= | strText= | strControl= | strSendText= | nMode=0 ]

Enter the keyword and the parameters in the test case as shown below


Once you run the test case, you will see the texts in the notepad as shown in the below image


Send : The arguments required to send the text to notepad are

[ strSendText= | nMode=0 ]

The text sent from ControlSet will be displayed first and then send keyword text will be displayed, and the controlsend text will be displayed at last.


Once you run the test case, the text will be displayed in the notepad as shown below


ProcessClose : The ProcessClose keyword is used to close the process of the ride editor.

The arguments required to close the process of the ride editor is:

[ strProcess= ]

Enter the keyword ProcessClose and parameter(name of the application:notepad.exe) as shown below


As soon as you run the test case, the notepad will be closed.

User Defined Keywords Using Python in Robot Framework

Working with Notepad and Calculator in Robot Framework

So far, we learned all the important keywords of AutoIt Library, let us work on the calculator application to add two numbers and display the result. In the notepad application, we are going to insert some text, as shown below.

Create a new test case as Practice and enter the required keywords to implement the calculator and the notepad applications.


The continued part of the test case to implement notepad is as follow


Select the test case and run, once the test case starts executing, the calculator will open, and it will add 5+7=12 and then notepad will also open, and it will display a text as This will be in beginning this is inbetweenThis is my first text using controlset


Web Services Automation in Robot Framework

End to End Desktop Automation with Robotframework

The end to end desktop application include the following steps:

  • Overview of the application
  • Manual Testcase flow
  • Execution of test case manually
  • Automating the manual flow

Now I will show you the application which is very helpful for beginners to practice on it, the name of the application is TrainingOrdersystem.

Once you successfully installed the TrainingOrderSystem(most probably this application will be saved in the C drive), go to the file location and click on the .exe file, a small dialog box(Sign in) will appear on your system window as shown below


Enter the Staff number as bp and the password as the password and click on Sign InOnce you SignIn, the Options dialog box will appear as shown below


As this application is a simple exe and does not require any database so that we can use this to practice easily, The option contains the following:

  • Add new order
  • View existing order
  • Quite

I am selecting the first option, Add new order and click on Go, the new order page will be displayed as shown below


The NewOrder dialog box contains Product code, Number required, Unit price, Cost center, and Total price, as soon as we enter all this information and click on submit the order, we will get a confirmation number. This confirmation number is used to retrieve the order. We have to do this manually.

The following application demonstrates the automation of Add New Order in the Training Order System

Test Case Name Test Steps Description Expected Result
TC01_Add_New_Order Step1 Launch TrsiningOrderSytem by double-clicking on the Executable Training Order System will be launched
Step2 Enter Staff Number-bp and Password-password. Click on SignIn The Options screen will be displayed containing the options-1. Add New Order,2. View Existing Oder, 3.Quite
Step3 Enter Option number 1 and click on Go The New Order Entry screen Will be displayed

Enter Product Code-ABC-125,Number Required-3, Unit Price-2.16, Cost Center-101. Click Submit

The Following Message will be displayed-Please Take a Note of your order reference: <Number>

Let us manually execute the above test case, adding a new order. Our first step is to open the executable file by clicking on the TrainingOrderSystem.exe file and verify that the application is opened.


The second step is to enter the staff number as bp and the password as a password and click on Sign In


Once you click on the Sign In the screen will be displayed containing the options Add New Oder, Containing Existing Order, and Quite, as shown below.


Enter the first option number and click on, Go and the new order page will be displayed. verify whether the page contains the following options.


Now, enter the product code, the number required, Unit price, Cost center and the total price is displayed, then click on Submit.


Once you click on the Submit Order button, the order confirmation message will be displayed as shown below with the reference number.


Note the reference number and click on continue. Go back and select the View existing order and enter the reference number and click on RetrieveOrder and hence the order will be retrieved as shown below


This application is not connected to any database; thus, it is a dummy application, and the order details are not always correct. But this application is useful for practitioners.

We are going to divide the test case into four significant keywords, such as Login Functionality, Enter Option Functionality, New Order Functionality, and Verify Confirmation Functionality.

Now let us Automate the above test case as shown below

Go to the ride editor and create a new test suite as CreateOrder under the new Folder named as DesktopApplication. Import the SeleniumLibrary and AutoIt Library into the new project and a new test case. Create new Commonusedkeyword Resource file and import the Selenium and AutoIt Library.

Open the TrainingOrdersystem application and the AutoIt spy to find the properties of Username and Password and then the Sign In button.




Create our first keyword Login inside the CommonUsedKeyword resource file, here, the first keyword used is run, to run the application and the parameter required is the location of the TrainingOrdersystem

To Find the Location: Go to the file location and right-click and select the properties option, you will find the location of the file, copy and paste it in the Login keyword and convert backward slashes into forwarding slashes.


The Login keyword with all the credentials has been created as shown below


Go to CreateOrder test suite and import the CommonUsedKeyword resource file and then create a new test case as TC01_CreateOrder



Now, select the test case and run, once the test case starts executing, the editor will open the TrainingOrdersystem application and enters the username and password and click on the sign-in button.

The Next step is to create Enter Option Functionality, Open the TrainingOrderSystem application and spy, Login to the application by using valid user name and password and move the spy on the option number and you will get the Advance mode as [NAME:txtOption].


Get the property of the button Go by moving spy on it


Go to ride editor and create another keyword called EnterOption and add credentials to it


Now enter this new keyword into a test case and run


Once you run the test case, the ride editor will sign in to the application and enter the option one and displays the new order details, as shown below.


The next step is to create our third keyword New Order Functionality, open a new order page, and move to find the properties of all the options which are present in the original order page.

Product code:[NAME:txtProductCode]

Number required: [NAME:txtNumberReq]

Unit Price: [NAME:txtUnitprice]

Cost Centre: [NAME:txtCostCentre]

Submit Order:[NAME: Button1]

Go to ride editor and create another keyword called InputOder and enter the credentials, as shown below.


Now, enter the Input order keyword in the test case and run the test case.


Once you run the test case, the editor will sign in to the application and enter the option and then input the order details.


The next steps are to create a Last keyword for the test case that is nothing but Order confirmation. Open the spy and move on the message which is displayed on the order confirmation page, and you will get the advanced mode property. this time we are using Classname, instead of advanced mode. Order confirmation:

Go to the ride editor and create a new test case VerifyOder Confirmation


Now, enter the keyword into the test case and run


Select the test case and run, once the test case starts executing the robot framework will open the application and sign in with valid credentials and then enters the option, inputs new order details and then verifies the order confirmation. This is your end to end automation test case.


And the report is as below.


Introduction & Installation of Robot Framework

Problem Faced:

Whenever I used the keyword Win Wait Active, I use to get an error as a test case has failed to active within 60 min, hence in most of the test cases I have not used win wait actively keyword.

Comment / Suggestion Section
Point our Mistakes and Post Your Suggestions

Subscribe to See Videos

Subscribe to my Youtube channel for new videos : Subscribe Now