Forum Discussion
Lens
17 years agoOccasional Contributor
Hi,
The purpose of the script is the following.
It's read the response, and catch al the data and write it to a Properties-step. Than I run the Property Transfer and the DataSink, so that the data will write out in a Excel-file.
The response has a few standard topics, who will return several times. But I don't know how many times. That's why I use the while-loop.
So here is the entire script.
def a="true"
def teller=0
def teststep=""
def inputFcli=""
def inputFileDate=""
def inputCreateDate=""
def inputLoadDate=""
def inputStatus=""
def inputBillcycleStartDate=""
def inputBillcycleEndDate=""
def inputPrice=""
def inputConso=""
def inputIncludedVolume=""
def inputUsedVolume=""
//aanmaken teststep properties
testRunner.testCase.addTestStep("properties","Objects")
teststep=testRunner.testCase.getTestStepByName("Objects")
teststep.addProperty('Fcli')
teststep.addProperty('FileDate')
teststep.addProperty('CreateDate')
teststep.addProperty('LoadDate')
teststep.addProperty('Status')
teststep.addProperty('BillcycleStartDate')
teststep.addProperty('BillcycleEndDate')
teststep.addProperty('Price')
teststep.addProperty('Conso')
teststep.addProperty('IncludedVolume')
teststep.addProperty('UsedVolume')
while (a=="true"){
teller++
inputFcli=context.expand( '${GetADSLConsumption#Response#//ns2:GetADSLConsumptionResponse[1]/ADSLConsumptionBundle['+teller+']/fcli[1]}' )
if (inputFcli!=""){
//inlezen van response
inputFileDate = context.expand( '${GetADSLConsumption#Response#//ns2:GetADSLConsumptionResponse[1]/ADSLConsumptionBundle['+teller+']/filedate[1]}' )
inputCreateDate = context.expand( '${GetADSLConsumption#Response#//ns2:GetADSLConsumptionResponse[1]/ADSLConsumptionBundle['+teller+']/createdate[1]}' )
inputLoadDate = context.expand( '${GetADSLConsumption#Response#//ns2:GetADSLConsumptionResponse[1]/ADSLConsumptionBundle['+teller+']/loaddate[1]}' )
inputStatus = context.expand( '${GetADSLConsumption#Response#//ns2:GetADSLConsumptionResponse[1]/ADSLConsumptionBundle['+teller+']/status[1]}' )
inputBillcycleStartDate = context.expand( '${GetADSLConsumption#Response#//ns2:GetADSLConsumptionResponse[1]/ADSLConsumptionBundle['+teller+']/billcyclestartdate[1]}' )
inputBillcycleEndDate = context.expand( '${GetADSLConsumption#Response#//ns2:GetADSLConsumptionResponse[1]/ADSLConsumptionBundle['+teller+']/billcycleenddate[1]}' )
inputPrice = context.expand( '${GetADSLConsumption#Response#//ns2:GetADSLConsumptionResponse[1]/ADSLConsumptionBundle['+teller+']/price[1]}' )
inputConso = context.expand( '${GetADSLConsumption#Response#//ns2:GetADSLConsumptionResponse[1]/ADSLConsumptionBundle['+teller+']/conso[1]}' )
inputIncludedVolume = context.expand( '${GetADSLConsumption#Response#//ns2:GetADSLConsumptionResponse[1]/ADSLConsumptionBundle['+teller+']/includedvolume[1]}' )
inputUsedVolume = context.expand( '${GetADSLConsumption#Response#//ns2:GetADSLConsumptionResponse[1]/ADSLConsumptionBundle['+teller+']/usedvolume[1]}' )
//response wegschrijven naar properties file
testRunner.testCase.getTestStepByName("Objects").setPropertyValue('Fcli', inputFcli)
testRunner.testCase.getTestStepByName("Objects").setPropertyValue('FileDate', inputFileDate)
testRunner.testCase.getTestStepByName("Objects").setPropertyValue('CreateDate', inputCreateDate)
testRunner.testCase.getTestStepByName("Objects").setPropertyValue('LoadDate', inputLoadDate)
testRunner.testCase.getTestStepByName("Objects").setPropertyValue('Status', inputStatus)
testRunner.testCase.getTestStepByName("Objects").setPropertyValue('BillcycleStartDate', inputBillcycleStartDate)
testRunner.testCase.getTestStepByName("Objects").setPropertyValue('BillcycleEndDate', inputBillcycleEndDate)
testRunner.testCase.getTestStepByName("Objects").setPropertyValue('Price', inputPrice)
testRunner.testCase.getTestStepByName("Objects").setPropertyValue('Conso', inputConso)
testRunner.testCase.getTestStepByName("Objects").setPropertyValue('IncludedVolume', inputIncludedVolume)
testRunner.testCase.getTestStepByName("Objects").setPropertyValue('UsedVolume', inputUsedVolume)
//automatisch uitvoeren van teststeps
testRunner.runTestStepByName("Property Transfer")
testRunner.runTestStepByName("DataSink")
}
else {
a="false"
}
}
Regards,
Benny
The purpose of the script is the following.
It's read the response, and catch al the data and write it to a Properties-step. Than I run the Property Transfer and the DataSink, so that the data will write out in a Excel-file.
The response has a few standard topics, who will return several times. But I don't know how many times. That's why I use the while-loop.
So here is the entire script.
def a="true"
def teller=0
def teststep=""
def inputFcli=""
def inputFileDate=""
def inputCreateDate=""
def inputLoadDate=""
def inputStatus=""
def inputBillcycleStartDate=""
def inputBillcycleEndDate=""
def inputPrice=""
def inputConso=""
def inputIncludedVolume=""
def inputUsedVolume=""
//aanmaken teststep properties
testRunner.testCase.addTestStep("properties","Objects")
teststep=testRunner.testCase.getTestStepByName("Objects")
teststep.addProperty('Fcli')
teststep.addProperty('FileDate')
teststep.addProperty('CreateDate')
teststep.addProperty('LoadDate')
teststep.addProperty('Status')
teststep.addProperty('BillcycleStartDate')
teststep.addProperty('BillcycleEndDate')
teststep.addProperty('Price')
teststep.addProperty('Conso')
teststep.addProperty('IncludedVolume')
teststep.addProperty('UsedVolume')
while (a=="true"){
teller++
inputFcli=context.expand( '${GetADSLConsumption#Response#//ns2:GetADSLConsumptionResponse[1]/ADSLConsumptionBundle['+teller+']/fcli[1]}' )
if (inputFcli!=""){
//inlezen van response
inputFileDate = context.expand( '${GetADSLConsumption#Response#//ns2:GetADSLConsumptionResponse[1]/ADSLConsumptionBundle['+teller+']/filedate[1]}' )
inputCreateDate = context.expand( '${GetADSLConsumption#Response#//ns2:GetADSLConsumptionResponse[1]/ADSLConsumptionBundle['+teller+']/createdate[1]}' )
inputLoadDate = context.expand( '${GetADSLConsumption#Response#//ns2:GetADSLConsumptionResponse[1]/ADSLConsumptionBundle['+teller+']/loaddate[1]}' )
inputStatus = context.expand( '${GetADSLConsumption#Response#//ns2:GetADSLConsumptionResponse[1]/ADSLConsumptionBundle['+teller+']/status[1]}' )
inputBillcycleStartDate = context.expand( '${GetADSLConsumption#Response#//ns2:GetADSLConsumptionResponse[1]/ADSLConsumptionBundle['+teller+']/billcyclestartdate[1]}' )
inputBillcycleEndDate = context.expand( '${GetADSLConsumption#Response#//ns2:GetADSLConsumptionResponse[1]/ADSLConsumptionBundle['+teller+']/billcycleenddate[1]}' )
inputPrice = context.expand( '${GetADSLConsumption#Response#//ns2:GetADSLConsumptionResponse[1]/ADSLConsumptionBundle['+teller+']/price[1]}' )
inputConso = context.expand( '${GetADSLConsumption#Response#//ns2:GetADSLConsumptionResponse[1]/ADSLConsumptionBundle['+teller+']/conso[1]}' )
inputIncludedVolume = context.expand( '${GetADSLConsumption#Response#//ns2:GetADSLConsumptionResponse[1]/ADSLConsumptionBundle['+teller+']/includedvolume[1]}' )
inputUsedVolume = context.expand( '${GetADSLConsumption#Response#//ns2:GetADSLConsumptionResponse[1]/ADSLConsumptionBundle['+teller+']/usedvolume[1]}' )
//response wegschrijven naar properties file
testRunner.testCase.getTestStepByName("Objects").setPropertyValue('Fcli', inputFcli)
testRunner.testCase.getTestStepByName("Objects").setPropertyValue('FileDate', inputFileDate)
testRunner.testCase.getTestStepByName("Objects").setPropertyValue('CreateDate', inputCreateDate)
testRunner.testCase.getTestStepByName("Objects").setPropertyValue('LoadDate', inputLoadDate)
testRunner.testCase.getTestStepByName("Objects").setPropertyValue('Status', inputStatus)
testRunner.testCase.getTestStepByName("Objects").setPropertyValue('BillcycleStartDate', inputBillcycleStartDate)
testRunner.testCase.getTestStepByName("Objects").setPropertyValue('BillcycleEndDate', inputBillcycleEndDate)
testRunner.testCase.getTestStepByName("Objects").setPropertyValue('Price', inputPrice)
testRunner.testCase.getTestStepByName("Objects").setPropertyValue('Conso', inputConso)
testRunner.testCase.getTestStepByName("Objects").setPropertyValue('IncludedVolume', inputIncludedVolume)
testRunner.testCase.getTestStepByName("Objects").setPropertyValue('UsedVolume', inputUsedVolume)
//automatisch uitvoeren van teststeps
testRunner.runTestStepByName("Property Transfer")
testRunner.runTestStepByName("DataSink")
}
else {
a="false"
}
}
Regards,
Benny