Forum Discussion

Heidji's avatar
Heidji
New Contributor
5 years ago

How can I get a testStep level property in groovy

Hi Folks,

I want to get the value from a Property by a testStep level with groovy script, but the code that I've found isn't working.

 

I've searched through the internet also smart bear guides, but I didn't find it.

 

the error that I was receiving with this code is:

 

groovy.lang.MissingMethodException: No signature of method: java.util.HashMap.getPropertyValue() is applicable for argument types: (java.lang.String) values: [ArquivoCenarios] error at line: 8

 

The last line of my code below is line 8.

 

import jxl.*
import jxl.write.*
//planilhaExcel = "C:\\transfer\\data2.xls"
def planilhaExcelObj = testRunner.testCase.testSteps.getPropertyValue("ArquivoCenarios")

 

4 Replies

  • Hi Heidji ,

     

    You can use below code:

    def data = testRunner.testCase.getTestStepByName("Properties").getPropertyValue("ArquivoCenarios")
  • nmrao's avatar
    nmrao
    Champion Level 3
    You can easily define that property at test case level and access it using
    "context.testCase.getPropertyValue('propertyName')"

    This way, an additional step can be avoided.
    • Heidji's avatar
      Heidji
      New Contributor

      Hi Rao,

      thank you for helping me.

       

      I have tried this:

       

      planilhaExcel = context.testCase.getPropertyValue('ArquivoExcel')
      log.info planilhaExcel

      But the return to this log.info is null

      Wed Oct 09 11:52:08 BRT 2019:INFO:null