locked
Failed test not attaching screenshot RRS feed

  • Question

  • Hi,

    We are running coded ui tests via a build definition on a remote test agent.  Everything is running in a VS2010 configuration with .Net 4.0.  We are running a group of tests via an ordered test.  These tests run at night and are unattended.  When a test fails a screenshot of the failing application is attached to the test results.  However, sometimes the screenshot fails to attach.  

    I had searched through some of the posts and found that people recommended creating your own screenshot and attach it to the test results when the one that comes automatically from VS fails to attach.  So we created a recovery scenario that gets called when a test case fails and part of the recovery is to take an image of the screen, save it locally, and then attach it to the TestContext.  Here is the code we are using to do this:

                Image pic = myBroswer.CaptureImage();
                string fileName = @"C:/Windows/Temp/TestRecovery_" + theTestContext.TestName + ".png";
                //Save the file
                pic.Save(fileName);
                //Add the file to the results
                theTestContext.AddResultFile(fileName);

    This code works great when the normal VS screenshot attaches (so we have two screenshots in the results).  However, when the normal VS screenshot fails to attach this extra screenshot also fails to attach.  Basically we are back to no screenshot.

    Does anyone have a fix for this problem? It is very hard to figure out why a test failed without looking at the screen that it failed on.  Luckily since we are taking our own screenshot, we can pull the images out of C:/Windows/Temp/ on the Test Agent however it would be better if the images were attached to the report.

    Thanks

    Jeff

    Wednesday, January 29, 2014 4:17 PM

Answers

All replies

  • Hi Jeff,

    Generally we modify the .config file to get the detailed log which has the screen shot in the .html file.

    Reference:

    http://msdn.microsoft.com/en-us/library/jj159363.aspx

    I have met a similar issue, it seems that it is related to the IE version. Maybe you could check it here:

    http://social.msdn.microsoft.com/Forums/en-US/7a8bce65-a3a4-45b2-8ba6-5c50f3d96fe0/coded-ui-test-log-not-capturing-screen-shots?forum=vstest

    If you mean that you want to get your own screen shot in the .html file, maybe you could submit this feature request: http://visualstudio.uservoice.com/forums/121579-visual-studio. The Visual Studio product team is listening to user voice there. You can send your idea there and people can vote. If you submit this suggestion, I hope you could post that link here, I will vote it. Thanks for your understanding.

    Have a nice day,


    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click HERE to participate the survey.

    Friday, January 31, 2014 5:13 AM
  • Jack,

    Thanks for the reply.

    My problem is that sometimes the screenshot attaches and other times it doesn't when a test fails. Nothing in our environment has changed.  Same version of IE.  Same version of VS.  Same test case.

    We can run the test suite on Monday and get attached screenshots for all of the failed tests.  We run it again on Tuesday and the screenshot attachment fails.

    As far as taking our own screenshot, I have already implemented that code.  However, on days when the native screenshot won't attach the one that we create won't attach either.  The code that we are using to generate and attach the test case is in my original post.

    The issue that you referenced is a little different since they were not able to attach any screenshot before updating to IE10.  

    Is there any kind of issue with attaching a screenshot where the TRX file is over a certain size? There are a bunch of settings in the QTAgent32.exe.config file.  Would any of these impact the attachment of a screenshot other than

    <add name="EqtTraceLevel" value="2"

    <add key="EnableSnapshotInfo" value="true"/>

    We are using VS2010 BTW.

    Jeff

     

    Friday, February 7, 2014 6:02 PM
  • Hi krag451,

    Do you mean that sometimes you couldn’t get the screenshots? If so, whether it is the same test if you get the screen shots?

    Maybe you could check the detailed error when you run the tests. I didn’t find the document which shared the limitations for the screenshot size, but my understanding, it would have it more or less.

    One possible reason is that you tests don’t run, I mean that the test methods aren’t called.

    Sincerely,


    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click HERE to participate the survey.

    Monday, February 10, 2014 11:47 AM
  • participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place http://support.microsoft.com/common/survey.aspx?showpage=1&scid=sw%3Ben%3B3559&theme=tech


    • Edited by twista123456 Thursday, February 13, 2014 2:37 PM
    Thursday, February 13, 2014 2:36 PM