webdriverio-community / wdio-video-reporter

Reporter for WebdriverIO that makes videos of failed tests and has optional allure integration

Home Page:https://webdriver.io/docs/wdio-video-reporter

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

increase video length to include a few seconds before and after the failed test

jrobinson01 opened this issue · comments

This reporter is really useful, but it doesn't seem like there's enough info in the video to figure out what is going wrong. It might be useful for the video to start recording a few seconds earlier and stop a few seconds after the failed test.

Not sure how to do it, or if it is even possible.
The reporter latches on to the hooks that webdriver.io exposes:
https://webdriver.io/docs/customreporter.html#event-handler

I think you may be able to do the same thing by doing a few actions that generates screenshots (see the list here: https://github.com/presidenten/wdio-video-reporter/blob/master/src/config.js#L33) in the beforeEach/afterEach sections of the suite and increasing the videoSlowdownMultiplier option slightly.

Feel free to come up with some other ideas on how to achieve it that we can discuss though.
Im open to improving the library.

I took a quick look through the code but didn't quite grasp how the videos are generated. ffmpeg commands are crazy! What events does the reporter use to determine the start and end of the video? Would it be possible to capture the whole spec in the event of a failure? My idea there was to always gather the screenshots, and only build/save a video if there's a failure in the current spec.

Another idea to add onto the previous one, would be to write text into the video (screenshot) to display the current test/command/etc so as you watch the video, you get feedback as to what commands are running.

This is the quickie on how it works:

  • When a test starts it prepares with meta info, such as test name and reset the frame counter.

  • When any command is issued to the selenium server it is filtered through a list of what I think are "user actions". If the command is an action, then the reporter snaps a screenshot.

  • When the test ends, a ffmpeg command is prepared that will compile the frames to a video

  • When all tests (for one browser) are done, the ffmpeg commands get executed and videos generated.

Now to answer your questions:

What events does the reporter use to determine the start and end of the video?
onTestStart and onTestEnd. All available events can be found here:
https://webdriver.io/docs/customreporter.html#event-handler

Would it be possible to capture the whole spec in the event of a failure? My idea there was to always gather the screenshots, and only build/save a video if there's a failure in the current spec
Not sure what you mean? If you dont want all videos to be saved, set the config saveAllVideos to false.
https://github.com/presidenten/wdio-video-reporter/#normal-configuration-parameters

There is a trade off with the frame grabbing in that it slows down test execution. Thats why frames are only grabbed after "actions", where the reporter supposes something has changed. If you want more frames, there is an option for that as well. Pass an array called addJsonWireActions to the reporter config with more commands on when to take screenshots.
Read more here:
https://github.com/presidenten/wdio-video-reporter/#advanced-configuration-parameters
All available JSON wire commands can be found here:
https://github.com/SeleniumHQ/selenium/wiki/JsonWireProtocol#command-summary
Would that fullfil your need for longer/more video?

The command thing suggestion is really neat. Only problem is that the reporter dont see the webdriver io commands. It sees the JSON wire commands. Some webdriver.io commands translates into multiple JSON wire commands.
Maybe it would still be helpful though. If I manage to figure out how to append text to the video. Maybe it could be done by editing the screenshots before the videos are generated?
Hmm... Will ponder on this one.

Would it be possible to save all the screenshots within the same it() that the failure occurs?

Would it be possible to save all the screenshots within the same it() that the failure occurs?

Isnt this default behaviour? Or maybe I missunderstand something?

Closing this because no more input. Reach out again if you want me to reopen the issue