Forum Discussion
You need to create event handler for OnLogError event, inside it use LogParams.AdditionalText property to get the text you need.
You can use aqFile.WriteToTextFile to write the text to the file.
- cst990037 years agoContributor
This appear to work as expected but now every ERROR that is triggered hits this EVENT.
How do I get the EVENT to only work with this function?
or
Is there a different way to get the "Additional Info" text from the Accessibility Tests?
- karkadil7 years agoValued Contributor
How do I get the EVENT to only work with this function?
You can verify the LogParams.MessageText property inside your OnLogError event handler (it is the text from the log). If it contains "Web accessibility" (just double check the string, I'm not sure the text is exact the same), then add the AdditionalInfo to the file. You can use aqString.Find method, for instance, to check the substring presence.
- cst990037 years agoContributor
I am sorry but I do not think I am being clear on my question.
What I really need to do is get the text from the Additional Info tab in the ERROR results set.
A previous answer stated I could create an EVENT, which I have, and it is listed below but the problem is that the EVENT triggers EVERY time "any" ERROR is raised and I do not want that to happen. So what I would like to get is the Additional Info either through an event that is only called when I state it to be called or a different way to get the Additional Info.
I hope this is more clear.
Unless your post stated to allow the EVENT to trigger and wrap it with an "If" statement for WebAccessibility. I could easily do this but it seems odd that there is not better control of the EVENTs
Suggestions or Comments?
Thank youAndrew
function EventControl1_OnLogError(Sender, LogParams)
{var sFolder = "M:\\MyFiles\\";
var aString = LogParams.MessageText;
var aSubString = "\"";
var ResFirst = aqString.Find(aString, aSubString);
var ResLast = aqString.FindLast(aString, aSubString);if ( ResFirst != -1 ) {
str = aqString.SubString(aString, ResLast, aqString.GetLength(aString) );
aString = aqString.Replace(aString, str, "");
str = aqString.SubString(aString, 0, ResFirst+1);
aString = aqString.Replace(aString, str, "");
}var sFile = sFolder + aString + aqConvert.DateTimeToFormatStr(aqDateTime.Today(), "_%Y-%m-%d") + ".txt";
if (!aqFileSystem.Exists(sFolder)){
aqFileSystem.CreateFolder(sFolder);
}if (aqFile.Exists(sFile))
{
aqFileSystem.DeleteFile(sFile);
Log.Message("The file was created and the specified text is written to it successfully.");
}aqFile.Create(sFile);
aqFile.WriteToTextFile(sFile, LogParams.AdditionalText, aqFile.ctUTF8);
}