Contributions
Skip row of excel datadriver in groovy script
I'm running testcases based on an .xls datadriver file, which loops until the last row is found. However my excel file has headers, how can I make my data driver skip the first row of headers, since this is not testdata. // DECLARE THE VARIABLES def myTestCase = context.testCase //myTestCase contains the test case def counter,next,previous,size//Variables used to handle the loop and to move inside the file // Change file directory Workbook workbook1 = Workbook.getWorkbook(new File("C:/driver.xls")) //file containing the data (CHANGE THIS) log.info "C:/driver.xls" Sheet sheet1 = workbook1.getSheet("ins2_all_opt_out") //save the first sheet in sheet1 size= sheet1.getRows().toInteger() //get the number of rows, each row is a data set log.info size propTestStep = myTestCase.getTestStepByName("Property - Looper") // get the Property TestStep object propTestStep.setPropertyValue("Total", size.toString()) counter = propTestStep.getPropertyValue("Count").toString() //counter variable contains iteration number counter = counter.toInteger() // log.info counter next = (counter > size-2? 0: counter+1) //set the next line value log.info next Cell a = sheet1.getCell(0,counter) // getCell(column,row) //obtains cardnumber cell A, stores into C workbook1.close() //close the file log.info a.getContents() //////////////////////////////////// propTestStep.setPropertyValue("MemberNumber", a.getContents()) //value saved into property, for the appropriate test step propTestStep.setPropertyValue("Count", next.toString()) next++ //increase next value propTestStep.setPropertyValue("Next", next.toString()) //set Next value on the properties step //Decide if the test has to be run again or not log.info "info: counter: " + counter + "next: " + next + "size: " + size; if (counter == size-1) { propTestStep.setPropertyValue("StopLoop", "T") log.info "Setting the stoploop property now..." } else if (counter==0) { def runner = new com.eviware.soapui.impl.wsdl.testcase.WsdlTestCaseRunner(testRunner.testCase, null) propTestStep.setPropertyValue("StopLoop", "F") } else { propTestStep.setPropertyValue("StopLoop", "F") } log.info propTestStep.getPropertyValue("StopLoop"); log.info propTestStep.getPropertyValue("XML");// IMPORT THE LIBRARIES WE NEED1.7KViews0likes0Comments