Forum Discussion

rwestbury's avatar
rwestbury
Contributor
13 years ago

Testing Tab Order

Hello all,



I have searched extensively to find a thread discussing how to use TC to test (or just log for now) Tab Order. The most intuitive way to do this would be to write a script that presses Tab, then grabs the currently focussed or active control and logs whatever information we want about that control. By repeating the process of tabbing and finding the currently focussed control we can log the "Tab Order".



Is there no easy way to do this? I have experimented with the zDocument.activeElement, however, this doesn't not give you a reference to the actual TC object that you can perform additional tasks with, such as Sys.HighlightObject, or Log.Picture.



Thanks,

Robert.

4 Replies

  • irina_lukina's avatar
    irina_lukina
    Super Contributor

    Hi Robert,


    Have you tried the following approach?



    var focusedControlUniqueID = page.zDocument.activeElement.uniqueID;

    var focusedObject = page.NativeWebObject.Find("uniqueID_value", focusedControlUniqueID)


    Does the returned object provide you with the needed properties?

  • Hi Irina,



    That worked like a charm! That did exactly what I wanted it to do! Thanks a lot!



    Robert

  • Just to clarify with anyone who might see this thread, there was 1 typo in the solution... the working code is:



    var focusedControlUniqueID = page.zDocument.activeElement.uniqueID;

    var focusedObject = page.NativeWebObject.Find("uniqueID", focusedControlUniqueID)



    OR if you want a 1 liner:

    var focusedObject = page.NativeWebObject.Find("uniqueID", page.zDocument.activeElement.uniqueID)