Transcripted Summary



Let's talk a bit about the Settings section.

I'm going to go into my 001-DemoOfRobotFramework directory, and look at the tour-of.robot file, because it's got a good example of a nice, big Settings section.


*** 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}

# Settings - Library

We've already talked about the Library keyword and how we can use preexisting libraries full of keywords in our test cases. The Library keyword can pull in preexisting keywords.

Your developers can make libraries for Robot Framework. You can even pull in Python packages and use them here.

Any publicly exposed method or function in Python can be exposed as a keyword by pulling it in with the Library keyword.

# Settings - Resource

Resources are files that you build.

You may have files that have keywords in them. You may have some that have variables in them.

There are lots of different ways to use the Resource keyword, but it helps you keep your keywords in certain groups.

There are a lot of other cool things you can do with the Settings section.

Make sure to take a look robotframework.org and the documentation there to learn more about different keywords you can use in the Settings section.

# Settings - Suite Setup and Suite Teardown

Some of my favorite keywords are Suite Setup, Suite Teardown, Test Setup, and Test Teardown.

**The Suite Setup allows you to run specific keywords prior to the entire suite running. **

Here, I've got a keyword called Run Keywords allowing me to run more than one keyword sequentially.


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

The Initialize Test Data is one of the custom keywords in one of the resources files.

Configure Selenium is another one of these that I've created.

Navigate To Homepage is the third keyword I call with run keywords in the suite setup section.

We run these in order from left to right prior to this suite or this file running.

So, before any test cases, we do these 3 steps.

**After all the test cases are done, we do something called Exit Selenium using this Suite Teardown. **

This is a little bit different in terms of how control flow works within Robot Framework.

We previously said that control flow works by executing the test case with the Variables section first, the Settings section second, the Test Cases section third.

This breaks that rhythm; it breaks that paradigm.

  • Suite Setup gets run prior to all test cases in this suite.
  • Suite Teardown runs after all test cases in this suite.

But both of these keywords are in this Settings section. I know that's a little confusing.

Take a look at the documentation in the BuiltIn library for different explanations that might work better for you.

The Settings section is basically something you can think of as your configuration, your steps before the test case, your pre-conditions.



Resources



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