# Getting the Value of a Textfield

**URL:** <https://discuss.appium.io/t/getting-the-value-of-a-textfield/5823>\
**Category:** Issues/Bugs\
**Created:** [September 1, 2015, 5:00pm UTC](https://discuss.appium.io/t/getting-the-value-of-a-textfield/5823 "2015-09-01T17:00:35Z")\
**Posts on this page:** 11\
**Page:** 1

<div class="post-metadata">

**Author:** ![skycamefalling](https://discuss.appium.io/letter_avatar_proxy/v4/letter/s/e5b9ba/32.png) [@skycamefalling](https://discuss.appium.io/u/skycamefalling)\
**Post date:** [September 1, 2015, 5:00pm UTC](https://discuss.appium.io/t/getting-the-value-of-a-textfield/5823/1 "2015-09-01T17:00:35Z")

</div>

Does anyone know of a way to get the value of a textfield? I need to validate the text that goes from one iOS screen to another.

I am using the Ruby framework.

Thanks,  
Patrick

---

<div class="post-metadata">

**Author:** ![Aleksei](https://discuss.appium.io/user_avatar/discuss.appium.io/aleksei/32/6267_2.png) [@Aleksei](https://discuss.appium.io/u/Aleksei)\
**Post date:** [September 1, 2015, 5:06pm UTC](https://discuss.appium.io/t/getting-the-value-of-a-textfield/5823/2 "2015-09-01T17:06:39Z")

</div>

java like:  
`driver.findElement(MobileBy.Id("someId")).getAttribute("value")`  
or  
`driver.findElement(MobileBy.Id("someId")).getText()`

---

<div class="post-metadata">

**Author:** ![willosser](https://discuss.appium.io/user_avatar/discuss.appium.io/willosser/32/2454_2.png) [@willosser](https://discuss.appium.io/u/willosser)\
**Post date:** [September 1, 2015, 5:06pm UTC](https://discuss.appium.io/t/getting-the-value-of-a-textfield/5823/3 "2015-09-01T17:06:40Z")

</div>

@skycamefalling, If you have the element, you can use the text method:  
element.text

---

<div class="post-metadata">

**Author:** ![skycamefalling](https://discuss.appium.io/letter_avatar_proxy/v4/letter/s/e5b9ba/32.png) [@skycamefalling](https://discuss.appium.io/u/skycamefalling)\
**Post date:** [September 1, 2015, 8:53pm UTC](https://discuss.appium.io/t/getting-the-value-of-a-textfield/5823/4 "2015-09-01T20:53:43Z")

</div>

Thanks but I am getting an error.

Code: puts shippingaddress.streetaddress1\_field.text

Error: Failure/Error: puts shippingaddress.streetaddress1\_field.text  
ArgumentError:  
wrong number of arguments (0 for 1)

---

<div class="post-metadata">

**Author:** ![willosser](https://discuss.appium.io/user_avatar/discuss.appium.io/willosser/32/2454_2.png) [@willosser](https://discuss.appium.io/u/willosser)\
**Post date:** [September 1, 2015, 10:15pm UTC](https://discuss.appium.io/t/getting-the-value-of-a-textfield/5823/5 "2015-09-01T22:15:23Z")

</div>

That’s odd. You say you are using Ruby. Can you provide the code showing how you obtained shippingaddress.streetaddress1\_field?

---

<div class="post-metadata">

**Author:** ![skycamefalling](https://discuss.appium.io/letter_avatar_proxy/v4/letter/s/e5b9ba/32.png) [@skycamefalling](https://discuss.appium.io/u/skycamefalling)\
**Post date:** [September 2, 2015, 6:14pm UTC](https://discuss.appium.io/t/getting-the-value-of-a-textfield/5823/6 "2015-09-02T18:14:39Z")

</div>

def streetaddress1\_field  
element(:textfield, “Street Address Line 1”)  
end

This is in my page object. Is there something I need to ‘require’ for .text to work?

---

<div class="post-metadata">

**Author:** ![willosser](https://discuss.appium.io/user_avatar/discuss.appium.io/willosser/32/2454_2.png) [@willosser](https://discuss.appium.io/u/willosser)\
**Post date:** [September 2, 2015, 6:20pm UTC](https://discuss.appium.io/t/getting-the-value-of-a-textfield/5823/7 "2015-09-02T18:20:04Z")

</div>

Does this element method find the element by some type that recognizes :textfield? I can’t answer that question from looking at your code. Print out the class and available methods and you will likely have the answer

---

<div class="post-metadata">

**Author:** ![skycamefalling](https://discuss.appium.io/letter_avatar_proxy/v4/letter/s/e5b9ba/32.png) [@skycamefalling](https://discuss.appium.io/u/skycamefalling)\
**Post date:** [September 2, 2015, 6:28pm UTC](https://discuss.appium.io/t/getting-the-value-of-a-textfield/5823/8 "2015-09-02T18:28:31Z")

</div>

I will give that a shot - thanks!

---

<div class="post-metadata">

**Author:** ![gilangbha](https://discuss.appium.io/letter_avatar_proxy/v4/letter/g/4491bb/32.png) [@gilangbha](https://discuss.appium.io/u/gilangbha)\
**Post date:** [March 10, 2017, 10:53am UTC](https://discuss.appium.io/t/getting-the-value-of-a-textfield/5823/9 "2017-03-10T10:53:43Z")

</div>

im currently having the same problem, is there any solution to this?

---

<div class="post-metadata">

**Author:** ![reach2jeyan](https://discuss.appium.io/letter_avatar_proxy/v4/letter/r/b77776/32.png) [@reach2jeyan](https://discuss.appium.io/u/reach2jeyan)\
**Post date:** [May 4, 2017, 1:49pm UTC](https://discuss.appium.io/t/getting-the-value-of-a-textfield/5823/10 "2017-05-04T13:49:37Z")

</div>

Is there a method, where i can check if the text field is filled with a text? Like i proceed to the next screen only when the OTP is filled. I am giving a sleep command which I dont want to, dont like hardcoding.

So, is there something, i can assert in the text field, whether its filled with numbers or not? like find\_element().size \> 0?

---

<div class="post-metadata">

**Author:** ![willosser](https://discuss.appium.io/user_avatar/discuss.appium.io/willosser/32/2454_2.png) [@willosser](https://discuss.appium.io/u/willosser)\
**Post date:** [May 4, 2017, 2:07pm UTC](https://discuss.appium.io/t/getting-the-value-of-a-textfield/5823/11 "2017-05-04T14:07:49Z")

</div>

find\_element.text.size \> 0

If your text field is prepopulated with default text, you’ll need to check that condition as well
