# How to get the default value of input field

**URL:** <https://forum.katalon.com/t/how-to-get-the-default-value-of-input-field/59235>\
**Category:** Web Testing\
**Tags:** katalon-studio\
**Created:** [October 16, 2021, 4:33am UTC](https://forum.katalon.com/t/how-to-get-the-default-value-of-input-field/59235 "2021-10-16T04:33:47Z")\
**Posts on this page:** 9\
**Page:** 1

<div class="post-metadata">

**Author:** ![ryan](https://dub1.discourse-cdn.com/katalon/user_avatar/forum.katalon.com/ryan/32/16104_2.png) [@ryan](https://forum.katalon.com/u/ryan)\
**Post date:** [October 16, 2021, 4:33am UTC](https://forum.katalon.com/t/how-to-get-the-default-value-of-input-field/59235/1 "2021-10-16T04:33:47Z")

</div>

Hello!

I would like to ask for help because I want to verify that the default value of the input text field is correct. I used this syntax WebUI.getAttribute(findTestObject(‘Shopping\_Cart/Quantity\_Textbox’), 1), and I got an error below.

This is the actual UI

![JPetStore Demo 2021-10-16 at 12.32.45 PM](https://europe1.discourse-cdn.com/katalon/original/3X/a/7/a787cd9373160d09b0a12034edbd558f909b6724.jpeg)

=============== ROOT CAUSE =====================

For trouble shooting, please visit: [https://docs.katalon.com/katalon-studio/docs/troubleshooting.html](https://docs.katalon.com/katalon-studio/docs/troubleshooting.html)

================================================

10-16-2021 12:27:09 PM getAttribute(findTestObject(“Shopping\_Cart/Quantity\_Textbox”), 1)

Elapsed time: 0.208s

Test Cases/TC-002 FAILED.

Reason:

groovy.lang.MissingMethodException: No signature of method: static com.kms.katalon.core.webui.keyword.WebUiBuiltInKeywords.getAttribute() is applicable for argument types: (com.kms.katalon.core.testobject.TestObject, java.lang.Integer) values: [TestObject - ‘Object Repository/Shopping\_Cart/Quantity\_Textbox’, …]

Possible solutions: getAttribute(com.kms.katalon.core.testobject.TestObject, java.lang.String), getAttribute(com.kms.katalon.core.testobject.TestObject, java.lang.String, com.kms.katalon.core.model.FailureHandling)

at TC-002.run(TC-002:66)

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:430)

at com.kms.katalon.core.main.TestCaseExecutor.doExecute(TestCaseExecutor.java:421)

at com.kms.katalon.core.main.TestCaseExecutor.processExecutionPhase(TestCaseExecutor.java:400)

at com.kms.katalon.core.main.TestCaseExecutor.accessMainPhase(TestCaseExecutor.java:392)

at com.kms.katalon.core.main.TestCaseExecutor.execute(TestCaseExecutor.java:273)

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 TempTestCase1634358373663.run(TempTestCase1634358373663.groovy:25)

---

<div class="post-metadata">

**Author:** ![kazurayam](https://dub1.discourse-cdn.com/katalon/user_avatar/forum.katalon.com/kazurayam/32/333_2.png) [@kazurayam](https://forum.katalon.com/u/kazurayam)\
**Post date:** [October 16, 2021, 5:03am UTC](https://forum.katalon.com/t/how-to-get-the-default-value-of-input-field/59235/2 "2021-10-16T05:03:20Z")

</div>

Read the document carefully to find out how to call the keyword appropriately:

> **[\[WebUI\] Get Attribute](https://docs.katalon.com/katalon-studio/docs/webui-get-attribute.html)**
>
> Description Get the attribute of a web element. Parameters Param Param Type Mandatory Description to TestObject Required Represent a web element attribute String Required Name of the attribute flowControl FailureHandling...

---

<div class="post-metadata">

**Author:** ![kazurayam](https://dub1.discourse-cdn.com/katalon/user_avatar/forum.katalon.com/kazurayam/32/333_2.png) [@kazurayam](https://forum.katalon.com/u/kazurayam)\
**Post date:** [October 16, 2021, 5:07am UTC](https://forum.katalon.com/t/how-to-get-the-default-value-of-input-field/59235/3 "2021-10-16T05:07:22Z")

</div>

You need to read the HTML source of your web page. In order to see the HTML source, you need to use Chrome DevTools. Read the following post,

> [@\[TIP\] How To Help Us Help You!](http://forum.katalon.com/t/tip-how-to-help-us-help-you/12919):
>
> My test is BROKEN! NOTHING WORKS! HELP ME! Relax. We get it. We really do. There are some pretty smart and clever people on this forum, but you must realize, they are not magicians or wizards or gods. They cannot see your code, they can’t see your errors and they don’t even know what your AUT is meant to do even though it might seem perfectly obvious to you. So please relax and follow the advice below, before you start writing your post. The advice below will tell you the exact information …

especially,

> **8. Learn to Use DevTools.**  
> Finally, many of the points above rely on YOU understanding how to use the **[Browser Developer Tools](http://forum.katalon.com/t/how-to-the-browser-developer-tools-f12-devtools/34329)** (aka **[DevTools](http://forum.katalon.com/t/how-to-the-browser-developer-tools-f12-devtools/34329)** ).

---

<div class="post-metadata">

**Author:** ![kazurayam](https://dub1.discourse-cdn.com/katalon/user_avatar/forum.katalon.com/kazurayam/32/333_2.png) [@kazurayam](https://forum.katalon.com/u/kazurayam)\
**Post date:** [October 16, 2021, 5:46am UTC](https://forum.katalon.com/t/how-to-get-the-default-value-of-input-field/59235/4 "2021-10-16T05:46:11Z")

</div>

The default value of an `<input>` element is possibly contained as a `value` attribute.

[https://www.w3schools.com/tags/att\_input\_value.asp](https://www.w3schools.com/tags/att_input_value.asp)

---

<div class="post-metadata">

**Author:** ![ryan](https://dub1.discourse-cdn.com/katalon/user_avatar/forum.katalon.com/ryan/32/16104_2.png) [@ryan](https://forum.katalon.com/u/ryan)\
**Post date:** [October 17, 2021, 6:08am UTC](https://forum.katalon.com/t/how-to-get-the-default-value-of-input-field/59235/5 "2021-10-17T06:08:12Z")

</div>

Thanks @kazurayam, It works now. I used this syntax WebUI.getAttribute(findTestObject(‘Shopping\_Cart/Quantity\_Textbox’), ‘value’). But I’m not sure if I used correct syntax. Just to add a context, My goal is I want to ensure that the default value of the input field (the default quantity value in the actual UI is “2”) is correct. Is there another web keyword should I use? Thank you!

![JPetStore Demo 2021-10-17 at 2.00.17 PM](https://europe1.discourse-cdn.com/katalon/optimized/3X/3/f/3f751ee88f3590511335fecbb7db54e044af562a_2_690x78.jpeg)

---

<div class="post-metadata">

**Author:** ![kazurayam](https://dub1.discourse-cdn.com/katalon/user_avatar/forum.katalon.com/kazurayam/32/333_2.png) [@kazurayam](https://forum.katalon.com/u/kazurayam)\
**Post date:** [October 17, 2021, 6:10am UTC](https://forum.katalon.com/t/how-to-get-the-default-value-of-input-field/59235/6 "2021-10-17T06:10:48Z")

</div>

```auto
def v = WebUI.getAttribute(findTestObject(‘Shopping_Cart/Quantity_Textbox’), ‘value’)
assert v == "2"

```

---

<div class="post-metadata">

**Author:** ![ryan](https://dub1.discourse-cdn.com/katalon/user_avatar/forum.katalon.com/ryan/32/16104_2.png) [@ryan](https://forum.katalon.com/u/ryan)\
**Post date:** [October 17, 2021, 6:22am UTC](https://forum.katalon.com/t/how-to-get-the-default-value-of-input-field/59235/7 "2021-10-17T06:22:48Z")

</div>

> [@kazurayam](#):
>
> def v = WebUI.getAttribute(findTestObject(‘Shopping\_Cart/Quantity\_Textbox’), ‘value’) assert v == “2”

Hi @kazurayam Thanks for you response! I tried but I have an error ☹

![Katalon Studio - 8.1.0-8358ac4f - Ryan Exam - Location Usersryanp.escalKatalon StudioRyan Exam 2021-10-17 at 2.21.46 PM](https://europe1.discourse-cdn.com/katalon/optimized/3X/b/5/b50c2c1f21de6712707623c65ce5226a20b6e90b_2_690x33.jpeg)

---

<div class="post-metadata">

**Author:** ![kazurayam](https://dub1.discourse-cdn.com/katalon/user_avatar/forum.katalon.com/kazurayam/32/333_2.png) [@kazurayam](https://forum.katalon.com/u/kazurayam)\
**Post date:** [October 17, 2021, 6:26am UTC](https://forum.katalon.com/t/how-to-get-the-default-value-of-input-field/59235/8 "2021-10-17T06:26:48Z")

</div>

Your code is not the same as mine.  
You made a mistake.  
Review your code carefully.

---

<div class="post-metadata">

**Author:** ![ryan](https://dub1.discourse-cdn.com/katalon/user_avatar/forum.katalon.com/ryan/32/16104_2.png) [@ryan](https://forum.katalon.com/u/ryan)\
**Post date:** [October 17, 2021, 6:51am UTC](https://forum.katalon.com/t/how-to-get-the-default-value-of-input-field/59235/9 "2021-10-17T06:51:06Z")

</div>

Sorry @kazurayam. It’s working now. Thank you for always helping me! 🙂
