Ask a Question

Inserting Text instead of Keying

maumrm
Contributor

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/20906...

6 REPLIES 6
Marsha_R
Community Hero

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

Marsha_R_0-1609980281971.png

Use that variable as the input for Keys

Marsha_R_1-1609980547952.png

 


Marsha_R
[Community Hero]
____
[Community Heroes] are not employed by SmartBear Software but
are just volunteers who have some experience with the tools by SmartBear Software
and a desire to help others. Posts made by [Community Heroes]
may differ from the official policies of SmartBear Software and should be treated
as the own private opinion of their authors and under no circumstances as an
official answer from SmartBear Software.
The [Community Hero] signature is used with permission by SmartBear Software.
https://community.smartbear.com/t5/custom/page/page-id/hall-of-fame
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?


--------------------
Senior SQA Automation Engineer

Thanks 

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.

AlexKaras
Community Hero

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

 

Regards,
  /Alex [Community Hero]
____
[Community Heroes] are not employed by SmartBear Software but
are just volunteers who have some experience with the tools by SmartBear Software
and a desire to help others. Posts made by [Community Heroes]
may differ from the official policies of SmartBear Software and should be treated
as the own private opinion of their authors and under no circumstances as an
official answer from SmartBear Software.
The [Community Hero] signature is used with permission by SmartBear Software.
https://community.smartbear.com/t5/custom/page/page-id/hall-of-fame
================================

 

 

cancel
Showing results for 
Search instead for 
Did you mean: