Transcripted Summary

Hello, I'm Paul Merrill and I'll be guiding you through this course, an introduction to Robot Framework.

Robot framework is a test driver. It allows you to easily create and read automated scripts. Much like Cucumber, human readable scripts enable better communication between stakeholders, developers and testers.

Test drivers are helpful in implementing Acceptance Test Driven Development, ATDD, and Behavior Driven Development, BDD.

Let's walk through an example.

# Example Code – Tour-of.robot

*** Settings ***
Library  SeleniumLibrary
Library  OperatingSystem
Library  Collections

Resource    resources.robot
Resource    invoice-details-page.robot
Resource    navigation.robot
Resource    system.robot
Resource    data.robot

Suite Setup  Run Keywords   Initialize Test Data    Configure Selenium   Navigate To Homepage
Suite Teardown  Exit Selenium

*** Test Cases ***
Create An Invoice
    ${invoice}=     Get Dummy Invoice   demo
    Navigate To Add Invoice
    Fill Out Invoice Details    ${invoice}
    Submit Invoice Form
    ${invoice_id}=   Get Invoice Id     ${invoice}
    Page Should Contain     ${invoice_id}
    Open Invoice    ${invoice_id}

# Test Cases Section

Tests in Robot Framework are defined in a Test Cases section of a test file.

The section is defined by the heading, three asterisks, a space, “Test Cases”, a space and three asterisks — *** Test Cases ***.

Spacing and positioning are very important as they tell Robot Framework how to interpret the test file.

The name of the test case here is “Create an Invoice”.

Test case name is specified by being left justified or all the way to the left in a test case section.

The next 7 lines here are the actions that make up the test case.

For the most part, this section is easily readable. We create dummy invoices, navigate to the add invoice page and go back to the invoice details.

I've intentionally made this test suite a bit complicated so that you can get a sense of some of the features and inner workings of Robot Framework. Remember, this is an overview of Robot Framework.

# Settings Section

You'll also notice a section called “Settings” at the top of this text file — *** Settings ***

Robot Framework test suites are defined in text files.

You'll notice we're using libraries to find keywords we will use in the test case.

The libraries here include SeleniumLibrary, OperatingSystem and Collections.

You'll also note we use custom resources we've defined in other text files like resources.robot, invoice-details-page.robot, et cetera.

Resource files and libraries provide Robot Framework, a way to share behaviors and data keywords and variables between test suites.

Finally, you'll notice we've used a Suite Setup and Suite Teardown to call keywords or do actions. These run before and after the test suite.

# Running Suite

I run the suite using the command robot and the file name of the test suite I want to run — robot tour-of.robot.

This test suite is in the file name called “tour-of.robot”. I'm giving you a tour of Robot Framework, so I felt this was a good name.

This test suite and all of our tests during this course are running against an application I host called the Add Invoice application.

It is an invoice manager. You can add invoices, delete them and modify them.

It's not a good application. It has defects which I need in order to show tools like Robot Framework, identifying certain behaviors or failing tests.

As I mentioned, this test uses SeleniumLibrary to drive the web browser.

Now that the test has run and passed, let's look at the reports.

These are automatically generated locally.

Many plugins exist for continuous integration systems like Jenkins, Bamboo and others to make running, reporting and aggregating reports easy.

Note that the background is green when the test suite passes. Even if one test fails, it turns red.

Let's look deeper and view the logs.

The logs show us every keyword used in the test.

We can see if they passed or if they failed. We can see exactly what the problem was and what the keyword did.

This has been a brief overview of Robot Framework.

It's a powerful tool with an active open source community, testers with no automation experience can automate with it. Developers can use it to give access to features and logic long before a UI is available.

It's able to work with many different languages. It's easily readable by business users and works well in BDD and ATDD.

Robot Framework can work for most types of automated testing, not just UI testing. Many IDEs have support for Robot Framework like VS Code, IntelliJ and Atom.

I'm looking forward to working with you to learn more about how to use Robot Framework.


© 2021 Applitools. All rights reserved. Terms and Conditions Privacy Policy GDPR