Extracting Picture from logs
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Extracting Picture from logs
Hi,
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.
Thank you
- Labels:
-
BDD Tests
-
Script Tests
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Are you able to use OnLogPicture Event, which can be called during an OnLogError Event
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
I will try this. thanks
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
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.
function LogDataTypeExample()
{
Log.Error("testing")
// 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.");
else
if ( LogDataType == ldtText )
Log.Message("The dataset contains text data.");
else
Log.Message("The dataset contains pictures.");
}
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
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.
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Thanks @rraghvani I think I found that link too. Been a bit distracted but will start looking at this soon. 🙂
