Joe Tobin
Joe Tobin

Reputation: 602

Response assertion failing even though the document does contain the expected text

I have a response assertion validating the 'Document (text)' of a response.

This is the assertion

Assertion

This is the failure Failure

This is the response that the assertion is checking. As you can see I have directly copied 'Statutory Currency USD Total Tax (SC) 58.80' from the failing assertion and it is found in the response?! Response

Other assertions are passing for this request.

enter image description here

Upvotes: 1

Views: 331

Answers (3)

UBIK LOAD PACK
UBIK LOAD PACK

Reputation: 34526

You’re using document instead of Text response in Fields to test.

Document is usually reserved to asserting on pdf, excel, word document. it has an important cost in terms of performance and is not needed when asserting on text (html, json...)

Also you should favor substring instead of contains.

Upvotes: 0

Ori Marko
Ori Marko

Reputation: 58772

Notice you can (maybe should) switch to using Substring instead of Contains which will fix your issue, because it doesn't use regex which have reserved characters as (

Contains - true if the text contains the regular expression pattern

Substring - true if the text contains the pattern string (case-sensitive)

Upvotes: 2

Joe Tobin
Joe Tobin

Reputation: 602

Turns out the '(' and ')' needed to be escaped using a '\'.

Upvotes: 1

Related Questions