Forum Discussion

rjking's avatar
rjking
New Contributor
13 years ago

ClickItem versus Keys under Windows XP

We have a Delphi application that we run many hundreds of test on.  There is one combobox on one form that has 5 items that we need to select from.  The items are Minimum, Minus 1 Std Dev, Average, Plus 1 Std Dev and Maximum.



The test script sets the desired combobox value using a .Keys("xxxxxx") statement.



This script worked fine under Windows 2000.  Under Windows XP however, the wrong item is selected in the combobox (eg Minus 1 Std Dev might be selected when Minimum should have been selected) .  Now that we have changed the script to do a .ClickItem("xxxxx") all tests work correctly.



Is there a bug in TestExecute 8.5 Keys statement under Windows XP?  Has anyone else experienced similar issues?



We will be testing TestExecute under Windows 7 when we get a chance, but TestComplete had no problems using the .Keys statement (or the ClickItem statement) to select the correct combobox item under Windows 7.



(The reason we used .Keys rather than .ClickItem is that we have found .Keys to be faster as it does not cause the combobox to drop down the list of items.  However, it is better that it work slower and correctly, than faster but wrongly.  See another thread I am about to enter about the speed of XP versus W2K)



We are running Test Complete/Execute 8.50.

3 Replies

  • tristaanogre's avatar
    tristaanogre
    Esteemed Contributor
    Your answer comes down to what keyboard actions do to a combo box OUTSIDE of a scripting environment.  When you start typing in a combo box, it automatically selects the first item based upon what you're typing.  It's possible that Windows 2000 combo boxes do a continuous search on the box while typing while Windows XP may just select the first one.  Have you tried doing this manually to see what the behaviour is manually?



    In any case, IMO,  "keys" to select from a combo box does not actually interact with the box the way most users would anyways.  So, ClickItem is more accurate in reproducing a users actions with the component.
  • rjking's avatar
    rjking
    New Contributor
    Thanks for the help.



    Yes we have performed the tests manually and under XP the correct entry is selected.  I know there is a short timeout that you need to keep ahead of when typing manually, and it is easy to mistype or hesitate and the wrong entry is selected.  Manually typing and TestComplete/Execute's "typing" are clearly different "under the hood" and this must somehow account for the difference.  We are happy to use ClickItem when this issue arises in our tests.



    Interestingly, I had also previously tried putting the .Keys in a loop checking that the correct item was selected, ie



    while combobox.Text != "<desired_item_text>" {

       combobox.Keys("<desired_item_text>");

    }



    but this just got stuck in an infinite loop!



    Richard
  • AlexeyK's avatar
    AlexeyK
    SmartBear Alumni (Retired)

    Richard,


    I'd agree with Robert and recommend using ClickItem rather than Keys. The fact is that behavior of some controls can differ a little on different operating systems. For example, the control can process Windows messages at a slighly different speed on different systems. If the "typing" is too fast for it, the control may fail to select the appropriate item.


    To check if this is your case, you can slow the keys simulation a little in your tests. You can do this by setting a non-zero value (say, 50, 70 or 100 ms) to the "Key pressing delay" project property. It specifies the delay between keystrokes. To find the property, double-click the project node in the Project Explorer, then in the project editor, switch to the Properties tab and then to the Playback group.