Forum Discussion
- CBleunvenContributorHi Maxime,
I think you can parse the _NewEnum property of your Window (and recursively the subWindows) in order to find the Object for which the "Focused" property is true.
Regards,
Christophe - maxthomassinOccasional ContributorThank you for the answer Christophe.
Im testing on website (on IE). Im using TC 7 and we are going to switch to the lastest version soon.
I dont see the property focused in the property list. - dganovStaffTry to use document.activeElement property. It will return the native web object, so it will not have TestComplete specific properties and methods.
- maxthomassinOccasional ContributorIs there a way to tranform it into the TC Object? Cause i need to insert text or do a click on the item. I tried to get the name of the item, but its not always working.
Does it only work on item that have the property onFocus != null ? - dganovStaffTry to find some property of focused object that you can use to find corresponding TestComplete's object using Page.NativeWebObject.Find or FindChild method.
I believe that activeElement is not related to onFocus. - maxthomassinOccasional Contributor
- dganovStaffIt seems that actually some other page element has focus, maybe it is the parent of the element with id proprieteVide288. Or in the worst case this property is not what you are looking for.
You can set breakpoint at the line Log.Message(item.id) and inspect the item variable. Take a look at its nodeName, outerHTML properties and I think you will get the key to this issue. - CBleunvenContributorHi Maxime,
Sorry for my late come back, I didn't pay attention that Object on a Page doesn't have the OnFocus property (I work on an application).
It's quite difficult to find some properties with specific values when the object is focused, because, when you open the Object Spy, the Object of interest lost the focus...
So you need in your script to capture the value of the different properties.
A workaround is possible if you have at the beginning of the test, a list of the different elements you will meet. You may previously add a method to the onfocus event of each element.
var theFocusedElement;
MyElementA["onFocus"] = function() {
Log["Message"]("Element A receives focus.");
theFocusedElement = MyElementA;
}
MyElementB["onFocus"] = function() {
Log["Message"]("Element B receives focus.");
theFocusedElement = MyElementB;
}
etc...
The "problem" is that you modify your element under test...
regards,
Christophe
Related Content
- 12 years ago
Recent Discussions
- 17 hours ago
- 18 hours ago
- 4 days ago