Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

how to get the error message from the Robot Framework?

When I write testcase with Robot Framework, I write some error log with Robot Framework API logger.error(msg, html=False), when the test is finished, how can I get the error message?

For example, after the test is finished, log is as below: enter image description here

how can I get the error message that marked in red rect?

like image 395
Alex Bruce Avatar asked Dec 04 '25 14:12

Alex Bruce


1 Answers

@Alex Bruce. I was having the same issue. Use "Run Keyword And Ignore Error" with variable infront of it. That variable will have the Fail result you are looking for.

> *** 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
like image 114
ijaved Avatar answered Dec 08 '25 06:12

ijaved