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 with three asterisks, a space, the word “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 names are specified by being left justified or all the way to the left in a test cases 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.
  • We navigate to the add invoice page.
  • We get the invoice details and fill them out.
  • Submit an invoice form.
  • We check that the page should contain the invoice, and
  • Open the invoice.

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 just an overview of Robot Framework to give you a sense of how it works.

# Settings Section

You'll notice that there's a section at the top called “Settings” — *** Settings ***

Robot Framework test suites are defined in text files.

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

The libraries here include SeleniumLibrary, OperatingSystem, and Collections.

You'll also see that we use custom resources we've defined in other text files like resources.robot, invoice-details-page.robot, and others.

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 the 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 Invoices Application.



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

It's not a good application. It has defects and I use this application in order to show off tools like Robot Framework and help my people learn.

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



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

These reports are automatically generated.

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



Note, the background is green when the test suite passes. And even if 1 test case fails, it turns red.

**We'll look a bit deeper at 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 what exactly 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 available to work with many different languages. It's easily readable by business users and works well with 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.



Resources



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