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.
In a client-server architecture, the relationship of the computers are separated into two roles:
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 that 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.
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 :
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 first step of the desktop application is to invoke the application and the main keyword required to open 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
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.
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, O
Open the ride editor and enter the keyword as
win wait active and the argument as the
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 it will show the classnameNN as
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
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
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.
[ strTitle= | strText= | strControl= | strSendText= | nMode=0 ]
[ strProcess= ]
[ strRun= | strDir= | nShowFlags=1 ]
[ strTitle= | strText= | nPart=1 ]
[ strSendText= | nMode=0 ]