使用python绑定selenium3 webdriver进行测试自动化,以使用castro记录执行步骤,但在Windows 7 x64上失败.是否还有其他可用于记录目的的库或模块用castro编码from castro import Castrofrom selenium import webdri...

使用python绑定selenium3 webdriver进行测试自动化,以使用castro记录执行步骤,但在Windows 7 x64上失败.
是否还有其他可用于记录目的的库或模块
用castro编码
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上引发错误
Socket error: [Errno 10061] No connection could be made because the target machine actively refused it
Process Process-1:
Traceback (most recent call last):
File "D:\Python27\lib\multiprocessing\process.py", line 258, in _bootstrap
self.run()
File "D:\Python27\lib\multiprocessing\process.py", line 114, in run
self._target(*self._args, **self._kwargs)
File "D:\Python27\lib\site-packages\castro\lib\pyvnc2swf\vnc2swf.py", line 611, in main
merge=merge, debug=debug, reconnect=reconnect)
File "D:\Python27\lib\site-packages\castro\lib\pyvnc2swf\vnc2swf.py", line 429, in vnc2swf
client.loop()
File "D:\Python27\lib\site-packages\castro\lib\pyvnc2swf\rfb.py", line 489, in loop
if not self.loop1(): break
File "D:\Python27\lib\site-packages\castro\lib\pyvnc2swf\rfb.py", line 276, in loop1
self.request_update()
File "D:\Python27\lib\site-packages\castro\lib\pyvnc2swf\rfb.py", line 551, in request_update
self.send('\x03\x01' + pack('>HHHH', *self.clipping))
AttributeError: RFBNetworkClient instance has no attribute 'clipping'
解决方法:
我不建议使用castro.它真的过时了,我尝试在自己的测试中使用它并使其运行,但是它太不稳定了.
我目前正在将ffmpeg与screen-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
沃梦达教程
本文标题为:如何在Windows x64上的python中记录Selenium Webdriver测试执行


基础教程推荐
猜你喜欢
- Python画图时如何调用本地字体 2023-08-04
- Python面向对象之模块详解 2023-08-11
- Python实现检测照片中的人脸数 2022-08-30
- Centos7 安装Python3 Consul 和git最新版本 2023-09-04
- Python中paramiko模块的基础操作与排错问题 2022-10-20
- CentOS 7.5 安装 Python3.7 2023-09-03
- Pytorch关于Dataset 的数据处理 2023-08-04
- python中列表添加元素的几种方式(+、append()、ext 2022-09-02
- Python入门之字典的使用教程 2022-10-20
- python数据结构:数据类型 2023-08-05