# Verify text of two matching elements

**URL:** <https://forum.katalon.com/t/verify-text-of-two-matching-elements/8693>\
**Category:** Web Testing\
**Tags:** katalon-studio\
**Created:** [January 2, 2018, 6:56am UTC](https://forum.katalon.com/t/verify-text-of-two-matching-elements/8693 "2018-01-02T06:56:46Z")\
**Posts on this page:** 10\
**Page:** 1

<div class="post-metadata">

**Author:** ![Jacques\_de\_Jager](https://avatars.discourse-cdn.com/v4/letter/j/59ef9b/32.png) [@Jacques\_de\_Jager](https://forum.katalon.com/u/Jacques_de_Jager)\
**Post date:** [January 2, 2018, 6:56am UTC](https://forum.katalon.com/t/verify-text-of-two-matching-elements/8693/1 "2018-01-02T06:56:46Z")

</div>

Hi,

I’ve searched through this forum and used both the Verify Equal and Verify Match pages for information but can’t seem to find an answer to my rather simple query.

I have 2 elements:

**$3.56**

and

$3.56 

What i’m trying to do is compare the two values as they are sourced from different locations though are appearing on the same page. I’ve pulled both as a test object and also converted both into a Global Variable to see if that would work but the script still fails

Both examples on the Katalon documentation seem pointless, both compare either a flat string or numerical value you specify yourself (what point does this serve btw? You’re telling the script to take String “Apple” and compare it to String “Apple” and see that it matches. Of course they will as you give both inputs manually)

If someone can please point me in the right direction in comparing either String or Numerals through Katalon that would be greatly appreciated

Edit: The error i’m getting is generic “Objects don’t match” or “Object 1 and Object 2 are not equal”

---

<div class="post-metadata">

**Author:** ![Jacques\_de\_Jager](https://avatars.discourse-cdn.com/v4/letter/j/59ef9b/32.png) [@Jacques\_de\_Jager](https://forum.katalon.com/u/Jacques_de_Jager)\
**Post date:** [January 3, 2018, 3:43am UTC](https://forum.katalon.com/t/verify-text-of-two-matching-elements/8693/2 "2018-01-03T03:43:23Z")

</div>

In case anyone else encounters this issue i found the solution.

The problem is that the two objects are being compared as objects, rather than the actual text that makes up the object. To get around this, I’ve used getText on the object to get the actual string that resides within this object and done the comparison on this instead.

Solution:

def Card\_0\_Status = WebUI.getText(findTestObject(‘Automation\_Objects/Card\_0/Card\_0\_Status’))

def Card\_0\_CardDetails\_Status = WebUI.getText(findTestObject(‘Automation\_Objects/Card\_0/Card\_0\_CardDetails\_Status’))

WebUI.verifyMatch(Card\_0\_Status, Card\_0\_CardDetails\_Status, false)

---

<div class="post-metadata">

**Author:** ![Ankur\_Solanki](https://avatars.discourse-cdn.com/v4/letter/a/5f9b8f/32.png) [@Ankur\_Solanki](https://forum.katalon.com/u/Ankur_Solanki)\
**Post date:** [March 29, 2018, 4:24am UTC](https://forum.katalon.com/t/verify-text-of-two-matching-elements/8693/3 "2018-03-29T04:24:59Z")

</div>

I am not able to do verify the things using Verify Equal and verify Match, can you please suggest how to use these 2 alerts.

---

<div class="post-metadata">

**Author:** ![Marek\_Melocik](https://dub1.discourse-cdn.com/katalon/user_avatar/forum.katalon.com/marek_melocik/32/371_2.png) [@Marek\_Melocik](https://forum.katalon.com/u/Marek_Melocik)\
**Post date:** [March 29, 2018, 6:44am UTC](https://forum.katalon.com/t/verify-text-of-two-matching-elements/8693/4 "2018-03-29T06:44:03Z")

</div>

You can compare those two strings directly in Java/Groovy.

```auto
String object1 = WebUI.getText(findTestObject('Object1'))
String object2 = WebUI.getText(findTestObject('Object2'))

if(object1 != object2) {
    KeywordUtil.markFailed(object1 + " and " + object2 + " do not match.")
}

```

---

<div class="post-metadata">

**Author:** ![Ankur\_Solanki](https://avatars.discourse-cdn.com/v4/letter/a/5f9b8f/32.png) [@Ankur\_Solanki](https://forum.katalon.com/u/Ankur_Solanki)\
**Post date:** [March 30, 2018, 7:09am UTC](https://forum.katalon.com/t/verify-text-of-two-matching-elements/8693/5 "2018-03-30T07:09:32Z")

</div>

Thanks for the response!  
How can I use Verify Match alert in Manual Mode.

If both the strings are blank then whatever I pass will give me the result accordingly, is there any way, that when choosing Verify Match, user can choose the expected object from the OR.

I am attaching the screenshot for the same.

![](https://s3.amazonaws.com/katalon-forum/editor/zb/3xzce4g687d8.png "Image: https://s3.amazonaws.com/katalon-forum/editor/zb/3xzce4g687d8.png")

![](https://s3.amazonaws.com/katalon-forum/editor/bp/w9n14q8kji6f.png "Image: https://s3.amazonaws.com/katalon-forum/editor/bp/w9n14q8kji6f.png")

[verify match.PNG](https://s3.amazonaws.com/katalon-forum/editor/zb/3xzce4g687d8.png)

[testobject.png](https://s3.amazonaws.com/katalon-forum/editor/bp/w9n14q8kji6f.png)

---

<div class="post-metadata">

**Author:** ![Ankur\_Solanki](https://avatars.discourse-cdn.com/v4/letter/a/5f9b8f/32.png) [@Ankur\_Solanki](https://forum.katalon.com/u/Ankur_Solanki)\
**Post date:** [April 4, 2018, 9:15am UTC](https://forum.katalon.com/t/verify-text-of-two-matching-elements/8693/6 "2018-04-04T09:15:32Z")

</div>

Please help me out for the above mentioned question

---

<div class="post-metadata">

**Author:** ![evgenii](https://avatars.discourse-cdn.com/v4/letter/e/eb9ed0/32.png) [@evgenii](https://forum.katalon.com/u/evgenii)\
**Post date:** [April 4, 2018, 2:06pm UTC](https://forum.katalon.com/t/verify-text-of-two-matching-elements/8693/7 "2018-04-04T14:06:46Z")

</div>

> [Ankur Solanki](https://forum.katalon.com/profile/5433/Ankur%20Solanki) said:
> 
> Please help me out for the above mentioned question

You can switch to Script view and make it there, it’s easy, you should try it 🙂

---

<div class="post-metadata">

**Author:** ![bharathi.a](https://dub1.discourse-cdn.com/katalon/user_avatar/forum.katalon.com/bharathi.a/32/24695_2.png) [@bharathi.a](https://forum.katalon.com/u/bharathi.a)\
**Post date:** [January 24, 2022, 3:05pm UTC](https://forum.katalon.com/t/verify-text-of-two-matching-elements/8693/8 "2022-01-24T15:05:24Z")

</div>

you can use verifyMatch Keyword for this scenario if it contains $ then it should be a String.  
since Selenium will only get and pass a value as a String only.  
if you are getting this value from Excel or from DB Convert the value to String Using the following example.  
Eg:  
1.integer:  
String a=Integer.toString(your Value here)  
2.float  
String a=Float.toString(your Value here)  
3.double  
String a=Double.toString(your Value here)  
4.boolean  
String a=Bolean.toString(your Value here)

- you need to replace the $ using Sting.replace() in Script mode  
once you complete converting the value to String  
just concatinate it to the $  
eg:  
a=a+’$’

---

<div class="post-metadata">

**Author:** ![bharathi.a](https://dub1.discourse-cdn.com/katalon/user_avatar/forum.katalon.com/bharathi.a/32/24695_2.png) [@bharathi.a](https://forum.katalon.com/u/bharathi.a)\
**Post date:** [January 24, 2022, 3:14pm UTC](https://forum.katalon.com/t/verify-text-of-two-matching-elements/8693/9 "2022-01-24T15:14:04Z")

</div>

You can’t directly pass an object to verify match instead  
you can getText or get Attribute from the object and store it into a local variable and pass it into the verifyMactch keyword

eg:  
actual=WebUi.getText(findTestObject(“Your Object Location in object repository”))  
expected=WebUi.getAttribute(findTestObject(“Your Object Location in object repository”),‘value’)  
WebUi.VerifyMatch(actual,expected,false)

or

WebUi.VerifyMatch(WebUi.getText(findTestObject(“Your Object Location in object repository”)),WebUi.getAttribute(findTestObject(“Your Object Location in object repository”),‘value’),false)

---

<div class="post-metadata">

**Author:** ![albert.vu](https://dub1.discourse-cdn.com/katalon/user_avatar/forum.katalon.com/albert.vu/32/20595_2.png) [@albert.vu](https://forum.katalon.com/u/albert.vu)\
**Post date:** [August 8, 2022, 7:30am UTC](https://forum.katalon.com/t/verify-text-of-two-matching-elements/8693/10 "2022-08-08T07:30:05Z")

</div>


