by JSH_QA » Thu Nov 20, 2014 8:29 pm
We saw another example of this today, with a related, but slightly different scenario.
The scenario seen today is as follows:
The application under test (AUT) contains an edit box
As the user types into the edit box, the application tries to implement auto-complete. When it finds one or more matches, it drops down a list box containing the matches, then a fraction of a second later, it updates the edit box to contain the text typed so far followed by the remaining characters from the first matching entry, but with those characters selected and with the caret still in its original place at the end of the text actually typed into the edit box (so before the selected text).
In this, there appear to be two pieces of asynchronous code, the first dropping down the list box, the second appending selected text to the edit box and resetting the caret position.
What the automation was trying to do, was to type text into the edit box, then when the dropdown list appears, to move the mouse pointer (over a non-zero time period, I think 300ms) to the first entry in the dropdown list, and then left-click on it.
What is seen to happen is that the text is typed and the mouse pointer moves to the first entry, but then the mouse pointer moves to the top left of the window.
What seems to be happening is that the ListItem's Adapter is obtained for the first entry in the dropdown list, but somewhere in the asynchronous behaviour of the application under test, by the time the Click operation is called, the ListItem is no longer enabled/valid (the asynchronous resetting of the caret position would appear to trigger this change). At this point, presumably when the Click method is called, the mouse moves to the top left of the window.
We worked around this quite easily, but with asynchronous behaviour in applications under test, it is something we have to watch out for. Basically, between the point where you get an Adapter/Element for a control in your AUT and the point where you subsequently Click on it, asynchronous behaviour in the AUT may have invalidated the Adapter/Element.