Want to create unique name to test creating account

I want to create a unique name something like 'Krista' + 1, 2, 3... and have the first execution do Krista1 and then Krista2 and so on. I currently have written this:

class CreateName {
	private String name;
	private int number;
	private String uniquename;
	
	public CreateName(String name, Integer number) {
		this.name = name;
		this.number = number;
		this.uniquename = this.name + Integer.toString(this.number);
	}
	public String getUniqueName() {
		return this.uniquename;
	}
}

newName = new CreateName("Krista", 1)

and then in the process of executing the test I do this:

WebUI.setText(findTestObject('Page_XXX.com/input_Name_txtName'), newName)

I cannot get it to work and I am confused as to why, I am quite new to Katalon as well as quite new to Java, my main experience is in JS.

Thank you!

I edited your post so that the code is easier to read. Edit it yourself to see how I did that.

Did you get an error message? Please post it. Read this for advice.

Did you import the package/class before using it in the test case?

1 Like
10-25-2019 01:50:17 PM Test Cases/Create Client Account

Elapsed time: 17.506s

Test Cases/Create Client Account FAILED.
Reason:
groovy.lang.MissingMethodException: No signature of method: static com.kms.katalon.core.webui.keyword.WebUiBuiltInKeywords.setText() is applicable for argument types: (com.kms.katalon.core.testobject.TestObject, CreateName) values: [TestObject - 'Object Repository/Page_XXX/input_Name_txtName', ...]
Possible solutions: setText(com.kms.katalon.core.testobject.TestObject, java.lang.String), getText(com.kms.katalon.core.testobject.TestObject), getText(com.kms.katalon.core.testobject.TestObject, com.kms.katalon.core.model.FailureHandling), setText(com.kms.katalon.core.testobject.TestObject, java.lang.String, com.kms.katalon.core.model.FailureHandling), clearText(com.kms.katalon.core.testobject.TestObject), clearText(com.kms.katalon.core.testobject.TestObject, com.kms.katalon.core.model.FailureHandling)
	at Create Client Account.run(Create Client Account:46)
	at com.kms.katalon.core.main.ScriptEngine.run(ScriptEngine.java:194)
	at com.kms.katalon.core.main.ScriptEngine.runScriptAsRawText(ScriptEngine.java:119)
	at com.kms.katalon.core.main.TestCaseExecutor.runScript(TestCaseExecutor.java:337)
	at com.kms.katalon.core.main.TestCaseExecutor.doExecute(TestCaseExecutor.java:328)
	at com.kms.katalon.core.main.TestCaseExecutor.processExecutionPhase(TestCaseExecutor.java:307)
	at com.kms.katalon.core.main.TestCaseExecutor.accessMainPhase(TestCaseExecutor.java:299)
	at com.kms.katalon.core.main.TestCaseExecutor.execute(TestCaseExecutor.java:233)
	at com.kms.katalon.core.main.TestCaseMain.runTestCase(TestCaseMain.java:114)
	at com.kms.katalon.core.main.TestCaseMain.runTestCase(TestCaseMain.java:105)
	at com.kms.katalon.core.main.TestCaseMain$runTestCase$0.call(Unknown Source)
	at TempTestCase1572025815752.run(TempTestCase1572025815752.groovy:23)

This is the error I got. Which I think means it did not generate a name and therefore did not input one. What I did was record the test and then I went back to create this unique name. So all of the imports are the ones that were automatically added at the time of recording.

P.S. thank you for the edit! And also, I am reading the document you linked and will provide more information, thank you for that as well

1 Like

That sets newName to an instance of the class CreateName. I think you want this, instead:

newName = new CreateName("Krista", 1).getUniqueName()
1 Like

Yes!! This worked!!

Thank you so much!! and for being patient with me, like I said, I am very new to all of this!

1 Like