Forum Discussion

maumrm's avatar
maumrm
Contributor
4 years ago

Inserting Text instead of Keying

I need to be able to verify the maximum characters allowed can be saved into various forms on an online web application. The objects are considered "textarea" are do not allow the SetText method, but the Keying method does work. Some of the fields allow 4,000 characters, when using the Key method for those it takes a long time for the test to Key in 4,000 characters. Is there a faster way of inserting/pasting/setting the text contained in the variable into these fields w/o the automated test keying in 4,000 characters?

 

I saw this post which implied that the text from a variable could be inserted, but did not really state how to do that.

https://community.smartbear.com/t5/TestComplete-Functional-Web/SetText-over-Keys-for-speed/m-p/209067#M37124

6 Replies

  • Marsha_R's avatar
    Marsha_R
    Champion Level 3

    Here's how you do it from a variable, but if you are restricted to Keys, then it will still take a lot of time because Keys is meant to simulate a person typing.

     

    Create a variable to hold your max characters

    Use that variable as the input for Keys

     

    • tphillips's avatar
      tphillips
      Frequent Contributor

      Can you directly set the .text or .wText (or similar) property for the textarea? Rather than using a SetText() or Keys() method?

      • maumrm's avatar
        maumrm
        Contributor

        Hi tphillips - this is what I am wondering, I am not sure how this could be done. it would be nice to be able to take a variable which stores the 4000 character text string and use that to set the property for innertext, textContent.

    • maumrm's avatar
      maumrm
      Contributor

      Thanks 

  • AlexKaras's avatar
    AlexKaras
    Champion Level 3

    Hi,

     

     a [...] way of inserting/pasting [...] the text

    You almost answered your own question.

    Something like this (pseudocode):

    var strText = '<generated string of 4000 chars in length>';

    var testedObj = ...; // get a reference to the required object

    Sys.Clipboard = strText;

    testedObj.Keys('^V'); // Ctrl-V to paste the content of the clipboard into the field

     

    • maumrm's avatar
      maumrm
      Contributor