Reputation: 3
Response data : renderData":"{\"note\":\"test note\",\"color\":\"\",\"appHeight\":\"203px\",\"appWidth\":\"224px\",\"actionURI\":\"/static/nbapps/notepad/addNote.ejs\",\"mode\":\"INLINE\",\"annotationContainerId\":\"ebook_container\",\"pageXOffset\":0}"
Regular Expression (it's working perfect) - renderData : renderData":"([^}]+pageXOffset.+?})"
Response Assertion (Text Response, contains are selected) - ${renderData} : Assertion error: false Assertion failure: true Assertion failure message: Test failed: text expected to contain /{\"note\":\"test note\",\"color\":\"\",\"appHeight\":\"203px\",\"appWidth\":\"224px\",\"actionURI\":\"/static/nbapps/notepad/addNote.ejs\",\"mode\":\"INLINE\",\"annotationContainerId\":\"ebook_container\",\"pageXOffset\":0}/
why assertion is showing, text expected to contain, when the same text is available in response?
Upvotes: 0
Views: 1230
Reputation: 168092
As per How to Use JMeter Assertions in Three Easy Steps guide:
The Pattern can be either be:
a “string” for “Equals” or “Substring” clauses
a “Perl5-style” Regular Expression for “Contains” or “Matches” clauses
Given you use Contains
- JMeter treats the pattern as Regular Expression, it doesn't match anything hence it fails.
So you have the following options:
If you extracted the "interesting" response bit into a JMeter Variable - you can apply assertion to the variable directly, configure Assertion as follows:
Patterns to test: add your expected value:
{\"note\":\"test note\",\"color\":\"\",\"appHeight\":\"203px\",\"appWidth\":\"224px\",\"actionURI\":\"/static/nbapps/notepad/addNote.ejs\",\"mode\":\"INLINE\",\"annotationContainerId\":\"ebook_container\",\"pageXOffset\":0}
Just make sure assertion goes below Regular Expression Extractor
You can apply assertion directly to the response, in that case choose "Substring" in the "Pattern Matching Rules"
Upvotes: 1