You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@jmeter.apache.org by "Christensen, Alan" <al...@hp.com> on 2006/11/25 23:20:38 UTC

Multiple Response Assertions with "or" condition?

I do a search on my website.  This returns a list of URL's that
correspond to documents matching the search criteria.  I then select one
of the URL's at random and display the document.  Some of the documents
are in html format.  If this is the case, then the document will contain
the ID of the document as part of the returned html.  In the past I have
done a response assertion that looked for the document ID.  If the
correct document was returned, then the response assertion would be
true, and I'd know that things worked properly.  

Recently some .pdf files have been added to the document library.  So
now some of the URL's point to .pdf documents.  Whenever one of these
new documents is randomly selected, my response assertion fails.

What I would like to do to get rid of these errors is to do two response
assertions.  One would be like my current assertion and would look in
the returned html text for the correct document ID.  The second response
assertion would look at the URL and see if contained the string ".pdf".
I'd like the total response assertion to be true if either of these
conditions is met.  Hence the "OR" of the two response assertions rather
than the "AND".

I have yet to discover any way to "OR" two response assertions that are
inspecting different items, e.g., one that inspects the returned html,
and one that inspects the URL.  Is there any way to do this?  Are there
alternative ways to accomplish what I am trying to do?





Re: Multiple Response Assertions with "or" condition?

Posted by sebb <se...@gmail.com>.
Response assertions cannot be ORed currently.

It's not possible to use an OR in the Regex either, as you are
checking two different things (URL and text).

However, you know before the request is made whether or not you are
expecting to check the URL or the page contents, so why not use a
Switch Conroller to select between download+check URL and
download+check page?

You just need to code a function to return 0 or 1 depending on whether
the URL is for a PDF or HTML page. This could be in Javascript,
BeanShell or JEXL.

If you end up with more types, then it would be easy enough to extend
the Switch.

I don't think the Switch Controller will work with only the Assertion
in it, but might be worth trying.

S.
On 25/11/06, Christensen, Alan <al...@hp.com> wrote:
>
> I do a search on my website.  This returns a list of URL's that
> correspond to documents matching the search criteria.  I then select one
> of the URL's at random and display the document.  Some of the documents
> are in html format.  If this is the case, then the document will contain
> the ID of the document as part of the returned html.  In the past I have
> done a response assertion that looked for the document ID.  If the
> correct document was returned, then the response assertion would be
> true, and I'd know that things worked properly.
>
> Recently some .pdf files have been added to the document library.  So
> now some of the URL's point to .pdf documents.  Whenever one of these
> new documents is randomly selected, my response assertion fails.
>
> What I would like to do to get rid of these errors is to do two response
> assertions.  One would be like my current assertion and would look in
> the returned html text for the correct document ID.  The second response
> assertion would look at the URL and see if contained the string ".pdf".
> I'd like the total response assertion to be true if either of these
> conditions is met.  Hence the "OR" of the two response assertions rather
> than the "AND".
>
> I have yet to discover any way to "OR" two response assertions that are
> inspecting different items, e.g., one that inspects the returned html,
> and one that inspects the URL.  Is there any way to do this?  Are there
> alternative ways to accomplish what I am trying to do?
>
>
>
>
>
>

---------------------------------------------------------------------
To unsubscribe, e-mail: jmeter-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: jmeter-user-help@jakarta.apache.org