AutoIt: An Open Source Software Testing Tool for Windows

0
41219

autoit-softwar-testing-illustration

The official website of AutoIt defines it as a freeware BASIC-like scripting language designed for automating the Windows GUI and general scripting. AutoIt runs on all versions of Windows. This third-generation programming language can be used to automate any specific task by simply writing a few lines of script.

It can hardly be denied that many of us are becoming a bit lazy about performing tasks manually, and try our best to make the system do all repetitive tasks to the highest extent possible. If you are running out of time for completing a specific task on some online application within a deadline, you will rely on the system to do so with accuracy, reducing the chance of last minute errors that might creep in if the task is done manually. That is why automation is so important in the current technology-driven era.
Automation testing gauges the quality of software with other tools or software code, which compare the actual outcomes with the predicted outcomes. The entire test suite is run without any manual intervention. The tool itself generates the final outcome of the testing performed in the form of a test report, which features the expected and actual outcomes. The specific method or process that is used to implement the automated process is called a test automation framework. The tool can even help us log defects if required. Automation testing is one of the most happening areas of the software quality assurance industry, as most organisations prefer to rid themselves of manual testing as much as possible. They want to rely on the system or on some tool. Let’s have a look at the possible reasons for this.

  • Manual testing is time- and cost-consuming when it comes to covering all workflows, all fields and all negative scenarios. If the same set of validations is performed at different intervals, as in the case of regression testing, then automation testing is quite important.
  • Automation testing does not require any human intervention. The automated test suite can be run unattended (even overnight).
  • It increases the speed of test execution.
  • It increases test coverage.
  • Manual testing can also become boring at times and, therefore, it is error prone.
table-1-a-few-open-source-automation-testing-tools
Table 1: A few open source automation testing tools
figure-1-autoit-recorder-window
Figure 1: AutoIt recorder window

Some open source automation testing tools 
There are many options to test any type of software. Some tools are available as open source while some are licensed, for which one has to pay before use. The first choice of any organisation is always for open source tools as they are free of cost. But there are certain limitations associated with these tools, due to which some firms opt for licensed tools. Table 1 lists some open source tools that are being used to test various types of software applications.

The AutoIt tool
AutoIt is an open source tool that can be used to automate various processes involving Windows and desktop applications. The official website of AutoIt defines it as a freeware BASIC-like scripting language designed for automating the Windows GUI and general scripting. It basically uses a combination of different keystrokes, mouse movements and window/control manipulation to automate different tasks. AutoIt runs on all versions of Windows. Since its initial release around 17 years ago by Jonathan Bennett and the AutoIt team in January 1999, it has become a very powerful language that supports various complex expressions, user functions, loops and other such features.
The syntax of the scripting language used in AutoIt is similar to that found in the BASIC family of languages. It actually uses C# and VB as its scripting language. AutoIt is a third-generation programming language with a classical data model and various data types which can store several types of data. It can be used to automate any specific task by simply writing a few lines of script or even record that process using the AutoIt Recorder. Once the recording is done, the script is automatically generated and we can use the same to further play back the recorded process. It identifies several elements of the application by using their various properties like the control ID, coordinates, the element’s name and other such smart identifiers. All such identifiers’ values are stored in a repository in the form of objects, and they are used during playback to identify various elements and perform actions on them.
The AU3 Info object identifier helps retrieve these values for a specific element of an application. It also has several inbuilt function libraries containing predefined functions that must be imported so that different functions can be used in the script. It has a SciTE editor, which helps to build and run various programs. The SciTE editor also provides all the configuration settings and other utility programs like Code Folding, Auto-complete, Syntax Highlighting and Intellisense. AutoIt is distributed with an IDE which is based on the free SciTE editor. The compiler and its help text are fully integrated and provide a standard environment for developers. We can create various GUIs such as Input Box, Label, Browser window, etc, which can be used to get a feel of the built application while creating a script. Once we have created a script, we can save it in the form of a .au3 executable file. It can be converted into a compressed and standalone executable, which can even be run on computers that do not have the AutoIt interpreter installed.

figure-2-au3-info-tool
Figure 2: AU3 Info tool
figure-3-autoit-gui-icon-selector
Figure 3: AutoIt GUI icon selector

Features of AutoIt
Let’s check the various features of AutoIt.
Easy to learn syntax: AutoIt uses a very simple syntax for its scripting language, which can be easily learnt and implemented for the automation of any process. The SciTE editor makes it easy by providing the syntax highlighting feature, using which one can get an idea of the syntax of the various predefined functions used.

Record and playback: As previously discussed, AutoIt can even record and generate a script on its own for specific processes that need to be automated. Once recorded, the same script, without any modification, can be used to run and play back the recorded process when required.

Interaction with all standard Windows controls: AutoIt can easily interact with all types of standard Windows controls and other GUIs without any object identification issue. It identifies a specific control with the help of the control ID, class name, title, position coordinates, visible text, etc – all of which are associated with that Windows control. It can get such properties of an element using the AU3 Info tool.

Simulates keystrokes and various mouse movements: AutoIt can even simulate various mouse movements and different keystrokes using the inbuilt ‘Send Key’ function. These movements and different key actions can also be recorded and played back afterwards.

