You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@jmeter.apache.org by Knut Borchart <kb...@gmail.com> on 2007/06/08 15:27:41 UTC

Question about XPath Assertion/Extraction

Hi,

i am trying to use xpath assertion and extraction and it seems i cannot get
them to work. Here is what i am trying to accomplish:

1) xpath assertion for a http request. the response document is:

<?xml version="1.0" encoding="UTF-8"?>
<CompositeResponse elapsed="0" date="2007-06-08T14:17:32+0100">
    <CustomerAuthenticateResponse/>
    <CustomerDetailsResponse accountId="kborchart" customerId="100" domain="
test.com" anonymous="false" currency="EUR" currencyPrefix="�"/>
    <DeviceTypeResponse deviceID="ABC"/>
</CompositeResponse>

the xpath assertion i want to use is:

/CompositeResponse/CustomerDetailsResponse[@accountId="kborchart"]

This returns 1 node when i test the xpath query in another editor, but in
Jmeter i never get a positive result. In fact i could not find any xpath
query besides "/" that could generate a positive result. I tried to shorten
the query to /CompositeResponse or /compositeresponse (i am using the
tolerant parser, because otherwise i get a "Content is not allowed in
trailing section." error in the log. It seems there is a strange character
at the end of the response). What is wrong with my approach?

2) xpath extraction of an attribute value. The response document is:

<?xml version="1.0" encoding="UTF-8"?>
<CompositeResponse elapsed="0" date="2007-06-08T10:36:21+0100">
    <CustomerBalanceResponse balance="400.00"/>
    <FOOpenGameResponse gameId="12345678" nextDrawId="0"/>
</CompositeResponse>

The xpath query i want to use is:

/CompositeResponse/FOOpenGameResponse/@gameId

This returns "12345678" in another xml editor, but in jmeter does not find
anything. Is attribute value extraction not supported?

Thanks for any help or pointers!

Kind regards, Knut

Re: Question about XPath Assertion/Extraction

Posted by sebb <se...@gmail.com>.
Test plan sent privately.

The plan works in 2.2 and later.

The NPE was caused because I used the XPath for the Assertion in an
Extractor by mistake.

On 12/06/07, Knut Borchart <kb...@gmail.com> wrote:
> Hi Sebb,
>
> thanks for your response. Please send me a sample JMX if possible. Did you
> fix anything, should i download a new build of jmeter? I am not sure from
> your comment about the NPE...
>
> Kind regards, peter
>
> 2007/6/10, sebb <se...@gmail.com>:
> >
> > I was wrong - the samples work fine for me in JMeter 2.2.
> >
> > I can send you a sample JMX to try if you want.
> >
> > S.
> > On 09/06/07, sebb <se...@gmail.com> wrote:
> > > Check jmeter.log - I exepct you will find an NPE.
> > >
> > > It looks like the XPath evaluation is returning an XNodeSet with no
> > > children, hence the NPE.
> >
> > My bad - I was using the extractor instead of the assertion.
> > However the resulting NPE was still an error, which I have fixed.
> >
> > > Unfortunately I don't know how to detect that the matched item is an
> > > attribute, nor how to extract its value if so. Suggestions welcome!
> >
> > Not actually a problem - just my misunderstanding of the XPath syntax.
> >
> > >
> > > S.
> > > On 08/06/07, Knut Borchart <kb...@gmail.com> wrote:
> > > > Hi,
> > > >
> > > > i am trying to use xpath assertion and extraction and it seems i
> > cannot get
> > > > them to work. Here is what i am trying to accomplish:
> > > >
> > > > 1) xpath assertion for a http request. the response document is:
> > > >
> > > > <?xml version="1.0" encoding="UTF-8"?>
> > > > <CompositeResponse elapsed="0" date="2007-06-08T14:17:32+0100">
> > > >    <CustomerAuthenticateResponse/>
> > > >    <CustomerDetailsResponse accountId="kborchart" customerId="100"
> > domain="
> > > > test.com" anonymous="false" currency="EUR" currencyPrefix="�"/>
> > > >    <DeviceTypeResponse deviceID="ABC"/>
> > > > </CompositeResponse>
> > > >
> > > > the xpath assertion i want to use is:
> > > >
> > > > /CompositeResponse/CustomerDetailsResponse[@accountId="kborchart"]
> > > >
> > > > This returns 1 node when i test the xpath query in another editor, but
> > in
> > > > Jmeter i never get a positive result. In fact i could not find any
> > xpath
> > > > query besides "/" that could generate a positive result. I tried to
> > shorten
> > > > the query to /CompositeResponse or /compositeresponse (i am using the
> > > > tolerant parser, because otherwise i get a "Content is not allowed in
> > > > trailing section." error in the log. It seems there is a strange
> > character
> > > > at the end of the response). What is wrong with my approach?
> > > >
> > > > 2) xpath extraction of an attribute value. The response document is:
> > > >
> > > > <?xml version="1.0" encoding="UTF-8"?>
> > > > <CompositeResponse elapsed="0" date="2007-06-08T10:36:21+0100">
> > > >    <CustomerBalanceResponse balance="400.00"/>
> > > >    <FOOpenGameResponse gameId="12345678" nextDrawId="0"/>
> > > > </CompositeResponse>
> > > >
> > > > The xpath query i want to use is:
> > > >
> > > > /CompositeResponse/FOOpenGameResponse/@gameId
> > > >
> > > > This returns "12345678" in another xml editor, but in jmeter does not
> > find
> > > > anything. Is attribute value extraction not supported?
> > > >
> > > > Thanks for any help or pointers!
> > > >
> > > > Kind regards, Knut
> > > >
> > >
> >
>

