Book Image

Robot Framework Test Automation

By : Sumit Bisht
Book Image

Robot Framework Test Automation

By: Sumit Bisht

Overview of this book

Testing has traditionally been a part of software development, and has always involved a lot of manual effort. It can be automated with Robot Framework, which offers numerous benefits from cost saving to increased quality assurance in the software delivery. This book will help you to start designing test suites and Automated Acceptance Tests. Helping you to get started with automating acceptance tests, this book will provide a detailed overview of acceptance test management practices and principles. You will also be introduced to advanced techniques that you can use to customize the test suite, along with helpful tips and tricks to extend and leverage it in a wide variety of scenarios. Starting with a detailed explanation of the need for automated acceptance test driven development, this guide will help you with an empty test project creation and execution for proof of concept, and validation of installation. This book will also cover the Robot Framework in detail, and will help you test desktop applications using Java Swing. You will gain an in-depth knowledge of tricky activities, such as setting up a test environment and using it with Selenium. You will also learn about other popular libraries, and how to test network protocols, web services, and databases. This book will cover the entire Robot Framework with real- world practical material to make its content informative and interesting. By the end of this book you will be able to write acceptance tests for desktop and web applications, as well as know how to extend acceptance testing in other scenarios that are commonly devoid of tests, and present the results appropriately.
Table of Contents (12 chapters)

Preface

Testing is essential for any activity to succeed; this applies to software as well. It not only covers verification but also the validation of the software. Commonly used testing practices include unit and functional testing that validates the needed functionality. However, manual efforts by testers or stakeholders are required to verify that the software being tested works as desired, as part of the software acceptance process.

As software has grown both in size and amount over the years, the acceptance testing process has become automated, leaving behind vast information in the form of audit trails of tests that need to be made available to the user at a glance and without which the purpose of acceptance test automation is defeated.

The Robot framework provides this missing link that integrates with the testing tool used for performing acceptance testing over the software or the "system under test" and structures this execution into discrete structures of tests arranged in a proper hierarchical manner; this not only results in execution in the desired manner, but also generates orderly reports.

Being an open source framework, this tool does not limit you to simply performing acceptance testing in a hierarchical manner and generating automated reports, but also allows you to customize it and create your own tool or even use it with other tools as part of a custom test environment setup required for your team.

What this book covers

Chapter 1, Getting Started with the Robot Framework, explains the need for acceptance test driven development, offers a high-level overview, and gives different methods of installation of the Robot Framework tool. It also discusses the various commands available for the user to interact with the framework and demonstrates simple test project creation and execution to the user.

Chapter 2, Configuring a Test Project, explains the test hierarchies and covers the different files and tables used in the framework as well as different syntax options to write the test files. It explains the commonly used test practices and explains how information can be re-used within the tests.

Chapter 3, Further Test Customization, covers test re-use, connectivity to external data sources and test templates, and user-defined keywords. It also provides different test writing styles and offers comparison with some other famous behavior-driven test tools.

Chapter 4, Extending the Framework, demonstrates real-world testing challenges and offers practical ways of using various built-in and external libraries to solve these challenges. It covers both the Web-based and desktop testing through object-oriented as well as image-based tests. In the absence of a compatible testing library, it also demonstrates the creation and integration of a custom written library.

Chapter 5, Generating Reports, covers the generated output of the tool in detail and offers different ways to customize the reports as well as the logs generated through the built-in as well as custom mechanisms. It also encourages the user to leverage the source code to create a customized reporting mechanism in the existing framework.

What you need for this book

In order to use the Robot Framework, you first need to install Python (the examples have been tested against 2.7, but you are free to use any version between Python 2.7 or 3), which might be installed if you are using a popular Linux distro or Mac OS X as your OS. Apart from Python, you can also install Jython and IronPython that can be used to run Python-based applications and tools such as the Robot Framework on JDK or .NET Framework runtime. A few examples do require explicit use of Jython, but the rest of the available environments can be used with any Python-based runtime. To install third party tools, or for easier installation, it is recommended to use easy_install Python module. Installations for tools/frameworks needed alongside testing with the Robot Framework are provided where necessary.

