Software testing professionals working in office

Robot Framework – Things You Must Know About

Things you need to know about Robot Framework are listed as a Question & Answer session

It is quite sure that we dreamed of building and operating or simply operating a robot at some point in our lives. With that dream or its remnants subtly embedded in our consciousness, the term robot framework may like a framework that helps you build or operate robots. Isn’t it? However, this is not the case, the term has nothing to do with any robot, although it sounds similar.
This framework has a certain amount of automation involved, which allows developers to develop and set automatic tests for testing their complex computing solutions. Although popular, this concept still stirs doubts in minds of professionals who may be considering QA Analyst as a career option or those who may be planning to pursue this course.

Question and Answers on Robot Framework

Wally Tauriac, one of the popular trainers on Robot Framework Test Concepts and a Software Engineer and Test Analyst for over 40 years of experience with several fortune 500 companies, sheds light on the importance of this framework and its implementation benefits in an online interview with Ben Xavier, CTO, Guruface.com.

Ben Xavier: What is Robot Framework?
Wally Tauriac: Robot Framework is an open-source automation test tool. It integrates with some common tools, such as Selenium, Appium, SAPGUI, Excel, and Python. These tools enhance its ability to provide a robust test framework for different application platforms.

 

Ben Xavier: How do you use a Robot Framework?
Wally Tauriac: Robot Framework is an open-source automation test framework tool. It uses the keyword-driven testing technique approach for its process design. Its capabilities can be extended by the integration of test libraries, such as, Selenium which is implemented by either Java or Python.
Robot Framework has its own set of Libraries known as standard libraries. But Selenium provides a library that can be referenced by a Robot Framework. The diagram above is a sample of a simple Robot Framework test script. The second line demonstrates an import of the Selenium library. The keywords OPEN BROWSER and CLOSE BROWSER come from the Selenium Library. Execution of this Robot Framework script would launch the Chrome browser and link to the home page of the Google website, and then the browser would close. A test results report is automatically generated.
Ben Xavier: How do I use Robot Framework in Excel?
Wally Tauriac: Excel is one of the test libraries that integrates with the Robot Framework test tool. The Excel library provides Robot Framework keywords that support reading, writing, and updating Excel and comma-delimited (CSV) files. The design of the Robot Framework supports the use of the Excel library keywords to process Excel data in a type of function called Suite Setup.
Figure 1 below is a graphic example of potential Robot Framework files that make up a script. The test case file is the main process, and then the Resource files can be called or imported by the main process. The resource files support browser actions, variable definitions, and reusable functions, respectively. In Figure 2 you can see that the variable and test functions can be replaced with Excel Sheets to support and control data management.

graphic example of potential Robot Framework files that makeup a script
Figure 1
In Robot Framework variable and test functions can be replaced with Excel Sheets to support and control data management
Figure 2

Figure 3 can be useful in appreciating a graphic picture of several Robot Framework test component file combinations. The green boxes represent the main test case file. The blue boxes represent resource files providing reusable data for Robot Framework execution. The red box is where one or more Excel test sheets are invoked to drive the testing. Then each row of the main sheet describes a test case for Robot Framework to process.

A graphic representation of several Robot Framework test component file combinations.

Figure 3

Ben Xavier: How do you open the Robot Framework RIDE?
Wally Tauriac: First, RIDE stands for Robot Framework IDE. This is a tool known as the RF integrated development environment to implement automated tests for the Robot Framework using a GUI editor.
To open or launch RIDE requires launching Windows Explorer. Go to the folder where the RIDE is installed. Locate the executable and Right-click, and then select ‘Send To’ Desktop to create a shortcut. Once a shortcut is created on the desktop RIDE can be launched by double-clicking the icon. Otherwise, you would need to double-click the executable from within Windows Explorer.
When the tool is launched it will look something like the diagram below.

Screenshot of RIDE tool launched

When a new test case is requested, the screen shown in the diagram above appears. From here a Robot Framework script can be defined. The minimum is to specify Robot Keyword statements where the line numbers appear. Otherwise, more Robot Framework functionality can be utilized by defining setup and teardown code that can be processed before and after general code at the line numbers.
For those of you who are used to high-level IDE functionality, this is a good tool. I prefer to use the native Robot Framework coding features from a generic IDE like PyCharm for Robot Framework code development.

