Forum Discussion

krogold's avatar
krogold
Regular Contributor
6 years ago

Is it possible to set properties of a runTestStepByName target ?

Hello,

 

I have several steps with 'input' custom properties that I wish to call for several items.

I parse the item list in a groovy step, then call the steps using the runTestStepByName method.

I want to pass the item id and other data to the testStep. Is it possible to do so ? how can I do that ?

 

thank you

 

Alex

 

So far I try this :

in my calling step :

device_list.each{
	device ->

	// check external id
	step = testRunner.testCase.getTestStepByName("check externalId")
	step.setPropertyValue("uid", device)
	testRunner.runTestStepByName("check externalId")
}

and in my called step (a groovy step, unfortunately)

log.info testRunner.testCase.getTestStepByName("check externalId").getPropertyValue("uid")

but it returns null ...

 

It works fine if I call a runtestCaseStep.

 

  • Hi krogold ,

     

    Ok, i think i read it correctly, that you want to set a custom property at run time at a step that is groovy step,

     

    so it's not possible to do so. If you want to achieve than store the value in context variable and use it in your groovy step

     

    device_list.each{
    	device ->
    
    	// check external id
    	step = testRunner.testCase.getTestStepByName("check externalId")
    	//step.setPropertyValue("uid", device) don't use as there is no custom property at groovy step
    context.setProperty("uid", device) testRunner.runTestStepByName("check externalId") }

    and in calling groovy step use below to fetch value from context variable

     

    log.info context.uid

    Hope this will help, if you find any issue please let me know.

     

  • Hi krogold ,

     

    Ok, i think i read it correctly, that you want to set a custom property at run time at a step that is groovy step,

     

    so it's not possible to do so. If you want to achieve than store the value in context variable and use it in your groovy step

     

    device_list.each{
    	device ->
    
    	// check external id
    	step = testRunner.testCase.getTestStepByName("check externalId")
    	//step.setPropertyValue("uid", device) don't use as there is no custom property at groovy step
    context.setProperty("uid", device) testRunner.runTestStepByName("check externalId") }

    and in calling groovy step use below to fetch value from context variable

     

    log.info context.uid

    Hope this will help, if you find any issue please let me know.