cancel
Showing results for 
Search instead for 
Did you mean: 

How can I get a testStep level property in groovy

New Contributor

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 4
Community Hero

Re: How can I get a testStep level property in groovy

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.


Regards,
Rao.
New Contributor

Re: How can I get a testStep level property in groovy

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

Highlighted
Community Hero

Re: How can I get a testStep level property in groovy

Have you defined the property before accessing it?

Here you may find more sample snippets
https://www.soapui.org/scripting-properties/tips-tricks.html


Regards,
Rao.
Super Contributor

Re: How can I get a testStep level property in groovy

Hi @Heidji ,

 

You can use below code:

def data = testRunner.testCase.getTestStepByName("Properties").getPropertyValue("ArquivoCenarios")

Click "Accept as Solution" if my answer has helped, and remember to give "kudos" Smiley Happy

Thanks and Regards,
Himanshu Tayal
New Here?
Join us and watch the welcome video:
Top Kudoed Authors