【问题标题】:how to record selenium webdriver test executions in python on window x64如何在window x64上的python中记录selenium webdriver测试执行
【发布时间】:2017-06-12 15:49:29
【问题描述】:

使用 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'

【问题讨论】:

  • 你在vnc服务器上使用vncauth吗?

标签: python selenium automated-tests


【解决方案1】:

我不推荐使用 castro。它真的过时了,我已经尝试在自己的测试中使用它并且确实让它运行但它太不稳定了。

我目前正在使用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

【讨论】:

  • 两个都需要安装吗? ffmpeg 和屏幕截图记录器?
  • @Bomin,是的。
  • 支持命令行安装吗?例如,我可以从“chocolatey”安装它们
  • 视频捕获很好,但似乎没有捕获音频。 ffmpeg 是功能性的。可能是什么问题?
【解决方案2】:

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

【讨论】:

    【解决方案3】:

    Selenium 为我们提供了运行自动化代码/套件并将输出记录为视频并将其保存在您的系统上的功能。然后可以与任何可以看到自动化正在做什么的人共享此视频。首先,要启用视频录制,我们需要下载一些重要的 jar。它们可以从谷歌免费下载。下面是要下载的jar。这些是可用的最新版本,也可以下载任何其他版本:

    ATUReporter_Selenium_testNG_5.1.1 ATUTestRecorder_2.1

    您可以在以下链接中找到完整的代码: https://mytechdevice.com/how-to-record-video-of-automation-output-in-selenium/

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2013-09-18
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2017-01-11
      • 2015-06-07
      • 1970-01-01
      相关资源
      最近更新 更多