http://robotframework.org/robotframework/latest/libraries/BuiltIn.html#Run%20Keyword%20If%20Any%20Critical%20Tests%20Failed
| ?不太明白如何使用 | Run Keyword And Expect Error | expected_error, name,*args | ||
| Run Keyword And Ignore Error wait logname ${var} | Run Keyword And Ignore Error | name, *args |
Runs the given keyword with the given arguments and ignores possible error.
This keyword returns two values, so that the first is either string PASS or FAIL, depending on the status of the executed keyword. The second value is either the return value of the keyword or the received error message. See Run Keyword And Return Status If you are only interested in the execution status. The keyword name and arguments work as in Run Keyword. See Run Keyword If for a usage example. Errors caused by invalid syntax, timeouts, or fatal exceptions are not caught by this keyword. Otherwise this keyword itself never fails. Since Robot Framework 2.9, variable errors are caught by this keyword. | |
| ?不太明白如何使用 | Run Keyword And Return | name, *args |
Runs the specified keyword and returns from the enclosing user keyword.
The keyword to execute is defined with name and *args exactly like with Run Keyword. After running the keyword, returns from the enclosing user keyword and passes possible return value from the executed keyword further. Returning from a keyword has exactly same semantics as with Return From Keyword. Example: Run Keyword And Return My Keyword arg1 arg2 # Above is equivalent to: ${result} = My Keyword arg1 arg2 Return From Keyword ${result} Use Run Keyword And Return If if you want to run keyword and return based on a condition. New in Robot Framework 2.8.2. | |
| Run Keyword And Return If '${var}'=='aaa' logname ${var}==aaa | Run Keyword And Return If | condition, name, *args |
Runs the specified keyword and returns from the enclosing user keyword.
A wrapper for Run Keyword And Return to run and return based on the given condition. The condition is evaluated using the same semantics as with Should Be True keyword. Example: Run Keyword And Return If ${rc} > 0 My Keyword arg1 arg2 # Above is equivalent to: Run Keyword If ${rc} > 0 Run Keyword And Return My Keyword arg1 arg2 Use Return From Keyword If if you want to return a certain value based on a condition. New in Robot Framework 2.8.2. | |
| ${var}= Run Keyword And Return Status wait logname ${var}
logname ${var} | Run Keyword And Return Status | name, *args |
Runs the given keyword with given arguments and returns the status as a Boolean value.
This keyword returns Boolean True if the keyword that is executed succeeds and False if it fails. This is useful, for example, in combination with Run Keyword If. If you are interested in the error message or return value, use Run Keyword And Ignore Errorinstead. The keyword name and arguments work as in Run Keyword. Example: ${passed} = Run Keyword And Return Status Keyword args Run Keyword If ${passed} Another keyword Errors caused by invalid syntax, timeouts, or fatal exceptions are not caught by this keyword. Otherwise this keyword itself never fails. New in Robot Framework 2.7.6. | |
| Run Keyword If '${var}'=='aaa' logname ${var} | Run Keyword If | condition, name, *args |
Runs the given keyword with the given arguments, if condition is true.
The given condition is evaluated in Python as explained in Evaluating expressions, and name and *args have same semantics as with Run Keyword. Example, a simple if/else construct: ${status} ${value} = Run Keyword And Ignore Error My Keyword Run Keyword If '${status}' == 'PASS' Some Action arg Run Keyword Unless '${status}' == 'PASS' Another Action In this example, only either Some Action or Another Action is executed, based on the status of My Keyword. Instead of Run Keyword And Ignore Error you can also use Run Keyword And Return Status. Variables used like ${variable}, as in the examples above, are replaced in the expression before evaluation. Variables are also available in the evaluation namespace and can be accessed using special syntax $variable. This is a new feature in Robot Framework 2.9 and it is explained more thoroughly in Evaluating expressions. Example: Run Keyword If $result is None or $result == 'FAIL' Keyword Starting from Robot version 2.7.4, this keyword supports also optional ELSE and ELSE IF branches. Both of these are defined in *args and must use exactly format ELSE or ELSE IF, respectively. ELSE branches must contain first the name of the keyword to execute and then its possible arguments. ELSE IF branches must first contain a condition, like the first argument to this keyword, and then the keyword to execute and its possible arguments. It is possible to have ELSE branch after ELSE IF and to have multiple ELSE IF branches. Given previous example, if/else construct can also be created like this: ${status} ${value} = Run Keyword And Ignore Error My Keyword Run Keyword If '${status}' == 'PASS' Some Action arg ELSE Another Action The return value is the one of the keyword that was executed or None if no keyword was executed (i.e. if condition was false). Hence, it is recommended to use ELSE and/or ELSE IF branches to conditionally assign return values from keyword to variables (to conditionally assign fixed values to variables, see Set Variable If). This is illustrated by the example below: ${var1} = Run Keyword If ${rc} == 0 Some keyword returning a value ... ELSE IF 0 < ${rc} < 42 Another keyword ... ELSE IF ${rc} < 0 Another keyword with args ${rc} arg2 ... ELSE Final keyword to handle abnormal cases ${rc} ${var2} = Run Keyword If ${condition} Some keyword In this example, ${var2} will be set to None if ${condition} is false. Notice that ELSE and ELSE IF control words must be used explicitly and thus cannot come from variables. If you need to use literal ELSE and ELSE IF strings as arguments, you can escape them with a backslash like \ELSE and \ELSE IF. Starting from Robot Framework 2.8, Python's os and sys modules are automatically imported when evaluating the condition. Attributes they contain can thus be used in the condition: Run Keyword If os.sep == '/' Unix Keyword ... ELSE IF sys.platform.startswith('java') Jython Keyword ... ELSE Windows Keyword | |
| ? critical Test 是什么? Suite Teardown Run Keyword If All Critical Tests Passed logname allpass | Run Keyword If All Critical Tests Passed | name, *args |
没有评论:
发表评论