Forum Discussion

mima_vasiljevic's avatar
mima_vasiljevic
Occasional Contributor
10 years ago

Failed to enter a string into textbox


In WPF application I have two text box fields -  first field property is a isReadOnly=False and second textbox has property isReadOnly=True. While recording a keyword tests in first field I enter some string, leave second as it is and then I hit save button.



When I try to replay that test texbox where it needs to be typed that string has been skipped and the value tried to enter that other field which  property is isReadOnly=true. Test fails with explanation " Failed to enter text in edit box,since it is a read only".



Seems like ID's of those text fields are dynamic. Do you have any idea what to do with that.



Please help, I'm stuck and desperate :(


  • Haven't used keyword tests in years but try the following:

    In your keyword test when you "Select object" make sure you select the entire form NOT the text box it's self.

    1. Click next, then add property name "ReadOnly" value "false".
    2. Add a second property like "Name" and "*thenameofyourtextbox*" (with * wild cards).
    3. Click next and select the Keys method (if you make it to this point it found an object)
    4. Enter the value you want to key in
    5. Click Finish
  • Ryan_Moran's avatar
    Ryan_Moran
    Valued Contributor
    Haven't used keyword tests in years but try the following:

    In your keyword test when you "Select object" make sure you select the entire form NOT the text box it's self.

    1. Click next, then add property name "ReadOnly" value "false".
    2. Add a second property like "Name" and "*thenameofyourtextbox*" (with * wild cards).
    3. Click next and select the Keys method (if you make it to this point it found an object)
    4. Enter the value you want to key in
    5. Click Finish
  • mima_vasiljevic's avatar
    mima_vasiljevic
    Occasional Contributor


    Hey Ryan, it seems like it is working,THANK YOU a lot! Now it recognises the field properly!



    So for others havng this problem in future:



    - Use Find Object in Keywordtests, select whole form containing that field (if you could use just form without that other textbox field it could be even faster), set class name and isReadOnly = False property, also dynamic field needed to be either with wildcards or moved under most stable parent (with extended find), and used method Keys (setText didnt work for whatever reason it is)


  • Ryan_Moran's avatar
    Ryan_Moran
    Valued Contributor
    Assuming there are no other unique properties to these text box objects in your WPF application you could work around the issue by using .Find or .FindAll methods and specifying ReadOnly = false in the parameters.



    JS Example:




    var arProperties = ["ReadOnly","Name"];//or some other property besides Name


    var arValues = [false,"*myTextBoxName*"];


    var myTextBox = myFormParentObject.Find(arProperties,arValues,true,5000);

    myTextBox.Keys("somekeysiwanttotype");

  • mima_vasiljevic's avatar
    mima_vasiljevic
    Occasional Contributor


    Hi Ryan and thank you for giving me some tips!



    Yeah, all other properties are same ,execpt for isReadOnly. So I tried with your example (but in keyword test, since I'm not so familiar still with coding stuff etc).



    In FindObject I entered a textbox class name property and isReadOnly=false property. It didnt found any methods under it, so I guessed that some other stuff is going on - I got an error message Alias. ... .parentObject of textbox cannot be found.



    What to do with that...?? Do you have any idea?