Reply
Regular Contributor
dclaar
Posts: 1,128
Registered: 09-18-2008
0

Re: foreach and a response

Noodling around in the response map custom query area, it doesn't appear that iTest knows following-sibling.

Regular Contributor
dclaar
Posts: 1,128
Registered: 09-18-2008
0

Re: foreach and a response

I've attached my .ffrm, where I tried to use preceding-sibling and following-sibling to find the maximum. Now, I could be doing it wrong, but this seems to be the standard XPath 1.0 way of doing it. If you look at query2 and query3, they don't seem to be working right: One returns 37 entries, the other 0.
Expert
KumarS
Posts: 2,233
Registered: 08-30-2008
0

Re: foreach and a response

iTest is evaluating queries correctly. I used your response map's structured data (xml) into a third party XPATH evaluator tool (Visual XPATH - written in c#) and it produces exactly same results for the queries you have in response map. That is what I would expect because iTest uses standard XPATH 1.0 libraries.
Regular Contributor
dclaar
Posts: 1,128
Registered: 09-18-2008
0

Re: foreach and a response

Man, why does this have to be so hard? I just want to parse an ls command and find the largest SVN number!

 

If I analyze with the regex ".*", or even (.*)[\s\n\r], and use extraction group number 1, I get empty list items:

image-2.2.2.2_22368.img {} image-2.2.3.0_22313.img {} image-2.2.3.0_22340.img {} image-2.2.3.0_22354.img {} image-2.2.3.1_22466.img {} image-2.2.3.1_22504.img {} image-2.2.3.2_22536.img {} image-2.2.3.3_22649.img {} image-2.2.3.4_22747.img {} image-2.2.4.0_22395.img {} image-2.2.4.0_22427.img {} image-2.2.4.0_22477.img {} image-2.2.4.0_22521.img {} image-2.2.4.0_22552.img {} image-2.2.4.0_22572.img {} image-2.2.4.0_22592.img {} image-2.2.4.0_22594.img {} image-2.2.4.0_22611.img {} image-2.2.4.0_22633.img {} image-2.2.4.0_22654.img {} image-2.2.4.0_22668.img {} image-2.2.4.0_22675.img {} image-2.2.4.0_22716.img {} image-2.2.4.0_22738.img {} image-2.2.4.0_22757.img {} image-2.2.4.0_22784.img {} image-2.2.4.0_22802.img {} image-2.2.4.0_22825.img {} image-2.2.4.0_22851.img {} image-2.2.4.0_22867.img {} image-2.2.4.0_22890.img {} image-2.2.4.0_22901.img {} image-2.2.4.0_22905.img {} image-2.2.4.0_22959.img {} image-2.2.4.0_23022.img {} image-2.2.5.0_23027.img {} image-2.2.6.0_23059.img {} {}

If I want to use scriptEval, split [response get_ver] "\n" complains because it passes [response get_ver] to tcl.

If I use foreach i [tclexpr split [response get_ver] "\n"] (or various permutations), tcl complains that variables need a "$" in front.

 

Maybe I'm just having a bad day...

BadNews-BangHead.gif
Community Leader
PaulD
Posts: 1,214
Registered: 09-02-2008
0

Re: foreach and a response

Doug,

 

Maybe I'm missing something.  But if your goal is just to have a query that returns the largest build number, you can have a query called max_build_number whose query format is max(build_num()).  For the response map you posted, this returns 23059, which is the biggest one in your list.

 

I'm attaching an update to your response map -- using a simpler pattern map (which made more sense to me, but the block map was fine, too).

Regular Contributor
dclaar
Posts: 1,128
Registered: 09-18-2008
0

Re: foreach and a response

I didn't try max(), because it is XPath 2.0, and it isn't listed in the list of supported functions. Are there other XPath 2.0 functions supported?
Expert
KumarS
Posts: 2,233
Registered: 08-30-2008

Re: foreach and a response

iTest only supports XPATH 1.0. But in order to support backwards compatibility with FanfareSVT, we inject min, max and avg functions into the standard XPATH 1.0 engine. That is why you can use them.

 

We will try to add XPATH 2.0 to some future release of itest.

Regular Contributor
dclaar
Posts: 1,128
Registered: 09-18-2008
0

Re: foreach and a response

Cool! Think you could get that into the doc? I actually did look in the help to see if max was supported, and it isn't mentioned there.

Expert
KumarS
Posts: 2,233
Registered: 08-30-2008
0

Re: foreach and a response

I will ask our documentation person to update this in the next version of iTest.
Fanfare
RoyL
Posts: 36
Registered: 09-04-2008
0

Re: foreach and a response

OK, thanks for the update. The help topic now looks like this:

 

Supported XPath functions

 

iTest supports the following XPath functions:http://jaxen.org/apidocs/index.html 

 

 

To support backward compatibility with FanfareSVT, iTest supports the following additional XPath functions:

min

max

avg  

 

For an XPath language description, see http://www.w3.org/TR/1999/REC-xpath-19991116