# Unable to get the text using getText and getAttribute methods

**URL:** <https://forum.katalon.com/t/unable-to-get-the-text-using-gettext-and-getattribute-methods/6173>\
**Category:** Miscellaneous\
**Created:** [July 24, 2017, 11:26am UTC](https://forum.katalon.com/t/unable-to-get-the-text-using-gettext-and-getattribute-methods/6173 "2017-07-24T11:26:48Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![Vikram\_Davuluri](https://avatars.discourse-cdn.com/v4/letter/v/3e96dc/32.png) [@Vikram\_Davuluri](https://forum.katalon.com/u/Vikram_Davuluri)\
**Post date:** [July 24, 2017, 11:26am UTC](https://forum.katalon.com/t/unable-to-get-the-text-using-gettext-and-getattribute-methods/6173/1 "2017-07-24T11:26:48Z")

</div>

I am using getText method to get the text of a webElement. I am getting ‘null’ when trying to get the text instead of the value.

Alternatively, I tried getAttribute method to get the text. Same issue with this also.

Deleted the object from OR and captured it again and again.

Why is this happening ?

---

<div class="post-metadata">

**Author:** ![Vikram\_Davuluri](https://avatars.discourse-cdn.com/v4/letter/v/3e96dc/32.png) [@Vikram\_Davuluri](https://forum.katalon.com/u/Vikram_Davuluri)\
**Post date:** [July 26, 2017, 8:56am UTC](https://forum.katalon.com/t/unable-to-get-the-text-using-gettext-and-getattribute-methods/6173/2 "2017-07-26T08:56:19Z")

</div>

There is an attribute ‘text’. I am using that to get the text with getAttribute method but the value it is returning is ‘null’.

---

<div class="post-metadata">

**Author:** ![Hanh\_Tran](https://dub1.discourse-cdn.com/katalon/user_avatar/forum.katalon.com/hanh_tran/32/651_2.png) [@Hanh\_Tran](https://forum.katalon.com/u/Hanh_Tran)\
**Post date:** [July 25, 2017, 2:41am UTC](https://forum.katalon.com/t/unable-to-get-the-text-using-gettext-and-getattribute-methods/6173/3 "2017-07-25T02:41:16Z")

</div>

getAttribute should have ‘value’ as an input attribute to get the value. Do you use that correctly?

---

<div class="post-metadata">

**Author:** ![Rama\_Chandra](https://avatars.discourse-cdn.com/v4/letter/r/c57346/32.png) [@Rama\_Chandra](https://forum.katalon.com/u/Rama_Chandra)\
**Post date:** [December 11, 2017, 3:09pm UTC](https://forum.katalon.com/t/unable-to-get-the-text-using-gettext-and-getattribute-methods/6173/4 "2017-12-11T15:09:49Z")

</div>

Can someone guide me how to get the test from this?

- [_: :before_ \*\* Mytext\*\*](https://forum.katalon.com/myfav#mytext)

When i tried with gettext(), i am getting a space. Please suggest.

---

<div class="post-metadata">

**Author:** ![Balraj\_Alladi](https://avatars.discourse-cdn.com/v4/letter/b/b9e5f3/32.png) [@Balraj\_Alladi](https://forum.katalon.com/u/Balraj_Alladi)\
**Post date:** [December 11, 2017, 8:50pm UTC](https://forum.katalon.com/t/unable-to-get-the-text-using-gettext-and-getattribute-methods/6173/5 "2017-12-11T20:50:47Z")

</div>

custUrl = WebUI.getAttribute(findTestObject(‘Object Repository/QA2\_OBP\_OR/SettingsInTransactionPage\_OR/input\_customUrl’), ‘value’)

WebUI.println('custUrl = '+ custUrl)

payerUrl=WebUI.concatenate([baseUrl, custUrl] as String[],

FailureHandling.STOP\_ON\_FAILURE)

WebUI.println('payerUrl = '+ payerUrl)

WebUI.navigateToUrl(payerUrl)

WebUI.waitForPageLoad(20)

---

<div class="post-metadata">

**Author:** ![nhi](https://avatars.discourse-cdn.com/v4/letter/n/d2c977/32.png) [@nhi](https://forum.katalon.com/u/nhi)\
**Post date:** [December 12, 2017, 4:11am UTC](https://forum.katalon.com/t/unable-to-get-the-text-using-gettext-and-getattribute-methods/6173/6 "2017-12-12T04:11:11Z")

</div>

> [Rama Chandra](https://forum.katalon.com/profile/Rama%20Chandra) said:
> 
> Can someone guide me how to get the test from this?
> 
> - [_: :before_ \*\* Mytext\*\*](https://forum.katalon.com/myfav#mytext)
> 
> When i tried with gettext(), i am getting a space. Please suggest.

In your case **Mytest** is the text of href link. So you should get text of element with tag =
