Best way to take screenshots of tests in Selenium 2?

后端 未结 13 2162
别跟我提以往
别跟我提以往 2020-11-28 04:29

I need a way to take screenshots of my functional tests. Right now I\'m using Selenium 2 with C# bindings. I pretty much want to take a screenshot at the end of the test to

13条回答
  •  半阙折子戏
    2020-11-28 05:07

    Define this in global code :

    var counter = DateTime.Now.Ticks.ToString();
    
    ((ITakesScreenshot)driver).GetScreenshot().SaveAsFile((snap +counter + ".jpg").ToString(), OpenQA.Selenium.ScreenshotImageFormat.Jpeg);
    test.Log(LogStatus.Fail, "Snapshot below: " + test.AddScreenCapture(snap + counter + ".jpg"));
    

提交回复
热议问题