如何在windowsx64上用python记录selenium webdriver测试执行

2024-09-27 17:32:56 发布

您现在位置:Python中文网/ 问答频道 /正文

使用python绑定selenium3webdriver进行测试自动化,使用castro记录执行步骤,但在windows7x64上失败。在

是否有其他库或模块可用于录制目的

与卡斯特罗合作

from castro import Castro
from selenium import webdriver
from selenium.webdriver.common.keys import Keys
from time import sleep

def my_video_record():
    castroObject = Castro(filename="video/mytest.swf")
    castroObject.start()
    firefoxDriver = webdriver.Firefox(executable_path="firefox_geckodriver64bit/geckodriver")
    firefoxDriver.get("https://www.python.org")
    assert "Python" in firefoxDriver.title
    sleep(1)
    firefoxDriver.quit()
    castroObject.stop()

if __name__ == '__main__':
    my_video_record()

但它在我的Windows7 x64上引发错误

^{pr2}$

Tags: fromimportmyvideoselenium记录步骤sleep
2条回答

我不建议使用卡斯特罗。它真的过时了,我试着在我自己的测试中使用它,并且确实让它运行,但它太不稳定了。在

我目前使用的是ffmpegscreen-capture-recorder(屏幕录制软件),它的工作方式就像一个符咒。它允许您设置帧速率、分辨率、比特率以及选择不同的视频编解码器。在

代码如下:

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

原因是您没有启用vnc环回连接。在

相关问题 更多 >

    热门问题