tphillips
4 years agoFrequent Contributor
Disable warning about text being truncated
I am writing a test that checks that when it enters text in a text field that has a maxLength set, the text gets truncated. I noticed that TestComplete (helpfully) logs a Warning when it tries to ent...
- 4 years ago
Use the onLogWarning event.
2 ways, check the Sender object to filter on source basis or check the LogParams to filter on message basis.
Below a sample of message basis filtering :
var globals = {}; globals.WARNINGTOSKIP = ['The text cannot be fully entered', 'The length is too long', 'Another message to skip']; // Array of the warnings message to skip globals.IGNOREWARNING = false; // True then convert Log.Warning into Log.Message
function GeneralEvents_OnLogWarning(Sender, LogParams) { // Detect if, based on log message, it's a warning to be totally ignored let skip = false; for (let i = 0; i < globals.WARNINGTOSKIP.length; i++) { skip = skip == false ? aqObject.CompareProperty(LogParams.MessageText, cmpContains, globals.WARNINGTOSKIP[i], false, lmNone) : true; } if (skip) { Log.Message(LogParams.MessageText); LogParams.Locked = true; } else { // If just message instead of warning if (globals.IGNOREWARNING) { Log.Message(LogParams.MessageText, LogParams.AdditionalText); LogParams.Locked = true; } else { // Need to switch to avoid reentrancy let f = GeneralEvents_OnLogWarning; GeneralEvents_OnLogWarning = null; Log.Warning(LogParams.MessageText, LogParams.AdditionalText); GeneralEvents_OnLogWarning = f; LogParams.Locked = true; } } }