Forum Discussion

vcheung's avatar
vcheung
Occasional Contributor
13 years ago

having problems inserting text into textboxes with helper text when not focused

I'm currently having some problems automating a textbox's ["Keys"] action for a textbox with javascript to display helper text when it's not focused. The problem I have is as follows:



env info: 



I have a textbox that, when not focused, displays a helper text. By default it is not focused. I'm currently using a trial TestComplete V9





problem:



1. when I use ["FindChild"] to locate the textbox (not focused), using ["Keys"] did not insert into the textbox

2. when I use ["focus"] on the text label to put the textbox in focus, and then try to use "Keys" right after, it still did not insert into the text box





my question:



What is the general best practice in terms of focusing a textbox and then using ["Keys"] to type in data?
  • vajindarladdad's avatar
    vajindarladdad
    Frequent Contributor
    Hi Vincent,

    First , get the object focused with the "Focus" method/property then insert the text using "setText"/"Text" method/property.



    Just a question ..

    As you said ... you are using findChild method .. what type of object does the "findChild" returns ? Did you investigate on it ..using "Ctrl+F12"...



    I would recommend you to debug it ... and crosscheck again.



    I hope this has been of some help.
  • Answer below to your query:



    code snippet:



    function FindChild()

    {

     var TestObj =  Sys.WinFormsObject("XYZ");

    var ChildObj =  TestObj.FindChild(Array("ObjectType","ObjectIdentifier"),Array("Textbox","TextboxID" ),1);

    ChildObj.SetFocus();



    -----;

    ChildObj.SetText("Kumar");  (OR) ChildObj.Keys("Kumar");

    ------------------;



    Regards,

    Kumar



    }