how to record selenium webdriver test executions in python on window x64

后端 未结 3 1446
悲&欢浪女
悲&欢浪女 2021-01-25 05:23

Using python binding selenium3 webdriver for test automation, to record execution steps using castro but it is failing on Windows 7 x64.

Is there any other library or mo

3条回答
  •  谎友^
    谎友^ (楼主)
    2021-01-25 06:06

    I do not recommend using castro. It's really outdated, I've tried using it in my own tests and did get it running but it was too unstable.

    I'm currently using ffmpeg together with screen-capture-recorder (screen recording software) and it works like a charm. It allows you to set the framerate, resolution, bitrate as well as chose different video codec.

    The code looks like this :

    from subprocess import Popen
    from subprocess import call
    
    cmd = 'ffmpeg -y -rtbufsize 2000M -f dshow  -i video="screen-capture-recorder" -s 1920x1080 -b:v 512k -r 20 -vcodec libx264 test.avi'
    
    def terminate(process):
        if process.poll() is None:
            call('taskkill /F /T /PID ' + str(process.pid))
    
    videoRecording = Popen(cmd) # start recording
    
    terminate(videoRecording)   # terminates recording
    

提交回复
热议问题