I have to create multiple users/logins and the software I’m testing doesn’t allow duplicates. How can achieve that by using the Record and Play functionality?

As part of my regression testing I want to create multiple users/logins however the software I’m testing doesn’t allow duplicates, so as soon I have recorded the action of creating an user when trying to play back the test I’m getting a validation message due to the username already been used

Hi,

You will need some little tricks in using the unique username in your case. Just need to add a generation step for the username’s variable and it will be unique in every step.

Example:

import static com.kms.katalon.core.checkpoint.CheckpointFactory.findCheckpoint
import static com.kms.katalon.core.testcase.TestCaseFactory.findTestCase
import static com.kms.katalon.core.testdata.TestDataFactory.findTestData
import static com.kms.katalon.core.testobject.ObjectRepository.findTestObject
import com.kms.katalon.core.checkpoint.Checkpoint as Checkpoint
import com.kms.katalon.core.checkpoint.CheckpointFactory as CheckpointFactory
import com.kms.katalon.core.mobile.keyword.MobileBuiltInKeywords as MobileBuiltInKeywords
import com.kms.katalon.core.mobile.keyword.MobileBuiltInKeywords as Mobile
import com.kms.katalon.core.model.FailureHandling as FailureHandling
import com.kms.katalon.core.testcase.TestCase as TestCase
import com.kms.katalon.core.testcase.TestCaseFactory as TestCaseFactory
import com.kms.katalon.core.testdata.TestData as TestData
import com.kms.katalon.core.testdata.TestDataFactory as TestDataFactory
import com.kms.katalon.core.testobject.ObjectRepository as ObjectRepository
import com.kms.katalon.core.testobject.TestObject as TestObject
import com.kms.katalon.core.webservice.keyword.WSBuiltInKeywords as WSBuiltInKeywords
import com.kms.katalon.core.webservice.keyword.WSBuiltInKeywords as WS
import com.kms.katalon.core.webui.keyword.WebUiBuiltInKeywords as WebUiBuiltInKeywords
import com.kms.katalon.core.webui.keyword.WebUiBuiltInKeywords as WebUI
import internal.GlobalVariable as GlobalVariable
import org.apache.commons.lang.RandomStringUtils

‘Max length of generated string’
randomStringLength = 5

String charset = ((‘a’…‘z’) + (‘A’…‘Z’) + (‘0’…‘9’)).join()
String randomString = RandomStringUtils.random(randomStringLength, charset.toCharArray())
userName = userName + randomString

WebUI.openBrowser(GlobalVariable.G_SiteURL)
WebUI.setText(findTestObject(‘Page_Login/txt_UserName’), Username)
WebUI.closeBrowser()

P/s: In the further case that you need to execute test suite on multiple dataset, it’s best to use data-driven feature of the test suite:

https://docs.katalon.com/display/KD/Data+for+Test+Execution