We are building a new experience for our SmartBear Community.
This site is now read-only. You can still browse and search as usual. Learn More
This site is now read-only. You can still browse and search as usual. Learn More
I am using javascript, but the logic is the same - you could try to get the length of the string, then obtain a random starting point between 1 and the length of your string (*minus 6, so it won't grab less than 6 characters) and use it in the aqString.SubString method https://support.smartbear.com/testcomplete/docs/reference/program-objects/aqstring/substring.html:
function getRandomString() {
var string = "ABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890abcdefghijklmnopqrstuvwxyz";
var strCount = aqString.GetLength(string); // length of string
var strMax = strCount - 6; // strCount - 6 >> so it doesn't grab less than 6 characters
var randoStart = Math.round(Math.random()*(strMax - 1) + 1); // random # between 1 and strMax
var randoStr = aqString.SubString(string, randoStart, 6)
Log.Message(randoStr);
return randoStr;
}
function test() {
getRandomString(); // 1
getRandomString(); // 2
getRandomString(); // 3
}
Output:
You can use the TestComplete string generator
try one of these
https://support.smartbear.com/testcomplete/docs/testing-with/data-driven/generators/types/string.html
https://support.smartbear.com/testcomplete/docs/testing-with/data-driven/generators/types/custom-string/about.html
Thank you so much 8Kit and Marsha_R Both the codes worked for me .
I have worked with 8Kit code I was able to generate the sting from the position of a Random string. It was not able to pick random keys from the given text.
for example: I have the text as : 'ABCDEFGH1234556789'
if random value is 6
then its picking the text from 6th position of the above string upto the given length of 4 as (FGH1).
further more my intention is to generate any random keys from the above text.
for example if selct the length of the string as 4 it should pick any random keys from the given text as:
P324 or 1567 or AHDF