Forum Discussion

roja1's avatar
roja1
Contributor
5 years ago

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 ...
  • avidCoder's avatar
    avidCoder
    5 years ago

    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.

  • avidCoder's avatar
    avidCoder
    5 years ago

    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"
    }
    }
    }
    }