How to get value of input field in form


I have a form that have filled input fields in it. And I want to get this values from this input fields to compare it between the start variables. How can I do this? The sapmle of input fields in screenshot

2.png

hey someone can help me with this problem?

Use WebUI.getAttribute(testObject, “value”) method. It should be stored in value attribute.

2 Likes

thanks, Marek, it works

hello, you can also use
if( webui.getText(object) == ‘desired value’)
{
}

Can I take the value from the previous line and pass to the next input and add a number to it?

Sorry for my english)

Hy marek,

I’m working on mobile app automation testing and i’m facing the same issue could you please advise me and my field is dateStamp variable.

kindly help me capture dynamic value from verification code textbox and pass it to next input textbox…see attachedlogin

@emmanuhkipngetich Without the actual HTML, I can only assume.
You can try:
WebUI.setText(findTestObject(‘Lower Enter Verification Code path’),WebUI.getAttribute(findTestObject(‘Upper Verification code path’), “value”))

or you can do it in two steps:
def str = WebUI.getAttribute(findTestObject(‘Upper Verification code path’), “value”)
WebUI.setText(findTestObject(‘Lower Enter Verification Code path’), str)

If you look at the HTML code of the Upper Verification Code element, you will be able to see if the “value” attribute has the 3607 inside; like value=“3607”. So what the above does is get the contents of the “value” attribute and puts it into the “Lower Enter Verification Code” box.

testcase did not run successful ,
it is returning a null

07-03-2020 10:31:48 AM Test Cases/01 Login functionalities/01 verify whether a user can log in

Elapsed time: 55.650s

Test Cases/01 Login functionalities/01 verify whether a user can log in FAILED.
Reason:
com.kms.katalon.core.exception.StepFailedException: Unable to set text ‘null’ of object ‘Object Repository/01 log in functionalities/Page_Co-operative Bank of Kenya Coop/Page_Co-operative Bank of Kenya Coop/input_Verification code_captcha’
at com.kms.katalon.core.webui.keyword.internal.WebUIKeywordMain.stepFailed(WebUIKeywordMain.groovy:64)
at com.kms.katalon.core.webui.keyword.internal.WebUIKeywordMain.runKeyword(WebUIKeywordMain.groovy:26)
at com.kms.katalon.core.webui.keyword.builtin.SetTextKeyword.setText(SetTextKeyword.groovy:66)
at com.kms.katalon.core.webui.keyword.builtin.SetTextKeyword.execute(SetTextKeyword.groovy:37)
at com.kms.katalon.core.keyword.internal.KeywordExecutor.executeKeywordForPlatform(KeywordExecutor.groovy:72)
at com.kms.katalon.core.webui.keyword.WebUiBuiltInKeywords.setText(WebUiBuiltInKeywords.groovy:976)
at com.kms.katalon.core.webui.keyword.WebUiBuiltInKeywords$setText$1.call(Unknown Source)
at 01 verify whether a user can log in.run(01 verify whether a user can log in:33)
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 TempTestCase1593761496768.run(TempTestCase1593761496768.groovy:25)
Caused by: java.lang.IllegalArgumentException: Text is null
at com.kms.katalon.core.webui.keyword.builtin.SetTextKeyword$_setText_closure1.doCall(SetTextKeyword.groovy:48)
at com.kms.katalon.core.webui.keyword.builtin.SetTextKeyword$_setText_closure1.call(SetTextKeyword.groovy)
at com.kms.katalon.core.webui.keyword.internal.WebUIKeywordMain.runKeyword(WebUIKeywordMain.groovy:20)
… 17 more

Also the object itself is dynamic, so it cannot retrieve a value from it since it is different during runtime

Get Text Input Field Value in JavaScript <input type="text" placeholder="Type something..." ... Get Value function getInputValue(){ // Selecting the input element and get its value. var inputVal = document. ... // Displaying the value.

this one works for me
"or you can do it in two steps:
def str = WebUI.getAttribute(findTestObject(‘Upper Verification code path’), “value”)
WebUI.setText(findTestObject(‘Lower Enter Verification Code path’), str )

If you look at the HTML code of the Upper Verification Code element, you will be able to see if the “value” attribute has the 3607 inside; like value=“3607”. So what the above does is get the contents of the “value” attribute and puts it into the “Lower Enter Verification Code” box.
[/quote]"

but its cannot proceed using next buttonnext

@emmanuhkipngetich Again, you haven’t shown any HTML code so that we can be more helpful, however, (again I’m assuming):

I assume the Next element is a button. Perhaps just use text()=“Next” as the means to locate the element.
//button[ text()=“Next”]

Then
WebUI.click(findTestObject(‘myPage/button_Next’))

or you can try:

WebUI.enhancedClick(findTestObject(‘myPage/button_Next’))

I have use WebUI.submit instead of WebUI.click worked