![Robot Framework Tutorial](/robot_framework/images/robot-framework-mini-logo.jpg)
- Robot Framework Tutorial
- Robot Framework - Home
- Robot Framework - Overview
- Environment Setup
- Unix and Linux Installation
- Introduction to Ride
- First Test Case Using Ride
- Writing and Executing Test Cases
- Keyword and Data Driven Test Cases
- Working With Browsers Using Selenium Library
- Working With Textbox
- Working With Radio Button
- Working With Checkbox
- Working With Dropdown
- Working With Keywords
- Working With Variables
- Working With Command Line
- Working With Setup And Teardown
- Working with Built-In Library
- Working With External Database libraries
- Testing Login Page Using Robot Framework
- Robot Framework Useful Resources
- Robot Framework - Quick Guide
- Robot Framework - Useful Resources
- Robot Framework - Discussion
Working With Setup And Teardown
In this chapter, we will understand two important concepts of testing world − setup and teardown.<
Setup
This is a set of keywords or instruction to be executed before the start of test suite or test case execution.
Teardown
This is a set of keywords or instruction to be executed after the start of test suite or test case execution.
We will work on a project setup, where will use both setup and teardown. The opening and closing of browser are the common steps in test cases.
Now, we will add keyword open browser in the setup and close browser in teardown.
Open Ride using ride.py command from command line and create a new project.
![Teardown](/robot_framework/images/teardown.jpg)
Click New Project to create project.
![Create Teardown](/robot_framework/images/create_teardown.jpg)
Click OK to save the project.
![Save Teardown](/robot_framework/images/save_teardown.jpg)
Click New Test Case to create one.
![Test Case Teardown](/robot_framework/images/test_case_teardown.jpg)
Click OK to save the test case.
Now we need to import the SeleniumLibrary to use the keywords related to browser and interact with the pages.
To import the library, click Library −
![Import library Teardown](/robot_framework/images/import_library_teardown.jpg)
![Click library Teardown](/robot_framework/images/click_library_teardown.jpg)
Click OK to save the library.
![Save library Teardown](/robot_framework/images/save_library_teardown.jpg)
In the above screenshot, the Settings section has Setup and Teardown options. For Setup, click Edit to enter the keyword.
Now, enter the Keyword −
![Setup library Teardown](/robot_framework/images/setup_library_teardown.jpg)
Arguments have to be separated with the pipe character (|).
![pipe character](/robot_framework/images/pipe_character.jpg)
Click OK to save the Setup. We have entered the Keyword Open browser and also added the arguments as shown above.
Now, we will enter the teardown case.
Click Edit for Teardown and enter the keyword.
![Edit Teardown](/robot_framework/images/edit_teardown.jpg)
Click OK to save the teardown.
Now, we will enter the keywords for test case.
![Keywords Teardown](/robot_framework/images/keywords_teardown.jpg)
We have only Input Text in the test case. The opening and closing of the browser is done from Setup and Teardown Settings.
Test Execution Details
![Execution Teardown](/robot_framework/images/execution_teardown.jpg)
Conclusion
Setup and teardown play a crucial role in the testing world. We have seen how to use setup and teardown in our test cases and also how they are executed.