i try to running testcase using selenium python and want to record video on every testacases, but when i try the output is always corrupted. FFMPEG process are running, no error appear on the output line. I attach my code, Please anyone help me is there anything i need to add or remove
here's the first file, for recorder :
import subprocess
from subprocess import Popen
from subprocess import call
class recorderMethod():
videoRecording = None
@staticmethod
def recorder_start(res,name):
rec_lib = 'ffmpeg -y -rtbufsize 2000M -f dshow -i video="screen-capture-recorder" -s '
resolution = res
buffer = ' -b:v 512k -r 20 -vcodec libx264 '
filename = name
extension = '.mp4'
complete_command = rec_lib+resolution+buffer+filename+extension
recorderMethod.videoRecording = Popen(str(complete_command))
@staticmethod
def recorder_stop():
if recorderMethod.videoRecording.poll() is None:
call('taskkill /F /T /PID ' + str(recorderMethod.videoRecording.pid))
here's the main test file for record the video
import unittest
import recorder_main
from selenium import webdriver
from time import sleep
class recordingTest(unittest.TestCase):
#init test
browser = webdriver.Chrome()
baseurl = 'http://www.facebook.com/'
record = recorder_main.recorderMethod
#setup
def setUp(self):
#declare to use browser
self.driver = recordingTest.browser
#make variable for easy access
driver = self.driver
#maximize Firefox
driver.maximize_window()
#go to maukerja
driver.get(recordingTest.baseurl)
#test001
def test_001_record(self):
#start recording
recordingTest.record.recorder_start('1920x1080','Test_Sleep')
sleep(10)
#stop_recording
recordingTest.record.recorder_stop()
#teardown
def test_999_ShutDownTest(self):
self.driver.close()
if __name__ == '__main__':
unittest.main(exit=False)