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 enter text (using SetText()) which is too long into a field with maxLength set.
Short of disabling the Log before setting the text and re-enabling afterwards, is there any way to tell TestComplete I don't care about if the text gets truncated (I am validating that myself, I expect it to get truncated).
I could use an event to catch when it's about to log a warning and check the warning text, but I would like to avoid that if possible.
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; } } }