cancel
Showing results for 
Search instead for 
Did you mean: 

Unable to add Property to Groovy TestStep

SOLVED
Satyadip28
New Contributor

Unable to add Property to Groovy TestStep

String rec = "Test1"

testRunner.testCase.getTestStepByName("Env_SetUp").setPropertyValue("TestCase",rec)

-------------------------------

Using the above code to add a Custom Property to a DataSource TestStep programatically. This Executes without any error or warning, but the Custom Property to a DataSource Test Step in SOAPUI Pro.

Is there a way we can programatically add the DataSource Custom Properties rather than importing them manually.

DataSource_Properties.png

The above method setPropertyValue works when adding properties to a TestCase or TestSuite but not to a TestStep.
ReadyAPI Version 2.5.0.

Can you please help.

1 ACCEPTED SOLUTION

Accepted Solutions
msiadak
Community Hero

Re: Unable to add Property to Groovy TestStep

If you are trying to set up the properties for a Data Source, try using the below snippet. That will add the property. Depending on what sort of DataSource you are using you may have other stuff you need to work through first. What sort of Data Source do you want to use? Grid? XML? Groovy? More details will be helpful.

 

String rec = "Test1"

testRunner.testCase.getTestStepByName("Env_SetUp").addProperty("TestCase");



---

Click the Accept as Solution button if my answer has helped, and remember to give kudos where appropriate too!

View solution in original post

6 REPLIES 6
HimanshuTayal
Community Hero

Re: Unable to add Property to Groovy TestStep

Hi @Satyadip28 ,

 

I think you want to dynamically add properties to the DataSource Step, but i am not sure you can do this because the properties in DataSoruce step are ReadOnly, so the below command

 

testRunner.testCase.getTestStepByName("Name").setPropertyValue("foo",bar)

 

will not work.

 

Can you elaborate why you want to do this, so in case we can discuss on any alternate available to your problem.

 


Click "Accept as Solution" if my answer has helped,
Remember to give "Kudos" 🙂 ↓↓↓↓↓



Thanks and Regards,
Himanshu Tayal
Satyadip28
New Contributor

Re: Unable to add Property to Groovy TestStep

I want to create a generic DataSource step that could be used for all my Test Scripts without needing to have a different DataSource Step in each of my testCase. All my TestCases have different DataSource Properties. Though i can parameterize the Excel Sheet and the Workbook for the DataSource TestStep based on my Test Scenario but i cannot dynamically change the Parameters list. So the whole idea fails.


@HimanshuTayal wrote:

Hi @Satyadip28 ,

 

I think you want to dynamically add properties to the DataSource Step, but i am not sure you can do this because the properties in DataSoruce step are ReadOnly, so the below command

 

testRunner.testCase.getTestStepByName("Name").setPropertyValue("foo",bar)

 

will not work.

 

Can you elaborate why you want to do this, so in case we can discuss on any alternate available to your problem.

 


 

HimanshuTayal
Community Hero

Re: Unable to add Property to Groovy TestStep

Hi @Satyadip28 ,

 

I think you are using Excel sheet in data source to fetch the data, instead use groovy to fetch the data from Excel Sheet.

Refer below article, hope it will help you in resolving your issue

 

DataSource step with groovy

 


Click "Accept as Solution" if my answer has helped,
Remember to give "Kudos" 🙂 ↓↓↓↓↓



Thanks and Regards,
Himanshu Tayal
Satyadip28
New Contributor

Re: Unable to add Property to Groovy TestStep


@HimanshuTayal wrote:

Hi @Satyadip28 ,

 

I think you are using Excel sheet in data source to fetch the data, instead use groovy to fetch the data from Excel Sheet.

Refer below article, hope it will help you in resolving your issue

 

DataSource step with groovy

 


This doesn't solve my problem as this just programmatically adds value to Properties. I want to add Properties programmatically. If you don't have properties in the Properties List then we can't run the Groovy code itself.

HimanshuTayal
Community Hero

Re: Unable to add Property to Groovy TestStep

Then in that case what i would suggest is :

 

1. Add a properites step at runtime

2. save each value in properties step and

3. delete the properties step after each iteration

 

then i think it will get incorporated in your framework

 


Click "Accept as Solution" if my answer has helped,
Remember to give "Kudos" 🙂 ↓↓↓↓↓



Thanks and Regards,
Himanshu Tayal
msiadak
Community Hero

Re: Unable to add Property to Groovy TestStep

If you are trying to set up the properties for a Data Source, try using the below snippet. That will add the property. Depending on what sort of DataSource you are using you may have other stuff you need to work through first. What sort of Data Source do you want to use? Grid? XML? Groovy? More details will be helpful.

 

String rec = "Test1"

testRunner.testCase.getTestStepByName("Env_SetUp").addProperty("TestCase");



---

Click the Accept as Solution button if my answer has helped, and remember to give kudos where appropriate too!

View solution in original post

New Here?
Join us and watch the welcome video:
Announcements
Top Kudoed Authors