问题
I have written a keyword for Testcase teardown in my Robot Testsuite. Which is mentioned below:
*** Keyword ***
Result Evaluation
@{TRACEFILE} = evalVirdict ${value[2]}
:FOR ${ELEMENT} IN @{TRACEFILE}
\ Log ${ELEMENT}
\ Run Keyword if '${TEST STATUS}'=='FAIL' readerrlines ${ELEMENT}
In the above Keyword evalVirdict
is a function written in python and ${value[2]}
is coming from my Testcases and in Run Keyword if '${TEST STATUS}' == 'FAIL' readerrlines ${ELEMENT}
part. I am calling another function readerrlines
which returns some value. The readerrlines
function definition is below:
def readerrlines(tracefile):
errVal = []
for line in list(open(tracefile)):
line = line.strip()
mat = re.match(r'.*\s.*\s+:\s\*+(.*\s)\s{1}', line)
if mat:
err = mat.group(1).strip()
errVal.append(err)
return errVal
Here i want to know how to get this returned value from readerrlines functions in Run Keyword if '${TEST STATUS}' == 'FAIL' readerrlines ${ELEMENT}
?
I have tried Run Keyword if '${TEST STATUS}' == 'FAIL' @{errval} = readerrlines ${ELEMENT}
but got an error as Non-Existing variable @{errval} and also Run Keyword if '${TEST STATUS}' == 'FAIL' Set Variable @{errval} = readerrlines ${ELEMENT}
with no error and no output as well.
回答1:
Run Keyword If
will return the result of the keyword it is running. Thus, you would do:
${result}= Run Keyword If '${TEST STATUS}'=='FAIL' readerrlines ${ELEMENT}
来源:https://stackoverflow.com/questions/31249339/how-to-get-returned-value-from-a-keyword-called-under-run-keyword-if-in-robot-fr