当我使用Robot Framework编写测试用例时,我使用Robot Framework API logger.error(msg, html=False)
编写了一些错误日志,测试完成后,如何获取错误消息?
如何获取红色矩形标记的错误消息?
答案 0 :(得分:0)
@Alex Bruce。我遇到了同样的问题。使用"运行关键字并忽略错误"面前可变。该变量将具有您正在寻找的失败结果。
> *** Settings *** Documentation Test Suite Teardown Close All Browsers Library Selenium2Library timeout=10
>
> *** Variables *** ${BROWSER} chrome ${SLEEP} 3
>
> *** Test Cases *** Testing
> Error Logging
>
> *** Keywords *** Open Google
> Open Browser http://google.com/ ${BROWSER}
> Wait Until Page Contains Damn timeout=1
>
> Error Logging
> ${ErrorChk} = Run Keyword And Ignore Error Open Google
> log ${ErrorChk[1]}
Starting test: Error.Testing
20170731 17:57:13.874 : INFO : Opening browser 'chrome' to base url 'http://google.com/'
20170731 17:57:19.131 : INFO : </td></tr><tr><td colspan="3"><a href="selenium-screenshot-1.png"><img src="selenium-screenshot-1.png" width="800px"></a>
20170731 17:57:19.132 : FAIL : Text 'Damn' did not appear in 1 second
20170731 17:57:19.133 : INFO : ${ErrorChk} = ('FAIL', u"Text 'Damn' did not appear in 1 second")
20170731 17:57:19.133 : INFO : Text 'Damn' did not appear in 1 second
Ending test: Error.Testing
答案 1 :(得分:0)
您好@AlexBruce也许您可以使用此KW:
Run Keyword If '${status}'=='FAIL' FAIL msg=${message}
您可以选择$ {message}中的消息