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

时间:2015-04-02 05:04:46

标签: firefox selenium video screen

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

2 个答案:

答案 0 :(得分:5)

您可以将其包含在测试中。这是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();

答案 1 :(得分:-1)

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();
        }
    }
}