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.
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.