This tutorial explains the Basics of the Robot Framework IDE – RIDE, how to create a Project, Test Suite, and Test case in RIDE & how to use Libraries:
In the previous Robot Framework tutorial, we learned about its pros, cons, important features, and installation instructions in detail.
Ride is the Integrated Development Environment for Robot Framework. An Integrated Development Environment (IDE) is a software application that provides comprehensive facilities to computer programmers basically for writing and debugging code.
In our case, Ride as the IDE will be used to write and execute the scripts in the Robot Framework.
This tutorial will give you an understanding of the basics of Ride. We shall learn how Ride as an IDE can be used to write test scripts. We would learn about the libraries available and also see how these libraries can be used.
Lastly, we would understand the need for adding browser driver and learn to add them too.
What You Will Learn:
Basics Of RIDE – Robot Framework IDE
Before we begin understanding the basics of Ride, we need to know how we would access it once it has been installed on our system.
So, to access Ride we have two options as explained below:
- Go to the command prompt and type ‘Ride.py’
- Create a shortcut of Ride on the desktop for easy access. Follow the steps mentioned below:
- Open Windows Explorer.
- Go to the folder where Ride is installed (“C:\python27\scripts” in our case).
- Right-click and select ‘Send To’ Desktop (Create shortcut)’.
- A shortcut is created on the desktop and can be clicked to open Ride.
When Ride is opened for the first time, the screen will look as shown below.
The top menu has the options – File, Edit, Tools, Navigate, Macros, Help. Below the Menu Options are the Shortcut icons: Go Back, Go Forward, Open Test Suite, Open Directory, Save, Save As, Search Keywords, Search Tests, Run Tests, Run Tests with Debug, Stop Test Run.
As we go ahead with understanding the use of Ride, you will get to know the use of each of these menus and shortcuts.
The next topic will explain how we can create a new Project, Test Suite, and a Test Case using the File menu.
Creating A Project, Test Suite & Test Case In Ride
The File Menu is used to create a new Project. Let’s select the menu option File -> New Project to create our first project in Ride. Within the project, we will see how we create a Test Suite and it is within the Test suite that we will create our first test case in Ride.
Click the File menu option and choose the first option “New Project”.
You will get a screen as shown below on clicking the ‘New Project’. On the screen below, add a ‘Name’ to the project and select the ‘Parent Directory’ where you want to create this project.
The project can be created as a File as well as a Directory. We will keep the format of the Project as ‘ROBOT’ and the Type as ‘Directory’.
In the above image, we are creating a project by the name ‘MyFirstProject’ the path for which can be seen in the ‘Created Path’ as ‘C:\RF\MyFirstProject’. Once ‘OK’ is clicked the project gets created as seen in the screenshot below.
Once the project is created, right-click the project and select “New Suite”.
As in the snapshot below, we are creating the test suite by the name “TestSuite1”. Click “OK”.
Now that we have the Test suite created, let’s now create the Test case within it and we hope you now know how to create one. Right-click on “TestSuite1” and select “New Test Case”.
As seen in the below screenshot, we are creating our test case by the name “TestCase1”.
This is the hierarchy in which the test cases are placed in Ride. One could compare the Test Project to the actual project for which the test cases are being designed, the Test Suite corresponds to a module within the project and the Test Cases within the Test Suite are the test cases related to that particular module.
So we have divided the test cases, module wise within a project in Ride.
The screen below is where we write test scripts in Ride. It is a tabular structure in which the test scripts can be written.
You must be curious to begin writing your first test script in Robot Framework using Ride, but before we start with it, let’s quickly take a look at the libraries that are required for Robot Framework and also learn how to add browser drivers that would be needed for executing a Test case.
It is the libraries that contain the keywords to help us write test scripts in the Robot Framework.
There are two different types of Libraries:
- Standard Libraries
- External Libraries
Standard Libraries are the built-in libraries that are provided along with the Robot Framework. Robot Framework however also supports the use of External Libraries. Standard Libraries do not need to be imported explicitly and are available by default, however, External libraries need to be imported into the project/suite where it is to be used.
Do keep in mind, that you too can create External Libraries once you gain expertise.
Enlisted below are the keywords that are made available through the Standard and various External libraries. This will give you an idea of some of the keywords that can be used as per the requirement to write the code for a test case.
#1) Standard Libraries
Given below are the Standard Libraries of Robot Framework:
|Builtin||It contains the basic keywords that are needed for writing scripts.||For Example, “Should Contain”, “Set Variable If”, “Run Keyword” And Ignore Error”etc.|
|Collections||It contains keywords for interacting with Lists and dictionaries.||For Example, “Create List”, “Should Be Empty”, “Get Count”|
|DateTime||It has useful keywords for handling operations related to date/time.||For Example, “Get Current Date”, “Add Time To Date” etc.|
|Dialogs||The keywords in this Library come handy when we want to pause and execution until an input is received from the user.||For Example, “Get Selection From User”, “Get Value From User”,etc.|
|Operating System||This library caters to the tasks related to the Operating System. For Example, Create directory, Set environment variables etc.||For Example, “Create Directory”, “Environment Variable Should Be Set” etc.|
|Process||The keywords in it are required to run a process, start a process and waiting for process to complete.||For Example, “Run Process”, “Start Process”, “Wait For Process” etc.|
|Remote||This library in actual doe s not have keywords of its own but acts as a proxy between the Robot Framework and the actual servers containing the test libraries. Example of Remote server is the PythonRemoteServer, node-robotremoteserver etc.||N/A|
|Screenshot||As the name suggests, the keywords in this library are needed when we want to capture screenshots.||For Example, “Take Screenshot”, “Set Screenshot Directory”|
|Telnet||To communicate over a telnet connection we can use the keywords of this library.||For Example, “Read Until Prompt ““Set Timeout”, “Close Connection”|
|XML||It provides Keywords for verifying or modifying the contents of XML files.||For Example, “Evaluate Xpath”, “Parse Xml”|
#2) External Libraries
Besides the Internal Libraries available by default with Robot Framework, there are a plethora of External Libraries too, that can be used to enhance the capabilities of the Robot Framework.
Unlike the standard libraries that are included by default, the External Libraries have to be installed and then imported into the Project/Suite where it is to be used.
Let’s begin by learning to install the most commonly used libraries, followed by importing them into a Project/Suite.
(i) SeleniumLibrary: It is a testing library that enables the use of the Selenium tool. It is one of the commonly used external libraries. To install this Library use the below command at the command prompt.
Pip install robotframework-seleniumlibrary
(ii) Appium Library: This is an Appium testing library for testing the Android and iOS applications. It, therefore, supports using the Robot Framework for automating mobile application testing. To install this Library, use the below command at the command prompt.
pip install robotframework-appiumlibrary
(iii) Database Library (Python): This is a python library that can be used for database testing. To install this Library use the below command at the command prompt
pip install -U robotframework-databaselibrary
(iv) Android Library: Keywords from this library are required for Android application testing. It uses Calabash Android to interact with the Android Application. To install this Library use the below command at the command prompt (Python >= 3.6 is needed to execute this command).
pip install –upgrade robotframework-datadriver
So far, we have discussed the various Standard and External Libraries, let’s take a look at how each of these libraries, installed on our system can be imported into a Project/Test suite.
As an example let’s import the SeleniumLibrary into the project we created. Select the project where the Library is to be used. Click the “Library” button on the left.
In the “Name” text box, type the name of the Library ‘SeleniumLibrary” and click “OK”.
If the name appears as below (in black) it means that it has been successfully imported into the project.
However, if the library name appears in red after “OK” is clicked, then it means that the library could not be found and has not been added to the Project. For Example, see the screenshot below.
This is not over yet, once you have imported the Library into the project, it must also be imported at the Test Suite level. So, let’s now select the test suite and repeat the same steps as above to add it to TestSuite1.
This completes the process to download and import the External libraries at Project and Suite level.
Downloading And Adding Browser Drivers
The tests that we automate will be executed in a browser and we need to add the browser drivers for that. To begin with, we will be downloading the Browser driver for Chrome.
Follow the below steps to download the browser driver for Chrome:
#1) Open Chrome driver downloads and click the desired version of the Chrome driver. We are downloading the latest version shown here i.e. version 79.0.3945.36.
#2) On the next screen, the File has to be selected as per the operating system version. Here we are selecting for Windows.
#3) After downloading, open the download folder and you will be able to see the file (in zipped format), now unzip the file and you will get the chromedriver.exe file.
#4) This .exe file is to be copied and pasted in the Python27 folder or its Scripts folder. The reason for saving it in either of the locations is that we have added that path in the Environment Variable and it will be accessible from anywhere on the system.
We have now installed the Chrome driver successfully on our system. Similarly, we can download the Browser driver for IE, Edge, and Firefox, etc. and save the unzipped .exe directly in the Python27 folder or its Scripts folder.
We now have the browser driver along with the libraries imported into our project and test suite. We are now all set to begin writing a basic test script in the Robot Framework which we shall cover in our next tutorial “Understanding and working with Robot Framework”.
This brings us to the end of the tutorial “Getting Started with Ride”. We hope you have followed each step as mentioned and learned in the basics of Ride.
By now, you should be able to create a Project, a Suite, and a test case in Ride. The tutorial also explained the various libraries available and we also saw how they can be added in a Project/Suite.
We also saw how the browser driver can be added. This will form a basis for us to move to the next level of understanding Robot Framework and actually write scripts and thereby automating our test cases.
In our next tutorial, we will explore about Understanding and working with the Robot Framework”.