List Variable - Mapping to an Excel File cell

Hello,

I’m trying to pull data from an excel file in the ‘List’ variable type format. However when I try to print an item in the list it doesn’t seem to work.

Example:
Excel Test File Cell - [“value1”, “value2”]

Above is mapped to List variable ListVar1 via Test Suite Data binding

In my code:
println(ListVar1[0])

I would expect it to print out ‘value1’, but instead it prints out ‘[’, which seems to indicate to me it thinks the value is a string. Note: I’ve also tried [‘value1’, ‘value2’] and [value1, value2] in the excel cell.

If i setup a list variable in katalon with default value [“value1”, “value2”], then my print statement displays the correct value.

Anyone have any ideas?

Thanks

2 Likes

Hello,
ok … so …
you get value as an string. string is basically (can be represented) as an array of chars so by addressing 0 position of string you get 1st char of string “[” in your case
to achieve what you want:
store list in format : value1,value2,value3
use String function split() https://www.tutorialspoint.com/groovy/groovy_split.htm

class Example {
   static void main(String[] args) {
        String listSource = 'value1,value2,value3'
        String[] list = listSource.split(',')
        println list[0]
   } 
}