Ask a Question

Smart Assertion: Equals (One of)

SOLVED
alinabond
Occasional Contributor

Smart Assertion: Equals (One of)

Hello,

wenn I want to use an array in the smartAssertion which I have extracted with the Property transfer, it does not recognize an array.

E.g. I pass [EXT, GTF, SHZ, BHU] as an array and if I get EXT or BHU which are the first and the last elements of the array, it says it does not match.

I can't write the values with commas and without brackets, sice I'm extracting data via property transfer and it returns an array.

Thanks!

alinabond_0-1692883487945.png

 

8 REPLIES 8
nmrao
Champion Level 3

Would it be possible to show the screen short of Smart Assertion?

Have you tried with Exists in Condition field?

I am assuming that the tool still considers your input to Valid Value as String, but not an array.



Regards,
Rao.
alinabond
Occasional Contributor

Hi Rao,

 

sure. I pass a variable 

alinabond_0-1692948437339.png

and variable looks like this

alinabond_1-1692948552094.png

 

BR

 

nmrao
Champion Level 3

Just looking at the documentation

https://support.smartbear.com/readyapi/docs/testing/assertions/reference/property/smart-assertion.ht...

 

Do you want to try by removing square brackets?



Regards,
Rao.
alinabond
Occasional Contributor

Hi Rao,

yes, this would help, because it accepts values with comma and without brackets.

Do you know how?

nmrao
Champion Level 3

Not sure if I understand your question.

 

Did you try the above suggestion?



Regards,
Rao.
alinabond
Occasional Contributor

Without brackets it works, but the problem is, that I extract the values and pass the variables automatically. I don't want to remove it manuelly coz it's has to be automated test.

@alinabond

if I understand correctly, you need to transform the list (or a string containing brackets) into a string of comma-separated values.

 

If your source is an array, you can do a transformation with the join method:

list = ["A", "B", "C"]
log.info(list)
log.info(list.join(","))

 

If your source is a string containing brackets, you can use the replaceAll method:

stringList = "[D,E,F]"
log.info(stringList)
log.info(stringList.replaceAll(/\[|\]/, ""))

 

Karel@apimate.eu
https://apimate.eu
alinabond
Occasional Contributor

Yes, just found myself the last method you've mentioned with replaceAll 👍

cancel
Showing results for 
Search instead for 
Did you mean: