You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@jmeter.apache.org by Deepak Shetty <sh...@gmail.com> on 2010/02/01 21:58:46 UTC
Re: How to use XPath Assertion on a substring of the sampler
response?
BeanShell code would work. you could either write your assertions any way
you want or you might try
a. Use XPath Extractor to extract the string to a JMeter variable
b. Write a BeanShell sampler which returns this variable as the response,
c. Use the XPATH assertion as normal. for the above sampler
You would have an extra sample in your test results but if you can live with
it (And assuming it works, I havent tested) should be the simplest
On Mon, Feb 1, 2010 at 12:50 PM, David Levine <en...@gmail.com> wrote:
> Hi,
>
>
> I’ve got a situation where my WebService (SOAP) Request is returning a
> string which happens to be a nested XML document with its own schema. So
> it's an XML document nested inside the XML document returned by the SOAP
> call. Consequently, XPath can’t interpret the structure of the nested XML
> document, so I have to treat it as a string and for example use the XPath
> contains() function.
>
>
>
> Is there any way I can write an XPath Assertion against this nested XML
> document in such a way that it interprets the structure of the nested XML?
>
>
>
> I thought about trying to do it in two steps that might be:
>
> Step 1: Use XPath Extractor to extract the string to a JMeter
> variable
>
> Step 2: Use XPath Assertion on the variable as opposed to
> sampler output
>
>
>
> But I don’t think there’s any way to do step #2. Is there any relatively
> simple way to do what I want to do?
>
>
>
> My fallback is to use the XPath contains() function to do substring
> searching on the nested XML, but unfortunately since match() is not
> supported, this is very fragile.
>
>
>
> Any thoughts would be greatly appreciated!
>
>
>
> David
>
Re: How to use XPath Assertion on a substring of the sampler
response?
Posted by David Levine <en...@gmail.com>.
I forgot to thank you for your help: Thank you!
On Mon, Feb 1, 2010 at 5:24 PM, David Levine <en...@gmail.com> wrote:
> It seems like there's no way to run assertions against JMeter variables.
> So I'm thinking maybe I'd write a new sampler component called an "Echo
> Sampler", that took one parameter which was the value to echo, and it just
> echoed it back. The parameter of course could be any JMeter variable. That
> way you could extract in one step, and then echo back and assert in the next
> step.
>
> Is this a good idea, and would it be useful to others?
>
>
>
> On Mon, Feb 1, 2010 at 1:33 PM, sebb <se...@gmail.com> wrote:
>
>> On 01/02/2010, Deepak Shetty <sh...@gmail.com> wrote:
>> > BeanShell code would work. you could either write your assertions any
>> way
>> > you want or you might try
>> >
>> > a. Use XPath Extractor to extract the string to a JMeter variable
>> > b. Write a BeanShell sampler which returns this variable as the
>> response,
>>
>> Or use a Java Request/Java Test, which uses fewer resources.
>>
>> > c. Use the XPATH assertion as normal. for the above sampler
>> > You would have an extra sample in your test results but if you can live
>> with
>> > it (And assuming it works, I havent tested) should be the simplest
>> >
>> >
>> >
>> > On Mon, Feb 1, 2010 at 12:50 PM, David Levine <en...@gmail.com>
>> wrote:
>> >
>> > > Hi,
>> > >
>> > >
>> > > I’ve got a situation where my WebService (SOAP) Request is returning
>> a
>> > > string which happens to be a nested XML document with its own schema.
>> So
>> > > it's an XML document nested inside the XML document returned by the
>> SOAP
>> > > call. Consequently, XPath can’t interpret the structure of the
>> nested XML
>> > > document, so I have to treat it as a string and for example use the
>> XPath
>> > > contains() function.
>> > >
>> > >
>> > >
>> > > Is there any way I can write an XPath Assertion against this nested
>> XML
>> > > document in such a way that it interprets the structure of the nested
>> XML?
>> > >
>> > >
>> > >
>> > > I thought about trying to do it in two steps that might be:
>> > >
>> > > Step 1: Use XPath Extractor to extract the string to a
>> JMeter
>> > > variable
>> > >
>> > > Step 2: Use XPath Assertion on the variable as opposed
>> to
>> > > sampler output
>> > >
>> > >
>> > >
>> > > But I don’t think there’s any way to do step #2. Is there any
>> relatively
>> > > simple way to do what I want to do?
>> > >
>> > >
>> > >
>> > > My fallback is to use the XPath contains() function to do substring
>> > > searching on the nested XML, but unfortunately since match() is not
>> > > supported, this is very fragile.
>> > >
>> > >
>> > >
>> > > Any thoughts would be greatly appreciated!
>> > >
>> > >
>> > >
>> > > David
>> > >
>> >
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: jmeter-user-unsubscribe@jakarta.apache.org
>> For additional commands, e-mail: jmeter-user-help@jakarta.apache.org
>>
>>
>
Re: How to use XPath Assertion on a substring of the sampler
response?
Posted by sebb <se...@gmail.com>.
On 02/02/2010, David Levine <en...@gmail.com> wrote:
> It seems like there's no way to run assertions against JMeter variables.
> So I'm thinking maybe I'd write a new sampler component called an "Echo
> Sampler", that took one parameter which was the value to echo, and it just
> echoed it back. The parameter of course could be any JMeter variable. That
> way you could extract in one step, and then echo back and assert in the next
> step.
>
> Is this a good idea, and would it be useful to others?
>
That already exists - the Java Request/Test Sampler allows one to
create samples with any content, fixed or variable.
>
> On Mon, Feb 1, 2010 at 1:33 PM, sebb <se...@gmail.com> wrote:
>
> > On 01/02/2010, Deepak Shetty <sh...@gmail.com> wrote:
> > > BeanShell code would work. you could either write your assertions any way
> > > you want or you might try
> > >
> > > a. Use XPath Extractor to extract the string to a JMeter variable
> > > b. Write a BeanShell sampler which returns this variable as the
> > response,
> >
> > Or use a Java Request/Java Test, which uses fewer resources.
> >
> > > c. Use the XPATH assertion as normal. for the above sampler
> > > You would have an extra sample in your test results but if you can live
> > with
> > > it (And assuming it works, I havent tested) should be the simplest
> > >
> > >
> > >
> > > On Mon, Feb 1, 2010 at 12:50 PM, David Levine <en...@gmail.com>
> > wrote:
> > >
> > > > Hi,
> > > >
> > > >
> > > > I’ve got a situation where my WebService (SOAP) Request is returning a
> > > > string which happens to be a nested XML document with its own schema.
> > So
> > > > it's an XML document nested inside the XML document returned by the
> > SOAP
> > > > call. Consequently, XPath can’t interpret the structure of the nested
> > XML
> > > > document, so I have to treat it as a string and for example use the
> > XPath
> > > > contains() function.
> > > >
> > > >
> > > >
> > > > Is there any way I can write an XPath Assertion against this nested
> > XML
> > > > document in such a way that it interprets the structure of the nested
> > XML?
> > > >
> > > >
> > > >
> > > > I thought about trying to do it in two steps that might be:
> > > >
> > > > Step 1: Use XPath Extractor to extract the string to a
> > JMeter
> > > > variable
> > > >
> > > > Step 2: Use XPath Assertion on the variable as opposed
> > to
> > > > sampler output
> > > >
> > > >
> > > >
> > > > But I don’t think there’s any way to do step #2. Is there any
> > relatively
> > > > simple way to do what I want to do?
> > > >
> > > >
> > > >
> > > > My fallback is to use the XPath contains() function to do substring
> > > > searching on the nested XML, but unfortunately since match() is not
> > > > supported, this is very fragile.
> > > >
> > > >
> > > >
> > > > Any thoughts would be greatly appreciated!
> > > >
> > > >
> > > >
> > > > David
> > > >
> > >
> >
>
> > ---------------------------------------------------------------------
> > To unsubscribe, e-mail: jmeter-user-unsubscribe@jakarta.apache.org
> > For additional commands, e-mail: jmeter-user-help@jakarta.apache.org
> >
> >
>
---------------------------------------------------------------------
To unsubscribe, e-mail: jmeter-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: jmeter-user-help@jakarta.apache.org
Re: How to use XPath Assertion on a substring of the sampler
response?
Posted by David Levine <en...@gmail.com>.
It seems like there's no way to run assertions against JMeter variables.
So I'm thinking maybe I'd write a new sampler component called an "Echo
Sampler", that took one parameter which was the value to echo, and it just
echoed it back. The parameter of course could be any JMeter variable. That
way you could extract in one step, and then echo back and assert in the next
step.
Is this a good idea, and would it be useful to others?
On Mon, Feb 1, 2010 at 1:33 PM, sebb <se...@gmail.com> wrote:
> On 01/02/2010, Deepak Shetty <sh...@gmail.com> wrote:
> > BeanShell code would work. you could either write your assertions any way
> > you want or you might try
> >
> > a. Use XPath Extractor to extract the string to a JMeter variable
> > b. Write a BeanShell sampler which returns this variable as the
> response,
>
> Or use a Java Request/Java Test, which uses fewer resources.
>
> > c. Use the XPATH assertion as normal. for the above sampler
> > You would have an extra sample in your test results but if you can live
> with
> > it (And assuming it works, I havent tested) should be the simplest
> >
> >
> >
> > On Mon, Feb 1, 2010 at 12:50 PM, David Levine <en...@gmail.com>
> wrote:
> >
> > > Hi,
> > >
> > >
> > > I’ve got a situation where my WebService (SOAP) Request is returning a
> > > string which happens to be a nested XML document with its own schema.
> So
> > > it's an XML document nested inside the XML document returned by the
> SOAP
> > > call. Consequently, XPath can’t interpret the structure of the nested
> XML
> > > document, so I have to treat it as a string and for example use the
> XPath
> > > contains() function.
> > >
> > >
> > >
> > > Is there any way I can write an XPath Assertion against this nested
> XML
> > > document in such a way that it interprets the structure of the nested
> XML?
> > >
> > >
> > >
> > > I thought about trying to do it in two steps that might be:
> > >
> > > Step 1: Use XPath Extractor to extract the string to a
> JMeter
> > > variable
> > >
> > > Step 2: Use XPath Assertion on the variable as opposed
> to
> > > sampler output
> > >
> > >
> > >
> > > But I don’t think there’s any way to do step #2. Is there any
> relatively
> > > simple way to do what I want to do?
> > >
> > >
> > >
> > > My fallback is to use the XPath contains() function to do substring
> > > searching on the nested XML, but unfortunately since match() is not
> > > supported, this is very fragile.
> > >
> > >
> > >
> > > Any thoughts would be greatly appreciated!
> > >
> > >
> > >
> > > David
> > >
> >
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: jmeter-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: jmeter-user-help@jakarta.apache.org
>
>
Re: How to use XPath Assertion on a substring of the sampler
response?
Posted by sebb <se...@gmail.com>.
On 01/02/2010, Deepak Shetty <sh...@gmail.com> wrote:
> BeanShell code would work. you could either write your assertions any way
> you want or you might try
>
> a. Use XPath Extractor to extract the string to a JMeter variable
> b. Write a BeanShell sampler which returns this variable as the response,
Or use a Java Request/Java Test, which uses fewer resources.
> c. Use the XPATH assertion as normal. for the above sampler
> You would have an extra sample in your test results but if you can live with
> it (And assuming it works, I havent tested) should be the simplest
>
>
>
> On Mon, Feb 1, 2010 at 12:50 PM, David Levine <en...@gmail.com> wrote:
>
> > Hi,
> >
> >
> > I’ve got a situation where my WebService (SOAP) Request is returning a
> > string which happens to be a nested XML document with its own schema. So
> > it's an XML document nested inside the XML document returned by the SOAP
> > call. Consequently, XPath can’t interpret the structure of the nested XML
> > document, so I have to treat it as a string and for example use the XPath
> > contains() function.
> >
> >
> >
> > Is there any way I can write an XPath Assertion against this nested XML
> > document in such a way that it interprets the structure of the nested XML?
> >
> >
> >
> > I thought about trying to do it in two steps that might be:
> >
> > Step 1: Use XPath Extractor to extract the string to a JMeter
> > variable
> >
> > Step 2: Use XPath Assertion on the variable as opposed to
> > sampler output
> >
> >
> >
> > But I don’t think there’s any way to do step #2. Is there any relatively
> > simple way to do what I want to do?
> >
> >
> >
> > My fallback is to use the XPath contains() function to do substring
> > searching on the nested XML, but unfortunately since match() is not
> > supported, this is very fragile.
> >
> >
> >
> > Any thoughts would be greatly appreciated!
> >
> >
> >
> > David
> >
>
---------------------------------------------------------------------
To unsubscribe, e-mail: jmeter-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: jmeter-user-help@jakarta.apache.org