Hello,
"I am not really fond of using Log.Error instead because it may trigger the OnLogError event handler when you don't want to"
For this u can use anyway the Log.Error approach and manage unwanted log error event by using an event handler which will skip unwanted errors. The event handler must be in the main source code because events are fired by the testitem played.
Below here an example of a complete handler. It does 2 things, it manage multiple same errors raises and publish only one log entry and it skip unwanted errors raised.
The advantage is to fully centralized the error management.
/* ---------------------------------------------------------------------------
Gérer les erreurs répetées via gestion des events
--------------------------------------------------------------------------- */
function GeneralEvents_OnLogError(Sender, LogParams) {
if (LogParams.MessageText == LASTERRORLOG) {
SAMEERRORCOUNT++;
LogParams.Locked = true;
}
else {
// Pour éviter un test rouge
// - par l'erreur aléatoire de IT_Launch à sa sortie,
// - sur une déconnexion de la VM
// - ou sur une VM non visible
var skip = aqObject.CompareProperty(LogParams.MessageText, cmpContains, 'exception was encountered while terminating', false, lmNone);
if (!skip) {
skip = aqObject.CompareProperty(LogParams.MessageText, cmpContains, 'is invisible', false, lmNone);
}
if (!skip) {
skip = aqObject.CompareProperty(LogParams.MessageText, cmpContains, 'because the user session is disconnected', false, lmNone);
}
if (skip) {
Log.Message(LogParams.MessageText);
LogParams.Locked = true;
}
else {
if (SAMEERRORCOUNT > 1) {
Log.Warning('Erreur "' + LASTERRORLOG + '" répétée ' + SAMEERRORCOUNT.toString() + ' fois !');
}
LASTERRORLOG = LogParams.MessageText;
SAMEERRORCOUNT = 0;
}
}
}
Of course u need to initialize the variables used, in script extension init routine for example.
var LASTERRORLOG = '';
var SAMEERRORCOUNT = 0;