Continue to record web option no longer works when you add in Scripts


#1

Hi,

I had a requirement to generate first name and last name randomly in my Test case. There was an example online using the Scripts section for a test case. It seems to work correctly when just running the test case but when I try and continue recording from it it produces an error.

script contains

String sFirstName = ‘’
String sLastName = ‘’
String chars = ‘abcdefghijklmnopqrstuvwxyz0123456789’
sLastName = (‘test ’ + randomString(chars, 5))
sFirstName = (‘Sone ’ + randomString(chars, 1))
WebUI.openBrowser(’’)…

WebUI.click(findTestObject(‘Main Page/a_Save’))
static String randomString(String chars, int length) {
Random rand = new Random()
StringBuilder sb = new StringBuilder()
for (int i = 0; i < length; i++) {
sb.append(chars.charAt(rand.nextInt(chars.length())))
}
return sb.toString()
}

Is Scripts a good area for me to be adding in random name generation code?

Thanks