I would like to my test takes screenshot when an error occur.
I can write like this:
TestContext.WriteLine("aaaaaaaaa");
But how can I attach an image to a .TRX file?
I would like to my test takes screenshot when an error occur.
I can write like this:
TestContext.WriteLine("aaaaaaaaa");
But how can I attach an image to a .TRX file?
Images of controls and of the entire desktop can be taken during a Coded UI test. They are captured as normal
Image
objects and can then be saved or otherwise manipulated in the test. The files can also be attached to the test results. The code below gives some ideas on the code that can be used.The file name used in the
...Save
call should be modified to give each saved image a different name. This is specially necessary when the tests are data driven, otherwise there will be no way of associating images with test executions.