Forum Discussion
Hi Robert,
Thank you for your respond.
My question now is, does SetFocus method work with Window Object or only work with BrowserWindow? I tried using it with other objects on other page, and it also log error "unable to find the object SetFocus. Seems to me it only works with BrowserWindow... or I am doing something wrong here.
To answer your questions in italic...
What are you intending to achieve? I am trying to SetFocus on the objcet "Aliases.browser.pageConfirm.cellPopupm.table.cellNoticnconttablebx.table" which happens after another window get closed(a popup window for confirmation which get closed when click "OK"). By using "Aliases.browser.BrowserWindow3.SetFocus()" the window got focus, but when try to SetFocus on any object on that page, the error message say "Unable to find the object SetFocus. ". But really it was able to find and clicked, no issue. I don't know why there is error message there. If SetFocus is not use, object cannot be found.
Please describe what you are trying to implement and any information such as application type (WEB vs Desktop),
technologies used in the app, screenshots of the objects in question using Object Spy and/or object browser
- WEB application using IE.
Thanks again
Hi,
Usually, the "unable to find the object" JavaScript/JScript error means that the parent object (e.g. BrowserWindow3) was not identified by TestComplete. If TestComplete has not identified BrowserWindow3 object, then it (TestComplete) does not wrap it with helper functions (and SetFocus() is one of these functions). In this case TestComplete passes BrowserWindow3.SetFocus() expression to JavaScript/JScript runtime as is. JavaScript/JScript runtime tries to resolve SetFocus() according to its regular rules, fails (as such object cannot be resolved indeed) and posts runtime error.
So, on the first place, I would recommend to check in the debugger if BrowserWindow3 object was resolved by TestComplete. This can be done, for example, by checking if BrowserWindow3.Exists equals to true.
Another point that I remember (though it is from an old times and is desktop-application related) is that SetFocus() is applicable for the controls that can be focused (i.e. highlighted with the cursor put in the field).
Windows, on the other hand, could be activated (via BrowserWindow3.Activate() ), but not focused.