Search code examples
seleniumautomationrobotframework

What is the replacement for @BeforeMethod annotation in Robot Framework - Selenium Library?


I need to execute some keyword before each and every test cases. Assume I have a .robot file which has 4 test cases, and I need to run a keyword, 4 times before executing those 4 test cases. In TestNG, we can use @BeforeMethod annotation. I would like to know what can be used to do that from Robot Framework?

Thank You.


Solution

  • Following are the keywords in robot framework as the replacements for execution hooks.

    ┌────────────────┬───────────────────────┐
    │ Robot Keyword  │ TestNG Execution Hook │
    ├────────────────┼───────────────────────┤
    │ Test Setup     │ @BeforeMethod         │
    │ Test Teardown  │ @AfterMethod          │
    │ Suite Setup    │ @BeforeSuite          │
    │ Suite Teardown │ @AfterSuite           │
    └────────────────┴───────────────────────┘