- 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
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
Working With Setup And Teardown
In this chapter, we will understand two important concepts of testing world − setup and teardown.<
This is a set of keywords or instruction to be executed before the start of test suite or test case execution.
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.
Click New Project to create project.
Click OK to save the project.
Click New Test Case to create one.
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 −
Click OK to save the library.
In the above screenshot, the Settings section has Setup and Teardown options. For Setup, click Edit to enter the keyword.
Now, enter the Keyword −
Arguments have to be separated with the pipe character (|).
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.
Click OK to save the teardown.
Now, we will enter the keywords for test case.
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
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.