Forum Discussion

alinabond's avatar
alinabond
Occasional Contributor
8 months ago
Solved

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

    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(/\[|\]/, ""))

     

8 Replies

  • nmrao's avatar
    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.

    • alinabond's avatar
      alinabond
      Occasional Contributor

      Hi Rao,

       

      sure. I pass a variable 

      and variable looks like this

       

      BR

       

    • alinabond's avatar
      alinabond
      Occasional Contributor

      Hi Rao,

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

      Do you know how?

  • nmrao's avatar
    nmrao
    Champion Level 3

    Not sure if I understand your question.

     

    Did you try the above suggestion?

    • alinabond's avatar
      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.

      • KarelHusa's avatar
        KarelHusa
        Champion Level 3

        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(/\[|\]/, ""))