question

Leo_Xu avatar image
Leo_Xu asked Leo_Xu commented

Is is possible to compare string in XPATH in Spirent iTest

In iTest Xpath function which is pretty awesome feature, the number comparison seems working fine. But I can't do it in string comparison, I have checked the http://jaxen.org/apidocs/index.html, and haven't found a proper function can do that. Is it impossible to compare two string in XPATH of iTest.

A simple example

mapped/Tabular/table1/table/row[username >='Abc']

xpath
10 |950

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

1 Answer

·
JeffJ avatar image
JeffJ answered Leo_Xu commented

There are several string functions you can use in iTest but comparing a string as greater or less is not one of them. iTest uses XPATH 1.0. String comparison for XPATH 1.0 is limited to = and !=.

For more on XPATH 1.0 and string comparisons, look check out http://www.w3.org/TR/1999/REC-xpath-19991116/#section-String-Functions. This is been a great help to me in the past.

There may be a workaround for this depending on what you're wanting to recover. Your query above would find all the rows that have a username greater or equal to 'Abc'. You may be able to do this in iTest proper by using a query to find all the usernames in the table, removing the ones that are less than 'Abc' and then using another query to pull out the information for the usernames which are left. If you put this in a quickcall, then your users would only need to reference the quickcall. The information would still be abstracted from the test case.

1 comment
10 |950

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

Leo_Xu avatar image Leo_Xu commented ·

Thank you very much. If iTest have Linux awk feature, it would be awesome :)

1 Like 1 ·

Write an Answer

Hint: Notify or tag a user in this post by typing @username.

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.