I have the following code. The datatable value is USA, which is the 25th item in the WinComboBox (index = 24). Taiwan is the 24th item (index = 23).
When I run this code, what I observe is that first Taiwan is selected in the WinComboBox, which causes my application to popup an error message that my shipping method is invalid for the selected market. After a few seconds, the popup error is closed and then USA is selected in the WinComboBox.
When I step through the code, only USA is selected (which is exactly what should happen). If I slow down the script to watch it as it runs on its own (not stepping), I can see it iterate through this loop until i=24 (in the watch list) at which time the pointer stops on the .Select i line, then the above behavior (Taiwan, close the popup, USA) all occurs before QTP moves to the next line of code. The value of i never changes while the two different selections are made, and the script definitely does not flow through another iteration (I slowed it down with "wait 10" statements between every line of the code so I could watch where the pointer sat while things were happening).
Also note that while it goes through the first 23 iterations of the loop, nothing happens in the WinComboBox at all - in other words, it doesn't select Australia, Bermuda, Canada, etc - it only selcts Taiwan then USA.
I do not understand how this is possible.
How can one single line of code make two selections with different index values when the index doesn't change?
Anyone have any thoughts?
var_GetItemsCount = Window("Order Entry").WinComboBox("Country").GetItemsCount()
For i = 0 to var_GetItemsCount - 1
var_GetItem = Window("Order Entry").WinComboBox("Country").GetItem(i)
If var_GetItem = DataTable("Market", dtlocalSheet) Then
Window("Order Entry").WinComboBox("Country").Select i
Note: One thing I did to debug this was to hard code the index but the same exact thing I described above still happened: