Monday 17 February 2014

Handling AutoComplete Text box using TestComplete

Hi,

Handling auto complete text boxes using TestComplete is little tricky, where you will have to try few combination of keys and simulate key press events.
Recently, I came across one such scenario and here is the solution for the same:

As shown above, the highlighted text field was the autoComplete , text box that gets loaded with a default value.
My purpose was to remove the existing item in the text box and to simulate user actions of entering data in to the text field.
While, using "obj.value" or "obj.setText()" methods to set value in the text box were not helpful. Because, the page did not get refreshed automatically and the expected fields didn't appear.


I had tried the Obj.Keys method as shown below, with which page got refreshed automatically, assuming user has input the data, loading the expected fields.

1) grid.Cell(1, 1).Textbox("txtAlphaCode").DblClick();  // this is to double click on the textbox to clear the                                                                                           default value      
2)  grid.Cell(1, 1).Textbox("txtAlphaCode").Keys("[Del]"); // this is siumlation of hitting delete button
3)  grid.Cell(1, 1).Textbox("txtAlphaCode").Keys(policyData.Value("alphaCode")); // this is simulation of                                                                                                                                         user input

That's it!!

Now, the simulation of user input for autoComplete text box is done :-)

Leave your comments/doubts on scenarios that you think, I may help!!

No comments:

Post a Comment