How to create multi-line test or breaks in RobotFramework without creating a new keyword?

I need to call two teardown words in a test case, but I don't need to create a new keyword for this. I am wondering if there is such syntax for keywords as for documentation or loops, for example:

[Documentation] line1 ... line2 ... line3 
+6
source share
2 answers

Use the Run Keywords keyword.

From doc "This keyword is mostly useful when setting up and breaking, when they need to take care of several actions, and creating a new keyword of a higher level will be unnecessary"

It will look like this:

 Test Case [Teardown] Run Keywords Teardown 1 Teardown 2 

and

 Test Case [Teardown] Run Keywords Teardown 1 ... Teardown 2 

and with arguments

 Test Case [Teardown] Run Keywords Teardown 1 arg1 arg2 ... AND Teardown 2 arg1 
+20
source

To perform multiple keywords in the Teardown Test method, use the following trick:

First, define a new keyword that contains the set of keywords that you want to run.

eg. here Failed Case Handle is the new definition of the other two keywords take screenshot and close application . Think about it, take a screenshot, and then close the running application.

 *** Keywords *** Failed Case Handle take screenshot close application 

Basically, when you call the Failed Case Handle keyword, take screenshot and close application will execute accordingly.

Then, in the ***Settings*** section, define the Test Teardown procedure in the following example.

 *** Settings *** Test Teardown run keyword if test failed Failed Case Handle 

or,

 *** Settings *** Test Teardown run keyword Failed Case Handle 

So, in the first case, the Failed Case Handle keyword will be called if any test case fails. On the other hand, in the second case, after each test case, the Failed Case Handle keyword will be called.

0
source

All Articles