Re: Question about XPath Assertion/Extraction

Posted by Knut Borchart <kb...@gmail.com>.
Hi Sebb,

thanks for your response. Please send me a sample JMX if possible. Did you
fix anything, should i download a new build of jmeter? I am not sure from
your comment about the NPE...

Kind regards, peter

2007/6/10, sebb <se...@gmail.com>:
>
> I was wrong - the samples work fine for me in JMeter 2.2.
>
> I can send you a sample JMX to try if you want.
>
> S.
> On 09/06/07, sebb <se...@gmail.com> wrote:
> > Check jmeter.log - I exepct you will find an NPE.
> >
> > It looks like the XPath evaluation is returning an XNodeSet with no
> > children, hence the NPE.
>
> My bad - I was using the extractor instead of the assertion.
> However the resulting NPE was still an error, which I have fixed.
>
> > Unfortunately I don't know how to detect that the matched item is an
> > attribute, nor how to extract its value if so. Suggestions welcome!
>
> Not actually a problem - just my misunderstanding of the XPath syntax.
>
> >
> > S.
> > On 08/06/07, Knut Borchart <kb...@gmail.com> wrote:
> > > Hi,
> > >
> > > i am trying to use xpath assertion and extraction and it seems i
> cannot get
> > > them to work. Here is what i am trying to accomplish:
> > >
> > > 1) xpath assertion for a http request. the response document is:
> > >
> > > <?xml version="1.0" encoding="UTF-8"?>
> > > <CompositeResponse elapsed="0" date="2007-06-08T14:17:32+0100">
> > >    <CustomerAuthenticateResponse/>
> > >    <CustomerDetailsResponse accountId="kborchart" customerId="100"
> domain="
> > > test.com" anonymous="false" currency="EUR" currencyPrefix="�"/>
> > >    <DeviceTypeResponse deviceID="ABC"/>
> > > </CompositeResponse>
> > >
> > > the xpath assertion i want to use is:
> > >
> > > /CompositeResponse/CustomerDetailsResponse[@accountId="kborchart"]
> > >
> > > This returns 1 node when i test the xpath query in another editor, but
> in
> > > Jmeter i never get a positive result. In fact i could not find any
> xpath
> > > query besides "/" that could generate a positive result. I tried to
> shorten
> > > the query to /CompositeResponse or /compositeresponse (i am using the
> > > tolerant parser, because otherwise i get a "Content is not allowed in
> > > trailing section." error in the log. It seems there is a strange
> character
> > > at the end of the response). What is wrong with my approach?
> > >
> > > 2) xpath extraction of an attribute value. The response document is:
> > >
> > > <?xml version="1.0" encoding="UTF-8"?>
> > > <CompositeResponse elapsed="0" date="2007-06-08T10:36:21+0100">
> > >    <CustomerBalanceResponse balance="400.00"/>
> > >    <FOOpenGameResponse gameId="12345678" nextDrawId="0"/>
> > > </CompositeResponse>
> > >
> > > The xpath query i want to use is:
> > >
> > > /CompositeResponse/FOOpenGameResponse/@gameId
> > >
> > > This returns "12345678" in another xml editor, but in jmeter does not
> find
> > > anything. Is attribute value extraction not supported?
> > >
> > > Thanks for any help or pointers!
> > >
> > > Kind regards, Knut
> > >
> >
>

Re: Question about XPath Assertion/Extraction

Posted by sebb <se...@gmail.com>.
I was wrong - the samples work fine for me in JMeter 2.2.

I can send you a sample JMX to try if you want.

S.
On 09/06/07, sebb <se...@gmail.com> wrote:
> Check jmeter.log - I exepct you will find an NPE.
>
> It looks like the XPath evaluation is returning an XNodeSet with no
> children, hence the NPE.

