3

I'd like to have video recordings of the Selenium automation at work. And then delete the recording when the tests pass.

This way whenever the tests fail we can quickly replay the video to see what went wrong. Is there a free way to capture / record the screen while the automation is running?

I'm looking for something that wouldn't take up too much of disk space. And it's something that can be controlled via the program.

asked May 13, 2022 at 4:43

4 Answers 4

2

You can use docker image that Selenium provides for video recording. Since you use docker images in "remote driver" manner you can use those images from python code as well.

answered May 13, 2022 at 7:00
1

One of the simplest ways is to use the Castro library:

c = Castro(filename = "my-cool-selenium-video.swf")
c.start()
# Run your Selenium scenario
c.stop()

Videos are saved on /tmp, so you can simply run rm -rf /tmp/my-cool-selenium-video.swf afterwards.

EDIT:

Castro is not supported in Python 3 or later. As an alternative, you can use pyscreenrec.

import pyscreenrec
recorder = pyscreenrec.ScreenRecorder()
recorder.start_recording(video_name="output.mp4")
import time
time.sleep(10)
recorder.stop_recording()
answered May 13, 2022 at 7:33
3
0

You can use libraries like pyautogui and numpy to write code to record screen by taking screenshots and then adding them into a video file.

I haven't tried is myself, but with a quick search on the internet I got these links that might help you,

https://www.geeksforgeeks.org/create-a-screen-recorder-using-python/

https://python-mss.readthedocs.io/examples.html#opencv-numpy

https://www.thepythoncode.com/article/make-screen-recorder-python

https://www.section.io/engineering-education/create-a-screen-recorder-using-python-and-pycharm/

https://www.techgeekbuzz.com/how-to-make-a-screen-recorder-in-python/

Try these out and if any of it works do share the solution here so that other's may also benefit from it.

answered May 13, 2022 at 6:19
0

In every application, where user interface testing is performed, such scenarios of recording your automation script has become a common requirement in professional automation frameworks especially when you execute an automated nightly batch. Recording of test script is performed before start of your automation script and ends at tear down followed by saving recording at your local end. The best way to accomplish this task is to use Python with Castro which is a third party library.

Castro can be installed using below simple steps -

easy_install Castro or from pip command - pip install Castro

answered Jul 7, 2022 at 13:06

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

By clicking "Post Your Answer", you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.