Question

I added a Response Assertion to my test to hit the home page of our local site. I added this to the "Patterns to Test" in a Response Assertion:

Email

This worked. ( To get that label, I did View Source in Firefox and copied the code including all white space. I then clicked "Add" for the Response Assertion and pasted the copied code directly into JMeter this way. ) When I run my test, my test will pass with just this label as a Pattern to Test. It shows no red errors after running it in JMeter.

However, when I add the following span tag by clicking on "Add" to get a new entry in the same Response Assertion, the test will fail.

1.7.0.147

So, to be clear, I had 2 entries for the same Response Assertion...one for the "Email" label and one for the "footerVer" span. Each of these had their own separate line under the same Response Assertion.

Also, for most tests that passed and did not pass, I had "Main Sample only", "Text Response", and "Contains" selected. I did try to change to "Matches" and "Equals" but I just ended up with different errors. So, I wanted to stay on "Contains" for now since my other entry for the "Email" label worked when I had "Contains" selected.

Under the "View Results Tree", JMeter tells me about this failure when I add the span tag:

Assertion error: false Assertion failure: true Assertion failure message: Test failed: text expected to contain / 1.7.0.147 /

I also have had success with other tags like , , , , etc. along the way.

Only the tag seems to be giving me a problem right now. Any ideas?

===============================

Added config:

enter image description here

I am not able to add the full response since it is not my code, but the company's code. But, I can try to get something on here that me be useful in a different way.

This is the response dealing with the version copied verbatim from the response tab within JMeter:

<span class="footerVer">
    1.7.0.147
</span>

Hope that helps

Was it helpful?

Solution

I would suggest using XPath assertions for multiline HTML entities parsing as page source may vary and it can be a headache to deal with flaky HTML code.

Following XPath expression validates whether inner text of span with footerVer class equals 1.7.0.147

//span[@class='footerVer']/text()='1.7.0.147'

OTHER TIPS

Use Substring instead of Contains for Pattern Matching rules:

So, I found one way around this. Although, I do not think this is the most efficient way to verify the test. I split the span into 3 individual lines in the Response Assertion.

<span class="copyright marginLeft_100">

&copy; Copyright 2002-2013 Turning Technologies, LLC. All Rights Reserved.

</span>

========================== I do not really mind the first 2 lines. But, the third line is so generic it really does no good if not combined with the beginning tag

Well, for now, I can at least confirm something. Also, I left it on "Contains", even though I took a look at the other link posted above, because all of my other tags presented no problem when it was on "Contains". Hope this helps someone else also.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top