Selenium将浏览器操作记录为视频



我写了一个selenium代码,通过Firefox在网页中运行自动化我需要像视频一样记录浏览器操作有没有任何方法可以使用插件或其他方式将firefox上的屏幕录制为视频。我使用的是firefox版本34

您可以将其包含在测试中。下面是C#的一个例子。要使此工作,您需要安装Microsoft Expression Encoder并将引用添加到您的项目

using Microsoft.Expression.Encoder.ScreenCapture;
    string timestamp = DateTime.Now.ToString("dd-MM-yyyy-hh-mm-ss");
    ScreenCaptureJob vidrec = new ScreenCaptureJob();
    vidrec.OutputScreenCaptureFileName = @"C:/yourPathToSaveFile/yourFilename " + timestamp + ".wmv";
    vidrec.Start();
// your test
vidrec.Stop();

http://learnseleniumtesting.com/recording-selenium-test-execution/

using System;
.
.
using OpenQA.Selenium;
.
.
using Microsoft.Expression.Encoder.ScreenCapture;
using System.Drawing;
using Microsoft.Expression.Encoder.Profiles;
using Microsoft.Expression.Encoder;
namespace FRAMEWORK
{
    //Call this method in setup method.   
    public static void StartRecordingVideo()
    {
        //Provide setting in config file if you want to do recording or not.
        if (testEInfo.isRecording)
        {
            job = new ScreenCaptureJob();
            job.CaptureRectangle = Screen.PrimaryScreen.Bounds;
            job.ShowFlashingBoundary = true;
            //provide the location where you want to save the recording.
            job.OutputPath = AutomationLogging.newLocationInResultFolder;
            job.Start();
        }
    }
}

最新更新