Forum Discussion

Satyadip28's avatar
Satyadip28
New Contributor
5 years ago
Solved

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.

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.

  • 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");

6 Replies

  • 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.

     

    • Satyadip28's avatar
      Satyadip28
      New Contributor

      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's avatar
        HimanshuTayal
        Community Hero

        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

         

  • groovyguy's avatar
    groovyguy
    Champion Level 1

    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");