Forum Discussion
Hi,
I am having the same issue now, the object got focus and the test is running fine but the error message says "Unable to find the object SetFocus. "
When using SetFocus() with window(code below), there is no error message.
Aliases.browser.BrowserWindow3.SetFocus();
Here is my code, I have tried the solution mentioned in this post. The delay doesn't work, and FullName is the name of the object that got focused. How do I disable the error message??
aqUtils.Delay (2000, "delay to click");
globalObjects.chooseAfile.SetFocus();
Log.Message(Sys.Desktop.FocusedWindow().FullName);
roytberA wrote:
Hi,
I am having the same issue now, the object got focus and the test is running fine but the error message says "Unable to find the object SetFocus. "
When using SetFocus() with window(code below), there is no error message.
Aliases.browser.BrowserWindow3.SetFocus();
Here is my code, I have tried the solution mentioned in this post. The delay doesn't work, and FullName is the name of the object that got focused. How do I disable the error message??
aqUtils.Delay (2000, "delay to click");
globalObjects.chooseAfile.SetFocus();
Log.Message(Sys.Desktop.FocusedWindow().FullName);
Note that the OP is a different general source of the issue and is also 4 years old. There have been numerous updates to TestComplete since then as well as different ways of handling things. The original post is in a desktop application where as your situation seems to involve web applications.
I have a question concerning your post... you are trying to set focus on the browser window instead of some component or page within your web application. What are you intending to achieve? 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, etc.
- roytberA7 years agoOccasional Contributor
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
- AlexKaras7 years agoChampion Level 3
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.
- tristaanogre7 years agoEsteemed Contributor
So, I guess the next question is... why do you need to call the "SetFocus" method in the first place? What part of your test automation are you trying to implement? For the most part, I've found very little need for using "SetFocus" on a regular basis. It's only very rare situations that I've needed to do so.
for that matter, SetFocus is not a valid method for Web components... hence the behavior you're experiencing is correct. Web components on a web application will not have the "SetFocus" method. BrowserWindow, because it's not a web component but a "Window" component of the browser application, has the "SetFocus" method.
So... back to the question: What are you actually trying to do that you are trying to achieve by using "SetFocus? Have you tried simply sending a "Click" command to the component in question so that it is active and has focus?
- roytberA7 years agoOccasional Contributor
I agree with you, this is my first time using SetFocus. I've been using TC for 6 months. I am trying to click on an object that is on a different page from the previous action(click ok on popup window). And I had tried Click(), DblClick(), and Focus() follow with Click(), they did not work. Message from test log says "There was an attempt to perform an action at a point, which is beyond the screen." but the object is there and it is visible on screen. Basically, TC can not find any object on that page so I though maybe it still focus on the popup window.
So I searched for something that would help and came across SetFocus(), and it works but there is error in test log. But, there is no error
Related Content
Recent Discussions
Check PopupMenu exists
Solved4 days agomfoster711