Forum Discussion
10 Replies
Sort By
- gurpreetsOccasional ContributorHi Gaurav,
I am using the script below for the same. Also find the kind of excel i am using attached.
Thanks
// JAVA CLASSES
import java.io.File;
import com.eviware.soapui.support.*;
import java.util.*;
import jxl.*;
import java.lang.*;
// VARIABLE TO HOLD THE DATA SHEET NAME
// sDataSheetName = "header-inputs.xls"
// TO CREATE VARIABLES TO HOLD THE RESQUEST VALUES
def groovyUtils = new com.eviware.soapui.support.GroovyUtils( context );
def request = groovyUtils.getXmlHolder("deployCampaign_test#Request");
// DECLARING VARIABLES FOR GLOBAL PROPERTIES
def projectdir = context.expand('${#Global#PATH}');
Workbook workbook = Workbook.getWorkbook(new File("E:/xl-input/inputs.xls"));
Sheet sheet = workbook.getSheet("Input");
rowcount = sheet.getRows();
colcount = sheet.getColumns();
// TO GET THE TEST CASE NAME
def testCase = testRunner.getTestCase();
Name = testCase.getName();
// CHECK WHETHER THE TESTCASE NAMES MATCH
for (tc_row in 1..rowcount)
{
Cell a1 = sheet.getCell(0,tc_row);
String s1 = a1.getContents();
// UISupport.showInfoMessage("${s1}")
if ( Name == s1 )
{
current_row = tc_row;
break;
}
}
// TO CHECK FOR THE HEADER TAGS
for (tc_column in 2..colcount-1)
{
Cell a2= sheet.getCell(tc_column-1,0);
String s2 = a2.getContents();
//UISupport.showInfoMessage("${s2}")
if (s2 != "" )
{
Cell a3= sheet.getCell(tc_column-1,current_row);
String s3 = a3.getContents();
//UISupport.showInfoMessage("${s3}")
tag = s3;
//SETS INPUT VALUES IN CORRESPONDING NODE
request.setNodeValue("//icom:" + s2, "${tag}");
request.updateProperty();
}
}
- srinivas_das_lContributorThanks a lot for sharing following information
Adding to the below mentioned script ,
I have one query
The script works fine If we add a groovy step in testSteps and execute
But If we want to read the values from excel using "TestSuite - teardown script "
what changes need to be done
because I changed getXmlHolder ,testRunner to testSuite variable .But It's not working
So Can anyone give some idea in this ?? - Hi Gurpreet,
I am able to get the data from the excel sheet. If the input in data sheet for one field is blank the xml tag gets ended (Eg:where v11 is Xpath). If I want to add data for that field in second time it doesnt get added. The xml tag will be ended only as shown in eg.
Is there any way to open the tag again .
If u didnt understand my question let me know. I can elaborate on this query. - AnandKiranFrequent ContributorHi Guarav,
I suggest you to use Property Transfer step before Loading your Data into the Request XML everytime. So that you wont face the issue which you have mentioned. Hope I am clear let me know if you have any queries.
Regards
Anand.
anandkirang@yahoo.com - savithaNew ContributorCan anyone help me by sending the groovy script code for data driven testing in SOAP UI FREE version...
- savithaNew Contributor
savitha wrote: Can anyone help me by sending the groovy script code for data driven testing in SOAP UI FREE version...
I tried with the groovy script found in one of the posted reply... when I try to execute the script i get error unable to resolve workbook class... at line
Workbook workbook = Workbook.getWorkbook(new File("D:/xl-input/inputs.xls"));
I have saved the data sheet in the given path with the same name...
Please help me on this ASAP savitha wrote: Can anyone help me by sending the groovy script code for data driven testing in SOAP UI FREE version...
Hii,
I'm new to SOAP UI. Would this be possible to use Groovy/Java Script to create connection to transfer data from Excel/CSV file to SOAP UI properties file and take output to some excel/csv file again
I'm trying to automate my testing with SOAP UI free version.
Thanks in advance.- AnandKiranFrequent ContributorHi Savitha,
You need to paste the "jxl.jar" file in the ext folder of SOAP UI installation path.
C:\Program Files\eviware\soapUI3.0\bin\ext.
Then try to run the scripts , hope you will not face any issues.
Regards
Anand - Hi,
I am working on SoapUI 3.6.1.
Can anyone provide how to access data from excel file say in a location c:\test.xls
Also is there any jar file or settings required for the same.
Please help me. - ayushgoelgNew ContributorHi AnandKiran,
I have placed jxl.jar at the required location. but i am still getting error "unable to resolve classe Workbook".
Could you please help me out in this? I am using soapUI 3.5.1 Open source version.
Related Content
Recent Discussions
- 2 days agogroovyguy