thaidy
4 years agoOccasional Contributor
TestComplete question
Hello,
I am new into the TestComplete tool and I need to save a value from the screen(p.e 20), and after refresh, the value will be increased by one(p.e 21). What i need is to check that this value was really incremented. The "Valor: 20" is one object of the screen, and i want to check if after the reboot will be "Valor: 21", "22","23","24".... How can I do that?
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 [referenced here]:
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