How to record videos and taking screenshots for failed tests

I have two projects which I automate them using robotframework

First project I use
1- robotframework
2- azure pipeline
3- report portal
How can I take screenshot for failed test cases and display them in report portal?
How can i record video for all the tests or for the failed test cases and display them in report portal?

Second project I use
1- robotframework
2- Browser Library
3- azure pipeline
4- report portal
How can I take screenshot for failed test cases and display them in report portal?
How can i record video for all the tests or for the failed test cases and display them in report portal?

I’m open also if there is any recommendations on how/where to display screenshots and videos for failed test cases while running the tests on azure pipeline

Hi @hager_yousri,

Most of the libraries that interact with GUI’s will have a screenshot keyword.

e.g. for Browser Library it’s Take Screenshot and this is triggered by default on failure but can be changed with Register Keyword To Run On Failure

If you have a library that doesn’t have a screenshot function, then you could import SikuliLibrary and use Capture Screen or ImageHorizonLibrary and use Take A Screenshot both of which will capture everything on the screen at the os level

Another option is to use Run Process or Run to call an external command line screen shot program or shell script

As for taking a recording of the test, there’s nothing built in that I know of but if you have a command line screen recorder you can use the method above to run a start recording and a stop recording command. you can include the start recording and stop recording commands in the one of the Startup/Teardown keywords ( Test setup and teardown or Suite setup and teardown)

There may be more information in these threads:

Hope that helps,

Dave.

Thanks for the reply regarding the screenshots I tried this keyword " Register Keyword To Run On Failure" and it takes the screenshot successfully but it doesn’t be shown in report portal so any idea please how to fix this ?

Hi @hager_yousri,

No idea why they don’t show in the reports, they always do for me but on Linux and MacOS, I haven’t used RF on windows for over a year but from what I remember the reports worked there too.

You could look at the html of the report find the <img src=“”> and check the src path against your machine.

Dave.