How to Automate Windows Application Using WinAutomation Tool (Part- II):
We have covered all the basics of WinAutomation tool in our previous tutorial “Automating windows application using WinAutomation Tool (Part 1)”.
Main part comes in this tutorial, here we will discuss how to get started with the tool and create a simple robot and run the robot with some real-time examples.
As we continue with this part, we strongly recommend that you install WinAutomation Tool as per the details provided in part 1.
This tutorial includes a pictorial representation of each step involved in creating a robot along with practical examples in order to enable you to understand the concept in a better way.
In this tutorial, we will look into the following:
#1) Create a Simple Robot – 1
Consists of a very simple creation of a robot without using any properties of the WinAutomation Tool.
#2) Create a Simple Robot – 2
Consists of a little more complicated case with some advanced steps.
Let’s see now how to create a simple robot with 2 different examples.
As it is not an open source tool, I am running the Basic Edition of WinAutomation tool, which is a 30 days free trial. The various editions of WinAutoamtion Tool have been discussed already in our previous tutorial.
What You Will Learn:
Create a Simple Robot – Example 1
First, identify the WinAutomation icon and double click on it to open the console.
WinAutomation will take few seconds to get started and display the console.
Below is the screenshot of how WinAutomation Console will look like.
There are few predefined examples which are displayed on the left side of the Console.
Here you can create your projects as different folders as shown in the above image.
Now let’s start by creating a simple Robot with two steps. Though it would be much faster manually, as it is a basic simple test, let’s begin with it.
Here, our aim is to Create a folder in C drive and name the folder, say SimpleRobot.
It is just a demonstration of how to use some key features.
- Create a new folder.
- Name the folder.
- Add a message, that the task is completed.
#1) Click on the New Robot icon on the top left corner as shown below. You can use the shortcut (CTRL+N) as well to create a New Robot.
#2) Once you click on the New Robot, you will get a screen where it will ask to name the New Robot. Assign a name to the New Robot – say “First Robot”
#3) Once you give your Robot a name and click on enter, you will see a Robot designer as shown below, where it consists of many folders which have their own properties, and can be used during automation. As everything is predefined here, it is so easy to use the WinAutomation tool.
#4) Open the folder “Folders” and you can see “Create folder” option under it as shown below.
#5) Now you can drag the action create a folder and drop it to the main action sequence which is present on the right side as shown below. You can also double-click on the Action create folder.
#6) Once you double click on the create folder, a folder property window will be opened as shown below where you can enter the location and name of the folder in the fields provided.
Don’t enter anything in Action Output, leave it as it is for now and click on OK button.
After that, you can see that the create folder is added to the action sequence as seen below.
#7) Now we need to add a message that, the folder has been created successfully. For this expand message boxes folder and you will be able to see many options as shown below.
#8) Click on Display message option which is the first option in the list, you can click and drag or double click on Display message action.
#9) Properties window of the “Display message” action will be displayed.
For each action, there would be a corresponding property window, where you can assign your own properties to the action
#10) Enter a title and a message as shown below in the property window. Title as “My First Test” and message as Folder “SimpleRobot” has been created.
#11) Click on OK to close the box.
#12) Your designer screen should look as shown below.
Steps for creating the test script for the robot to run is completed now.
Next, you must Run the robot to check if it is working as expected.
#13) Click on the Run icon as shown in the below screen.
Once you click on Run, immediately the robot starts executing each line in the main console.
Once it is completed, you should see a message box “Folder “SimpleRobot” has been created” as shown below and a new folder would be created at the destination which you have selected in the property window of the action create folder.
So, it’s done now. You have successfully created a new folder using the Robot.
Close the Robot Designer and save the robot.
You can see the created Robot in the WinAutomation console as shown below.
There are few examples by default where you can understand and run those by default. WinAutomation has provided these examples for a better understanding of the tool.
According to the experience level of the user, there are many such examples in each folder on the WinAutomation Tool.
Create a Simple Robot – Example 2
In this Example, we will see some advanced features of the Win Automation Tool where you can use different variables which are present and also see how we can use the variables between different actions.
Here you can also copy the data and use it, by moving it into various actions.
In the first example, we saw how we can create a folder, now we will assign a date and time for the folder we created which would be in the name of the folder.
To perform the above-mentioned action, we need to perform the below 4 steps:
- Need to get the current time.
- As it in the number form, need to change into a text format.
- Create a folder with that name.
- Finally, we need to put up a message that the proposed actions are done as we did it in the first example. By putting up messages it would make your task easier where the Robot has finished the assigned task or not.
Let’s take a look at see how to perform the above four steps.
Step 1: Need to get the current time
We have already seen in the first example of how to open the WinAutomation tool and create a new Robot. Let us straight away go to the action part.
Navigate to the “Date time actions” folder from the list of folders displayed and expand it to see various actions.
Click and drag “Get Current Date and Time” action to the main console as shown below.
Now, the property window of “Get Current Date and Time” will open which consists of two variables – Action Input and Action Output as shown below.
There are two options available in the Retrieve drop down of Action Input variable. As we need current date and time as well, we are leaving the option as it is.
We will be retrieving the information to a variable “%CurrentDateTime%”.
So that we can store the retrieved date and time for future purposes.
Once you click on the OK button, you will see a screen like below.
Step 1 is done.
Step 2: Change date to text format.
Click and expand the “Text Actions” folder form the actions folder list.
You will see a list of actions as shown below.
Find the action “Convert date time to text”, click and drag the action to the main action sequence.
Property window for Convert date time to text will be displayed as shown below.
In Date Time to Convert field you need to enter the variable which you have created in your previous action, i.e., “%CurrentDateTime”.
Select Custom format from Format to use the drop down.
There are many custom formats for date and time in the custom format drop down.
Here, let’s select yyMMdd format in our example.
Property window will look as shown below.
The action output will be “%FormattedDateTime%” now.
Step 3: Create a folder
As we saw in Example 1, we need to create a new folder.
In this step, you will create a new folder with the name “%FormattedDateTime” and store the output in a folder and need to assign a message once the assigned task is completed.
Step 4: Assign a display message
The last step is to assign a display message for the task.
We need to perform the same steps as we did in the first example.
Click on OK button, and the property window of the display message will be closed.
Once all the steps are done, your final Robot designer should look as shown below.
Now run the Robot by clicking on the run icon at the top as we did in example 1.
Once your test is successfully run, go and verify in the destination folder if a new folder created with the folder name as current date and time in a text format.
Save the project and close the robot designer.
We are successfully done with two examples of how to use WinAutomation tool to automate a windows application.
I hope everyone should have a basic knowledge of how to use the WinAutomation Software tool for automating a windows application through this tutorial.
After using it practically, you will come to know that it is one of the best and easiest tools to automate windows and web applications.