Forum Discussion

TrishB's avatar
TrishB
New Contributor
9 years ago

can't get property expansion to work...

I am trying to access testcase variables in a loop, but I can't get the property expansion to work.

I have testcase variables with values (holiday_1, holiday_2, etc.)

Here's what I have (bare bones):

 

for (i=1; i<=16; i++)
{
 def curHolidayVariable = "holiday_"+i
 def holidayVariable = context.expand("\${#TestCase#curHolidayVariable}")
 log.info ("holidayVariable : ${holidayVariable}")

}

 

holidayVariable is always empty. Any help would be appreciated...

1 Reply

  • Now the code will look for the property called curHolidayVariable. Try changing it to

    def holidayVariable = context.expand("\${#TestCase#${curHolidayVariable}}")

    or

    def holidayVariable = context.expand('${#TestCase#' + curHolidayVariable + '}')

     

    That will make the code look for holiday_1, holiday_2, etc.