Who this book is for

As this book is focused on a testing tool, it primarily targets the testers. However, given the necessities of creating an in-house flexible testing tool, a hands-on Python development is also needed to modify and develop a testing framework to suit one's needs. Similar to DevOps movement, developers today are seeking ways to look beyond test and behavior-driven development, and the testers are also required to be more productive through means of automation. In this book, you will have to wear both the developer's and tester's hat in various situations in order to gain knowledge of this tool's working from both the perspectives.

Conventions

In this book, you will find a number of styles of text that distinguish between different kinds of information. Here are some examples of these styles, and an explanation of their meaning.

Code words in text are shown as follows: "We can include other contexts through the use of the include directive."

A block of code is set as follows:

# This code block runs 5 times for values of x between 11 and 15
|  | :FOR | ${x} | IN RANGE | 11 | 16 | 
# This code block runs 5 times for x = 10, 12, 14, 16,18
|  | :FOR | ${x} | IN RANGE | 10  |  20 |  2  |
|  |      |  Log  |  ${x} |

When we wish to draw your attention to a particular part of a code block, the relevant lines or items are set in bold:

           '<div id="top-right-header">' + 
             '<div id="report-or-log-link"><a href="#"></a></div>' + 
             '<div id="my_custom_image"><img src="../Pictures/github-icon.jpg" /></div>'+ 
           '</div>', { 
        generated: window.output.generatedTimestamp, 

Any command-line input or output is written as follows:

pybot --randomize tests all_tests

New terms and important words are shown in bold. Words that you see on the screen, in menus or dialog boxes for example, appear in the text like this: "On specifying the Fail option, the user is further requested for the failure message before failing the test."

Note

Warnings or important notes appear in a box like this.

Tip

Tips and tricks appear like this.

Reader feedback

Feedback from our readers is always welcome. Let us know what you think about this book—what you liked or may have disliked. Reader feedback is important for us to develop titles that you really get the most out of.

To send us general feedback, simply send an e-mail to , and mention the book title through the subject of your message.

If there is a topic that you have expertise in and you are interested in either writing or contributing to a book, see our author guide on www.packtpub.com/authors.

Customer support

Now that you are the proud owner of a Packt book, we have a number of things to help you to get the most from your purchase.

Downloading the example code

You can download the example code files for all Packt books you have purchased from your account at http://www.packtpub.com. If you purchased this book elsewhere, you can visit http://www.packtpub.com/support and register to have the files e-mailed directly to you.

The code files for all the chapters are also present on Github at http://github.com/SumitBisht/RobotFrameworkTestAutomation which you can download, fork, and modify as you like and send any suggestions or corrections there as well.

Errata

Although we have taken every care to ensure the accuracy of our content, mistakes do happen. If you find a mistake in one of our books—maybe a mistake in the text or the code—we would be grateful if you would report this to us. By doing so, you can save other readers from frustration and help us improve subsequent versions of this book. If you find any errata, please report them by visiting http://www.packtpub.com/support, selecting your book, clicking on the errata submission form link, and entering the details of your errata. Once your errata are verified, your submission will be accepted and the errata will be uploaded to our website, or added to any list of existing errata, under the Errata section of that title.

Piracy

Piracy of copyright material on the Internet is an ongoing problem across all media. At Packt, we take the protection of our copyright and licenses very seriously. If you come across any illegal copies of our works, in any form, on the Internet, please provide us with the location address or website name immediately so that we can pursue a remedy.

Please contact us at with a link to the suspected pirated material.

We appreciate your help in protecting our authors, and our ability to bring you valuable content.

Questions

You can contact us at if you are having a problem with any aspect of the book, and we will do our best to address it.