Handling issue with Html Text Field
prakash s chauhan 27000140Y5 Visits (5680)
Issue - Rational Functional Tester (RFT) not entering/setting the text in the correct field
It appears like RFT is not able to enter text into a textbox / Edit box .
It appears like the text is getting entered in the wrong field.
It appears like the whole page gets "Selected" ( like Ctrl+A happened on the page) but nothing gets entered.
Setting text in a text/edit field is a three step process.
1. Find the text/edit control.
2.Perform a click so that it gets focus.
3.Enter the text .. this is relative to the top level window and not to the control itself.
Now assuming that step 1 does not have any issue as there is no exception , we might have issue in the step 2 where RFT is supposed to click the control so that focus is set on that control . If that fails then the step 3 may not work correctly ( and behave as mentioned in the 'Symptoms' above ).
There could be various reasons why the step 2 may fail .. one of them being , when RFT performs the click on the text box so that it gets the focus , somehow the focus is stolen back by the previous control with focus or the click happens but somehow the control actually does not get the focus.
So how do we address it?
We can have a utility method as shown below that makes sure that the control has the focus before entering the text into it
textfield - the text/edit control , mapped or found using find.
textToEnter- Text to enter.
Call the above method from the script as
here text_user() and text_pwd() are the user name and password test objects from the Object map . But they can also be the test objects found using the find() api.
In case of objects found through find() api make sure you cast them to TextGuiTestObject.