Ben Xavier: How to create a List in Robot Framework?
Wally Tauriac: Robot Framework supports scalar, list, and dictionary variables. Variable names consist of the variable type identifier ($, @, &, %), curly braces ({, }) and the actual variable name between the braces. A list variable starts with “@” with a variable name inside the braces. (e.g. @{vname})
Ben Xavier: How do I create a List in Robot Framework?
Wally Tauriac: Define a variable in the Variables section of an RF test case or resource file. An example of the syntax is: @{List} Item1, Item2, ItemX
The variable must have two spaces before the data assignment.
Sample definition and reference of Robot Framework List variables:
Robot-Framework-List-variables
Ben Xavier: How do you use RIDE Robot Framework?
Wally Tauriac: This editor is available with Robot Framework which helps in writing and executing test cases. The editor is easy to install and use. RIDE simplifies writing test cases by providing framework-specific code completion, and syntax highlighting. Creation of project, test suite, test case, keywords, variables, importing the library, executing, tagging the test case is easy to do in the editor.

Ben Xavier: How to run a Python Script in Robot Framework?
Wally Tauriac: Robot Framework was built using Python. So, it fits naturally with the Python environment. Python can be defined to run in Robot Framework. There are at least two approaches – a Run Process keyword or referencing Python internal function names.
The Run Process keyword is a simple keyword from the Robot Framework Process standard library. As an alternative, all function names in Python programs can be referenced within a Robot Framework script as keywords. This approach also requires a Resource reference in the SETTINGS section of a Robot Framework script.

Robot-Framework-settings-Resource-reference

Ben Xavier: How do you write Robot Framework test cases?
Wally Tauriac: There are two file types associated with Robot Framework scripts – the test case file and the resource file. The test case file is the main file and is sufficient for a Robot Framework script. The test case file contains up to four sections labeled: SETTINGS, VARIABLES, TEST CASES, and KEYWORDS.
Details writing the test cases depend on whether you are using RIDE or another editor, such as PyCharm. In general, it requires specifying some settings to import libraries and resources, identifying, and required variable definitions, specifying some keywords to indicate a process flow, and defining reusable functions to reference in the test case flow.

Robot Framework screenshot

As said before, a Robot Framework test case includes up to four sections: SETTINGS, VARIABLES, TEST CASES, AND KEYWORDS. The example below demonstrates three of the four sections. The SETTINGS section is referencing a library reference and a resource file reference. It also references two SUITE keywords which execute browser keywords to Open the browser at the beginning of the test run, and a Close browser at the end of the test run. Several variables are defined in the Variables section. The Test Cases section assigns a test case name Valid Login. The remaining keywords provide test functions for the test case.
Ben Xavier: How to write test cases in Robot Framework?
Wally Tauriac: To write a test case using RIDE, right-click on the project. Click New Test Case. Enter the name of the test case and click OK. There are three tabs shown for the test case created − Edit, Text Edit, and Run.
Otherwise, like PyCharm, under the project, you can create a robot file. Double-click to open it and begin defining the sections and then the settings, variables, test cases, and supportive keyword functions.
Ben Xavier: How do I read a file in Robot Framework?
Wally Tauriac: The Excel library for Robot Framework supports reading XLS, XLSX, and CSV file extensions. It contains the necessary keywords to process these files.
The most important keyword from the Excel Library is the OPEN EXCEL statement. In the Test Case file, it is important to provide a Library statement referencing DataDriver. If that statement references an Excel or CSV file, the DataDriver will automatically read each row or record in the file one at a time. Otherwise, the OPEN EXCEL statement can be referenced in a Robot Framework Resource file.

What’s Next?
If you are interested in learning the framework and its implementation, you may join the online course on Robot Framework offered by Wally Tauriac on the top-rated e-learning platform – Guruface.com. This course is specially designed for those who want to improve their knowledge in automated testing by employing various features and functions of Robot Framework and exploiting its ability to integrate with Python, Selenium, and Excel.

Editor@Guruface.com

Leave a Reply

Name *
Email *
Website