selenium python实例录制运行,如何在x64窗口上的python中记录Selenium Webdriver测试执行...

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 module which can be used for recording purpose

Code with 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()

But it throws error on my 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'

解决方案

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

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值