如何将ScreenCaptureJob链接到浏览器窗口?

时间:2019-08-28 09:43:36

标签: c# selenium screen-capture expression-encoder microsoft-expression

我正在尝试使用Microsoft表达式编码器SDK录制屏幕视频。 但是它也会记录锁定的Windows屏幕(在超时或Win + L之后)。 如何将CaptureJob绑定到chrome / firefox浏览器并仅捕获浏览器窗口?

using Microsoft.Expression.Encoder.ScreenCapture;

[Binding]
public sealed class CommonWebActions
{
    [BeforeScenario]
    public static void Initialize(TestContext testContext)
    {
        Driver = new ChromeDriver();
        Driver.Manage().Window.Maximize();

        if (VideoRecorder.Status != RecordStatus.Running)
        {
            TestRecordName = "Test.wmv";
            VideoRecorder.OutputScreenCaptureFileName = TestRecordName;
            VideoRecorder.Start();
        }
    }

    [AfterScenario]
    public static void CleanUp()
    {
        VideoRecorder.Stop();
        if (_testContext.CurrentTestOutcome == UnitTestOutcome.Passed || 
            _testContext.CurrentTestOutcome == UnitTestOutcome.Inconclusive)
        {
            File.Delete(TestRecordName);
        }

        Driver.Quit();
    }
}

0 个答案:

没有答案