Graphical User Interfaces (GUIs): Different GUIs can be provided to different processes, wherever required while automating a specific task, using AutoIt. There are several inbuilt functions under ‘GUI Control Create’ for different GUIs, which can be incorporated. Each of the separate GUI functions has a different syntax, following which we can generate different GUIs like the input box, label, browser window, drop-down menu, etc.

Calling external DLL and Windows API functions directly: We can directly call any DLL using AutoIt with the help of its predefined function, DLLcall. We can also call any API using this, and can even perform different operations on the Windows API using several _WinAPI_ functions.

RunAs function:  AutoIt has an inbuilt RunAs function, which helps in running any external program using some external user.

Detailed ‘Help’ file and large community-based support forums: AutoIt comes with AutoIt Help.exe, which provides all the possible help and support information for any learner. It even illustrates the automation of several scenarios, where the tool was used.

Compatibility: AutoIt is compatible with all Windows versions — Windows XP, 2003, Vista and 2008; Windows 7, 2008 R2, Windows 8 and 2012 R2.

Compilation of scripts into standalone executables: The entire script written using AutoIt can be stored in the form of a .au3 executable, which can be easily compiled and executed by simply clicking on the .au3 executive file. We need not open the script to run it.

figure-4-creating-a-new-au3-file
Figure 4: Creating a new .au3 file
figure-5-autoit-script-editor-window
Figure 5: AutoIt script editor window

How to automate a process using AutoIt
We first need to have AutoIt installed on our system. It just takes a few minutes to install it—simply click on autoit setup.exe. We need to additionally install Scite Editor.exe as well, in order to have the script editor in AutoIt.
Once we are done with the installation part, we need to simply right-click anywhere on the location where AutoIt has been installed, and follow the steps shown below to get the new .au3 file created on our system.
Right click New -> AutoIt v3 script -> Give a name to the file -> Press Enter.
Once we have created the .au3 file using the above steps, we need to just right click on this file and select the Edit script option to get an AutoIt script editor window, as shown in Figure 5.
This is where we can try our hand at scripting in order to make the AutoIt tool perform some task or action. Let’s automate a simple scenario where the user is asked his/her name, and once that is entered in the input box, the user gets a ‘Welcome’ message. Before proceeding with the scripting part, we can add our name as the Author in the auto-generated template of the script editor window.
The requirements are:
1. The ability to display the question asking the user for his/her user name and to accept this input. To incorporate this, we need to have the predefined InputBox function of AutoIt.
2. The inbuilt Message Box function to display a Welcome message for the user. We will have to import the MessageBoxConstants library to use the Message Box function in our script.
Let’s start scripting with the following steps:
1. Import all the required library files — we need to include the MessageBoxConstants library file.
2. Declare all the types of variables required (integer, string, etc) using the keyword Dim.
3. As discussed in Requirement 1, use the InputBox function to ask and take the input from the user. We just need to type Input and then click Ctrl + Space to get various hints, and then we can select InputBox out of the options provided.
4. Insert an opening round brace just after InputBox; AutoIt will display the hint of the syntax to be followed for that specific function. So here, for InputBox, we need to enter the following parameters in sequence.

  • Title – title to appear on top of the Input Box window
  • Prompt – the question for which the user needs to provide input.

5.   Once the user enters his/her name, we need to display the Welcome message using the name; so we will store the value of InputBox in a variable. We also need to verify whether the user has entered a name or not, so that we can display the Welcome or Error message accordingly. Hence, we will use the conditional If-else for that.
Finally, we are ready with the following AutoIt code:

; Including library files
#include <MsgBoxConstants.au3>
 
; Variable Declaration
Dim $userName
 
; Taking input from User
$userName=InputBox(“User Name”,”Please enter the User Name”)
 
; Validating if User has entered some User Name and then displaying Welcome Message
If $userName <> “” Then
MsgBox(0,”Welcome Message”,”Hey “ & $userName & “, Welcome to AutoIt..!!!”)
Else
MsgBox(0,”Error Message”, “Please enter the User Name”)
EndIf

Once we run the above code using F5, we will get an input box for the user to enter his/her name (Figure 6).
Once the user enters some name, a Welcome message will be displayed (Figure 7).
If the user does not enter any name and clicks on OK, then an Error message is generated.

Advantages of AutoIt
1. Supports easy record/playback and simple scripting
2. Loglines can be debugged easily with consolewritecommand.
3. AutoIt is an open source tool for which we do not need to pay.
4. Small standalone executables can be created using AutoIt.
5. AutoIt can recognise specific areas with pixelchecksum and pixelsearch.
6. It recognises all basic Windows controls and also has the option to create different GUIs.

figure-6-input-box-window
Figure 6: Input box window
figure-7-welcome-message-box
Figure 7: Welcome message box
figure-8-error-message-box
Figure 8: Error message box

Disadvantages of AutoIt
1. All types of objects are not identified by the AU3 Info tool.
2. AutoIt has no Java support available so far.
3. It has no control repository to give an object a logical or technical name.
4. It does not support all browsers, but only supports Internet Explorer controls by using IE.AU3 or its own COM object references.
5. Users need to import separate libraries for using different predefined utility functions.
There are several open source tools available in the market, but we need to evaluate and analyse any specific tool based on our requirements. AutoIt is one tool which can be used to automate various processes associated with Windows and desktop based applications with simple, user-friendly scripting.

 

LEAVE A REPLY

Please enter your comment!
Please enter your name here