Ask a Question

Outbounde Exception the second time that I try to read an Excel with SoapUI

SOLVED
d82ej9dut
Occasional Contributor

Outbounde Exception the second time that I try to read an Excel with SoapUI

Hello everybody.

 

I'm trying to read the datas of an excel with the objects

 

wb = Workbook.getWorkbook(new File('C:/Users/Franciscog/Desktop/papageno1.xls')) 

 

It works fine the first time that I use, but the second time, I get this message:

java.lang.ArrayIndexOutOfBound.Exception:0error at line: 12

 

I have to add new rows and columns to the excel in order to make it works again. Any idea of why is it?

 

Thanks a lot in advanceTestingServer (172.29.106.161) - Remote Desktop Connection Manager v2.7.jpg

10 REPLIES 10
nmrao
Champion Level 3

@d82ej9dut,

 

There is simple way to achieve the same differently.

 

Create a .csv file for valid values for odometer as shown below:

 

odometer.csv - contents of the file

 

odometer
Miles
Hours
Kilometres

 

Download xlson library and its dependency  

For more details about xlson library, visit github

 

Here is the script which reads the above csv file and selects one of values randomly

import static com.xlson.groovycsv.CsvParser.parseCsv
//Provide the file path of odometer csv 
def data = parseCsv(new File('/tmp/odometer.csv').text)
def odometerUnits = data*.values.flatten()
//Randomly selects
def selectedValue = odometerUnits[new Random().nextInt(odometerUnits.size())]
log.info "Current selection: $selectedValue"

 



Regards,
Rao.
cancel
Showing results for 
Search instead for 
Did you mean: