Forum Discussion
HKosova
13 years agoSmartBear Alumni (Retired)
Hi Mykhailo,
A possible option is to use Name Mapping in your test, like Robert suggested. When you address an object using a mapped name/alias, and this object or any of its parent objects does not exist, no errors are posted to the log. This way, you can verify the object existence without checking existence of its parent hierarchy:
Another option that doesn't involve Name Mapping or verifying the entire object hierarchy is to create an OnLogError event handler that will suppress the standard "not found" errors from logging during the object existence check. Something like this:
A possible option is to use Name Mapping in your test, like Robert suggested. When you address an object using a mapped name/alias, and this object or any of its parent objects does not exist, no errors are posted to the log. This way, you can verify the object existence without checking existence of its parent hierarchy:
// TestComplete won't log an error if any object in the "path" doesn't exist
if Aliases.MyProcess.MyWindow.SomePanel.AnotherPanel.SomeButton.Exists then
Aliases.MyProcess.MyWindow.SomePanel.AnotherPanel.SomeButton.Click
else
Log.Message('SomeButton does not exist.');
Another option that doesn't involve Name Mapping or verifying the entire object hierarchy is to create an OnLogError event handler that will suppress the standard "not found" errors from logging during the object existence check. Something like this:
procedure GeneralEvents_OnLogError(Sender, LogParams);Make sure not to filter errors that may indicate other kinds of issues.
var str;
begin
str := LogParams.Str;
// Suppress messages containing one of the specified strings
if (Pos('Process not found', str) > 0) or
(Pos('Cannot obtain window', str) > 0) then
begin
LogParams.Locked := true;
end;
end;
Related Content
- 14 years ago
- 6 years ago
- 10 years ago
Recent Discussions
- 5 days ago
- 5 days ago