I want to add the amount and assert the total to a value
Hello,
SOA test : 9.9.5
I have an API where the response will be the clients accounts details like(accounts name, Category, amount and etc).
I want to add all the different accounts "amount" and assert the same with the "total balance" field.
please advise. Thank you.
regards,
Neil
Comments
-
I would use an XPath with the "sum" function.
See my earlier comments about how to use XPath: https://forums.parasoft.com/discussion/2895/how-to-assert-the-length-of-the-field
Other resources:
https://www.w3.org/TR/xpath-functions/#func-sum
http://stackoverflow.com/questions/7979705/how-to-use-sum-function-in-xpath0 -
Hello Benken,
I used below example : sum(/Xavor/Dev[position() <= 2]/Salary/text())
when I apply this x-path I am getting a alphabet charter in the results
please see the attachment.
0 -
Looks like your sum is very large.
When expressing numbers "e" means "times ten raised to the power of". It a notation used in math, science, calculators, computers, etc. It is often used when expressing numbers that are very large or very small, especially when there are constrains on the number of significant digits, like in computers and software. For further explanation, see: https://en.wikipedia.org/wiki/Scientific_notation#E-notation
If you need to compare this number to something else then you should do a numerical comparision, as opposed to a text/string-based comparison. For example, if you use XPath, you could perhaps use the numeric-equal, numeric-less-than, or numeric-greater-than functions, using your sum(/Xavor/Dev[position() <= 2]/Salary/text()) as an argument to that function. Also see https://www.w3.org/TR/xpath-functions/#comp.numeric
0