Forum Discussion

roja1's avatar
roja1
Contributor
5 years ago
Solved

compare property names with data in excel file

Hi,

 

I want to get the property name from properties at test step level. I have an excel which has 1st column as property names and 2nd value as property value. The property name which I get from soapui needs to be compared with the property names present in the 1st column of excel and get the corresponding value and assign it to the value of property in soapui.

 

Please help me with this

  • Then you can get the list of properties present inside the Properties TestStep and then compare :-

    def testStep = testRunner.testCase.testSteps["Properties"]
    if (testStep.getPropertyCount() > 0){
     for (prop in testStep.getPropertyList()){
      log.info(prop.getName() +" "+ prop.getValue())
     }
    }
  • roja1's avatar
    roja1
    5 years ago

    Hi,

     

    Thank you. It helped me to get the properties.

  • Ok, you are getting error at line 20. Actually setPropertyValue("", Val) always accepts String. Try to store prop.getName to a String value and then pass there. Like this - 

     

    def testStep = testRunner.testCase.testSteps["Properties"]
    if (testStep.getPropertyCount() > 0){
    for (prop in testStep.getPropertyList()){
    for(int i=0;i<size;i++){
    Cell f=sheet1.getCell(0,i)
    field=f.getContents()
    Cell f1=sheet1.getCell(1,i)
    value=f1.getContents()
    String propName = prop.getName()
    log.info propName
    if(prop.getName()==field){
    testRunner.testCase.testSteps["Properties"].setPropertyValue(propName, value)
    }
    else{
    log.info "Not Found"
    }
    }
    }
    }

16 Replies

  • avidCoder's avatar
    avidCoder
    Super Contributor

    First, get the properties value from test Steps using this code :-

     

    def code = testRunner.testCase.testSteps['Properties'].getPropertyValue("Code")

    Where, Code is the property name in Properties Step.

    And after that, Use DataSource expansion code

    def code = context.expand( '${DataSource#Code}' )

    Where, code is the column in Excel.

     

    And, if you are not using paid version of soapui, then you need to write excel connection code using java/groovy and fetch the particular row and column value and then do assert logic.

    And, finally,  do assertEquals logic,

    • roja1's avatar
      roja1
      Contributor

      Hi,

      Thanks for the response.

      What I am trying to acheive is , suppose my properties step has 4 properties named a,b,c,d. I want to get the names of those properties and serach for their values which are already present in an excel file.

       

      Appreciate your help in advance.

      • avidCoder's avatar
        avidCoder
        Super Contributor

        Then you can get the list of properties present inside the Properties TestStep and then compare :-

        def testStep = testRunner.testCase.testSteps["Properties"]
        if (testStep.getPropertyCount() > 0){
         for (prop in testStep.getPropertyList()){
          log.info(prop.getName() +" "+ prop.getValue())
         }
        }