Ask a Question

SetText over Keys for speed

SOLVED
BMD
Contributor

SetText over Keys for speed

Below is a bit of code that types over 4000 characters into the comment field.  I changed the keys to SetText because it takes too long to type the charterers in to the field.  The SetText I thought would be faster but it does not work at all.  This is using Firefox version 68.5 as the browser and TC is version 14.30.  Any pointers are greatly appreciated.

Thank you, BMD

 

TheString = LOCALBuildThe4000LongString();

var PropNames = ["Name", "idStr", "Visible"];
var PropValues = ["Textarea(\"Comments\")", "Comments", true];
var Comments_TB = Sys.Browser(ProjectSuite.Variables.Browser).Find(PropNames,PropValues,20);

if ( Comments_TB.Exists == true )
{
  Comments_TB.Click();
  Comments_TB.SetText(TheString);
}

 

function LOCALBuildThe4000LongString()
{
  var String1 = "Web testing Automated. ";
  var String = "";
  for (var i=1; i<200; i++)
  {
    String = aqString.Concat(String, String1);
  }
  return String;
}

6 REPLIES 6
Marsha_R
Community Hero

If you're trying to check the size of the comment field, why not just put a 4000 character string in there all at once and try to type one more?  


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
sonya_m
SmartBear Alumni (Retired)

Good thinking Marsha!

 

@BMD Will this approach work for you?


Sonya Mihaljova
Community and Education Specialist

This is exactly what I am doing with the .Keys() function.   It takes too long to type the 4000+ characters into the field.  It types the characters in about 8 times in the comment field on different pages.  The script runs fine but takes about 45 minutes to complete.  I'm looking for ways to refactor the code and speed up the script.  I thought my description about changing from the .Keys to the .SetText function would explain that.  I have use the .Keys and is working but I'm looking to speed the script up by switching to the .SetText function.

Thanks anyway, BMD

BMD
Contributor

Maybe this will help.  The code below ONLY enters 'Keys input'.  The 4000+ long string and 'SetText input' is NOT entered.  The object is found as the .Click and the .Keys work just fine.

 

var PropNames = ["Name", "idStr", "VisibleOnScreen"];
var PropValues = ["Textarea(\"Comments\")", "Comments", true];
var Comments_TB = Sys.Browser(ProjectSuite.Variables.Browser).Find(PropNames,PropValues,20);
if ( Comments_TB.Exists )
{
  Comments_TB.Click();
  Comments_TB.Keys("^a[Del]Keys input");
  Comments_TB.SetText(TheString);
  Comments_TB.SetText("SetText input");
}

BMD
Contributor

So the Test Complete SetText function simply does not work at all.

I changed the code to set the Sys.Clipboard to the 4000+ text string and using the Keys("^a[Del]^v") works fine.

Thank you for trying, BMD

 

Marsha_R
Community Hero

No, what I mean is set a text variable to some string that is 4000 characters long and just insert that into your field.  There is no need to type 4000 characters separately every time.  Insert the 4000 and then use Keys or SetText to try to type one more in and check to see if it worked. 


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
cancel
Showing results for 
Search instead for 
Did you mean: