HimanshuTayal
7 years agoCommunity Hero
Script challenge for Groovy DataSource - API Summer 2018
Hi Olga_T
I have developed a code for Groovy DataSource, hope this will meets the need of Question.
import jxl.* def groovyUtils1 = new com.eviware.soapui.support.GroovyUtils(context) def projectPath = groovyUtils1.projectPath projectPath = projectPath.replace("\\","/") def dataFile = projectPath + "/DataFile.xls" def f = new File(dataFile) def wk = Workbook.getWorkbook(f) def s1 = wk.getSheet(0) def rows = s1.getRows() def cols = s1.getColumns() def flag = 0 for(def i=1;i<rows;i++) { for(def j=0;j<cols;j++) { //For placing null for(def k = 0; k < 5; k++) { //Get Header Row Column Cell def c1 = s1.getCell(k, 0) //Get Value Row Column Cell def c2 = s1.getCell(k, i) testRunner.testCase.getTestStepByName("Properties").setPropertyValue(c1.getContents().toString(), "null") } //for placing value in front on particular iteration if(flag == j) { def c3 = s1.getCell(j, 0) def c4 = s1.getCell(j, 1) testRunner.testCase.getTestStepByName("Properties").setPropertyValue(c3.getContents().toString(),c4.getContents().toString()) } flag = flag + 1 } testRunner.testCase.getTestStepByName("Properties").setPropertyValue("Counter",i.toString()) }
Do Like and Accept if you find it as Solution.
Thanks,
Himanshu Tayal