Exception Handling and Conditional statement

In the Robot framework, there are builtin keywords that handle the execution when the failure occurs.

Below are the keywords available to use when the failure occurs,

 

Run Keyword And Continue On Failure - Runs the keyword and continue to execute the next line
Run Keyword And Expect Error  - Runs the keyword and checks that the expected error occurred.
Run Keyword And Ignore Error   - Runs the keyword and Ignore any error if it occurs
Run Keyword If All Critical Tests Passed - It should be used in Suite Teardown 
Run Keyword If All Tests Passed - It should be used in Suite Teardown 
Run Keyword If Any Critical Tests Failed - It should be used in Suite Teardown 
Run Keyword If Any Tests Failed - It should be used in Test Teardown 
Run Keyword If Test Failed - It should be used in Test Teardown 
Run Keyword If Test Passed - It should be used in Test Teardown 
Run Keyword If Timeout Occurred - It should be used in Test Teardown

 

The complete documentation is available in Robot framework forum - http://robotframework.org/robotframework/2.6.1/libraries/BuiltIn.html#Run%20Keyword%20And%20Continue%20On%20Failure

 

Conditional Statement :

The conditional statement If ... else can be used in Robot framework with Run Keyword If

 

Run Keyword If

 

Example:

 

Run Keyword If    '${flag}' == 'INPUT'    Input Text      firstName   webdriver
...    ELSE IF    '${flag}' == 'CLICK'    Click Element         //a[text()='REGISTER']
...    ELSE    Select From List by Label     country    ALBANIA
 

 

Related Tutorials