Extracting Picture from logs
I have a requirement to store picture from test log whenever an error occurs. So, if an error occurs and there's a 'Has Picture' attribute with an attachment then the event should be able to save the picture attached to that error in a folder.
I went through some documentation but its mostly getting all pictures I think.
Is there any way I can check with LogParams that there is a picture in 'Has Picture' attribute and then based on it, I can extract the 'Picture' from the bottom section where Pictures, Details and Call Stack exist.
So the OnLog event works for Log.Error wherever in the script. What if we want to generate event on the errors logged by test complete (the ones that occurred for any reason such as object not found etc.). These errors are also displayed as red x in the test log. @rraghvani
Also, I am completely lost here. I need to get access to the child data Picture. I found the below code. The documentation tells to use PictureLogDataObj.Picture property to get access to the Picture data, but I think I am using indexes incorrectly. I also tried giving 1,2 in Data object but it throws error. Could you check the attachment and help where I am making the mistake. I am not able to get to the child data set and save Picture.
// Obtains a collection of logs
var LogsCol = Project.Logs;
// Obtains the first log item
var LogItem = LogsCol.LogItem(0);
// Obtains the first dataset
// of the specified log item
var LogData = LogItem.Data(0);
// Obtains the scheme of the dataset
var Sch = LogData.Scheme.Child(0); //it picks up 'ldtText ' but if I change Child(1) it throws error that parameters are incorrect.
// Obtains the data type of the first dataset
var LogDataType = Sch.DataType;
// Checks the data type
if ( LogDataType == ldtTable )
Log.Message("The dataset contains tabular data or data in a tree-like list.");
if ( LogDataType == ldtText )
Log.Message("The dataset contains text data.");
Log.Message("The dataset contains pictures.");
Sorry for the late reply, I was on holiday.
I was looking at your code, and came across Access Test Log Contents from Tests. There's sample code you can refer to - once you have logs appearing in your project, run this sample code, and it will extract table, text and images.