Set text not removing previous value

Hi

When I use set text on a text box where there is a value in it, it doesn’t remove the previous value. Instead it types it in after. For example if the text box has the value 0,00 and I want to change it to 1,00 it becomes 0,001,00.

i don’t know if this is by design or not, but i’ve been using my own keyword whenever i want to write text to a field, which has been doing exactly what i wanted. first i use the built-in method to clear a field, then i use ctrl+a to select all the text in said field in case the clear failed for some reasons, and then i send the keys i wanted to write, which, combined with the first two functions, will fill in the field with only the text you want

import com.kms.katalon.core.webui.keyword.WebUiBuiltInKeywords as WebUI
import com.kms.katalon.core.testobject.TestObject
import org.openqa.selenium.Keys

public void enterText(TestObject to, String text) {
		WebUI.clearText(to)
		WebUI.sendKeys(to, Keys.chord(Keys.CONTROL, 'a'));
		WebUI.sendKeys(to, text);
	}
1 Like

Hi. How do you setup your custom keywords? When I try using the guide that Katalon has I set it up like this. But that is probably wrong because I get this error when running it
public class textthing {

@Keyword
def	public void enterText(TestObject to, String text) {
		WebUI.clearText(to)
		WebUI.sendKeys(to, Keys.chord(Keys.CONTROL, 'a'));
		WebUI.sendKeys(to, text);
	}

}

2022-08-03 13:10:16.401 ERROR c.k.katalon.core.main.TestCaseExecutor - :x: Test Cases/create measure FAILED.
Reason:
groovy.lang.MissingPropertyException: No such property: Keys for class: keywords2.textthing
at keywords2.textthing.enterText(textthing.groovy:28)
at keywords2.textthing.invokeMethod(textthing.groovy)
at com.kms.katalon.core.main.CustomKeywordDelegatingMetaClass.invokeStaticMethod(CustomKeywordDelegatingMetaClass.java:50)
at create measure.run(create measure:45)
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:445)
at com.kms.katalon.core.main.TestCaseExecutor.doExecute(TestCaseExecutor.java:436)
at com.kms.katalon.core.main.TestCaseExecutor.processExecutionPhase(TestCaseExecutor.java:415)
at com.kms.katalon.core.main.TestCaseExecutor.accessMainPhase(TestCaseExecutor.java:407)
at com.kms.katalon.core.main.TestCaseExecutor.execute(TestCaseExecutor.java:284)
at com.kms.katalon.core.main.TestCaseMain.runTestCase(TestCaseMain.java:142)
at com.kms.katalon.core.main.TestCaseMain.runTestCase(TestCaseMain.java:133)
at com.kms.katalon.core.main.TestCaseMain$runTestCase$0.call(Unknown Source)
at TempTestCase1659524968816.run(TempTestCase1659524968816.groovy:25)

that’s on me, i neglected to mention you need to import the selenium Keys class
import org.openqa.selenium.Keys
i have edited my original response to include the import statement for future reference

1 Like

Thank you :+1:

1 Like

Wow guys, thank you for the prompt contribution! :heart_eyes: