Excelシートからの値を要求できません。 次のコードでは、Excelシートから値を読み取ることはできますが、要求に配置することはできません。groovyで駆動されるデータ内で例外が発生しました
後import com.eviware.soapui.support.XmlHolder
import java.io.File;
import java.io.IOException;
import jxl.*;
import jxl.read.biff.BiffException;
import jxl.write.*;
log.info("Testing Started")
def reqOperationName = "getInsuranceDetails_1_FTC_005";
def inputDataFileName = "D:/SOAP UI Pro/MPI.xls"
def inputDataSheetName = "MPI"
Workbook workbook = Workbook.getWorkbook(new File(inputDataFileName));
WritableWorkbook copy = Workbook.createWorkbook(new File(inputDataFileName),workbook);
WritableSheet sheet1 = copy.getSheet(inputDataSheetName);
def groovyUtils = new com.eviware.soapui.support.GroovyUtils(context)
def reqholder = groovyUtils.getXmlHolder(reqOperationName+"#Request")
try{
rowcount = sheet1.getRows();
colcount = sheet1.getColumns();
for(Row in 1..rowcount-1){
for(Col in 2..colcount-1){
String reqTagName = sheet1.getCell(Col,0).getContents()
def TagCount = reqholder["count(//*:"+reqTagName+")"]
if(TagCount!=0){
String reqTagValue = sheet1.getCell(Col,Row).getContents()
reqholder.setNodeValue("//*:"+reqTagName, reqTagValue)
reqholder.updateProperty()
}
}
//test the request
testRunner.runTestStepByName(reqOperationName)
//Read Response xml
def resholder = groovyUtils.getXmlHolder(reqOperationName+"#Response")
resTagValue1= resholder.getNodeValues("//*:productID")
resTagValue2= resholder.getNodeValues("//*:accountNumber")
resTagValue3= resholder.getNodeValues("//*:insuranceCategory")
resTagValue4= resholder.getNodeValues("//*:imei")
resTagValue5= resholder.getNodeValues("//*:handsetMake")
resTagValue6= resholder.getNodeValues("//*:handsetModel")
resTagValue7= resholder.getNodeValues("//*:insurancePolicyName")
resTagValue8= resholder.getNodeValues("//*:insuranceStartTimestamp")
//Write Response into excel sheet
Label resValue1= new Label(4,Row,resTagValue1);
sheet1.addCell(resValue1);
Label resValue2= new Label(5,Row,resTagValue1);
sheet1.addCell(resValue1);
Label resValue3= new Label(6,Row,resTagValue1);
sheet1.addCell(resValue1);
Label resValue4= new Label(7,Row,resTagValue1);
sheet1.addCell(resValue1);
Label resValue5= new Label(8,Row,resTagValue1);
sheet1.addCell(resValue1);
Label resValue6= new Label(9,Row,resTagValue1);
sheet1.addCell(resValue1);
Label resValue7= new Label(10,Row,resTagValue1);
sheet1.addCell(resValue1);
Label resValue8= new Label(11,Row,resTagValue1);
sheet1.addCell(resValue1);
}
}catch (Exception e) {log.info(e)}
finally{
copy.write();
copy.close();
workbook.close();
}
log.info("Testing Over")
は、私は、コンソールに取得しています例外です:
INFO:java.lang.RuntimeException:net.sf.saxon.trans.XPathException:ライン上の文字11でXPathの構文エラー2({\ ncount(// * :)}:expected ""、found ")"
本当にありがとうございます。 おかげで、
ExcelシートのためのスクリーンショットとRequest以下
は、Excelシートや要求のための付属のスクリーンショット
は以下
は私のコードです、ありがとういますgroovyスクリプトで実装しています.....
それは働いた。ありがとうございました@sambid –
うわー、それは素晴らしいです。しかし、そのクレジットは@ sameer shaikに問題のために行く:) –