My bad - I was using the extractor instead of the assertion.
However the resulting NPE was still an error, which I have fixed.

> Unfortunately I don't know how to detect that the matched item is an
> attribute, nor how to extract its value if so. Suggestions welcome!

Not actually a problem - just my misunderstanding of the XPath syntax.

>
> S.
> On 08/06/07, Knut Borchart <kb...@gmail.com> wrote:
> > Hi,
> >
> > i am trying to use xpath assertion and extraction and it seems i cannot get
> > them to work. Here is what i am trying to accomplish:
> >
> > 1) xpath assertion for a http request. the response document is:
> >
> > <?xml version="1.0" encoding="UTF-8"?>
> > <CompositeResponse elapsed="0" date="2007-06-08T14:17:32+0100">
> >    <CustomerAuthenticateResponse/>
> >    <CustomerDetailsResponse accountId="kborchart" customerId="100" domain="
> > test.com" anonymous="false" currency="EUR" currencyPrefix="�"/>
> >    <DeviceTypeResponse deviceID="ABC"/>
> > </CompositeResponse>
> >
> > the xpath assertion i want to use is:
> >
> > /CompositeResponse/CustomerDetailsResponse[@accountId="kborchart"]
> >
> > This returns 1 node when i test the xpath query in another editor, but in
> > Jmeter i never get a positive result. In fact i could not find any xpath
> > query besides "/" that could generate a positive result. I tried to shorten
> > the query to /CompositeResponse or /compositeresponse (i am using the
> > tolerant parser, because otherwise i get a "Content is not allowed in
> > trailing section." error in the log. It seems there is a strange character
> > at the end of the response). What is wrong with my approach?
> >
> > 2) xpath extraction of an attribute value. The response document is:
> >
> > <?xml version="1.0" encoding="UTF-8"?>
> > <CompositeResponse elapsed="0" date="2007-06-08T10:36:21+0100">
> >    <CustomerBalanceResponse balance="400.00"/>
> >    <FOOpenGameResponse gameId="12345678" nextDrawId="0"/>
> > </CompositeResponse>
> >
> > The xpath query i want to use is:
> >
> > /CompositeResponse/FOOpenGameResponse/@gameId
> >
> > This returns "12345678" in another xml editor, but in jmeter does not find
> > anything. Is attribute value extraction not supported?
> >
> > Thanks for any help or pointers!
> >
> > Kind regards, Knut
> >
>

Re: Question about XPath Assertion/Extraction

Posted by sebb <se...@gmail.com>.
Check jmeter.log - I exepct you will find an NPE.

It looks like the XPath evaluation is returning an XNodeSet with no
children, hence the NPE.

Unfortunately I don't know how to detect that the matched item is an
attribute, nor how to extract its value if so. Suggestions welcome!


S.
On 08/06/07, Knut Borchart <kb...@gmail.com> wrote:
> Hi,
>
> i am trying to use xpath assertion and extraction and it seems i cannot get
> them to work. Here is what i am trying to accomplish:
>
> 1) xpath assertion for a http request. the response document is:
>
> <?xml version="1.0" encoding="UTF-8"?>
> <CompositeResponse elapsed="0" date="2007-06-08T14:17:32+0100">
>    <CustomerAuthenticateResponse/>
>    <CustomerDetailsResponse accountId="kborchart" customerId="100" domain="
> test.com" anonymous="false" currency="EUR" currencyPrefix="�"/>
>    <DeviceTypeResponse deviceID="ABC"/>
> </CompositeResponse>
>
> the xpath assertion i want to use is:
>
> /CompositeResponse/CustomerDetailsResponse[@accountId="kborchart"]
>
> This returns 1 node when i test the xpath query in another editor, but in
> Jmeter i never get a positive result. In fact i could not find any xpath
> query besides "/" that could generate a positive result. I tried to shorten
> the query to /CompositeResponse or /compositeresponse (i am using the
> tolerant parser, because otherwise i get a "Content is not allowed in
> trailing section." error in the log. It seems there is a strange character
> at the end of the response). What is wrong with my approach?
>
> 2) xpath extraction of an attribute value. The response document is:
>
> <?xml version="1.0" encoding="UTF-8"?>
> <CompositeResponse elapsed="0" date="2007-06-08T10:36:21+0100">
>    <CustomerBalanceResponse balance="400.00"/>
>    <FOOpenGameResponse gameId="12345678" nextDrawId="0"/>
> </CompositeResponse>
>
> The xpath query i want to use is:
>
> /CompositeResponse/FOOpenGameResponse/@gameId
>
> This returns "12345678" in another xml editor, but in jmeter does not find
> anything. Is attribute value extraction not supported?
>
> Thanks for any help or pointers!
>
> Kind regards, Knut
>