Forum Discussion
testerA
13 years agoOccasional Contributor
pflaumengeist, thank you so much.
I was able to read the three values from the text file: AreaCode, Prefix and LineNumber from one file
Now I need to read another set of values from another text file: ContactAreaCode, ContactPrefix and LineNumber
The loop I used to from first input file, TestFilesSave/Save_Ph.txt is included in the code section
How do I add another input file, TestFilesContact/Contact_Ph.txt with ContactAreaCode, ContactPrefix and LineNumber
Note:
I need to read from a total of 6 different phone numbers, stored in six different text files
TestFilesSave/Save_Ph.txt
TestFilesContact/Contact_Ph.txt
TestFilesContact/Mobile_Ph.txt
TestFilesContact/Service_Ph.txt
TestFilesContact/Work_Ph.txt
TestFilesContact/Callback_Ph.txt
I was able to read the three values from the text file: AreaCode, Prefix and LineNumber from one file
Now I need to read another set of values from another text file: ContactAreaCode, ContactPrefix and LineNumber
The loop I used to from first input file, TestFilesSave/Save_Ph.txt is included in the code section
How do I add another input file, TestFilesContact/Contact_Ph.txt with ContactAreaCode, ContactPrefix and LineNumber
Note:
/*
@Description : Data Source to read .txt file and pass the value to corresponding property.
@GroovyTestStepName : "GroovyScript-SaveDataSource"
*/
import com.eviware.soapui.support.XmlHolder
def myTestCase = context.testCase
def counter,next,previous,size
File tickerEnumFile = new File("C:/CTS/TestFilesSave/Save_Ph.txt") //make sure input.txt file already exists and contains different set of values sepearted by new line (CR).
"sleep(100000000000000000000000000000000)"
List lines = tickerEnumFile.readLines()
size = lines.size.toInteger()
propTestStep = myTestCase.getTestStepByName("Properties-Looper") // get the Property TestStep
propTestStep.setPropertyValue("Total", size.toString())
counter = propTestStep.getPropertyValue("Count").toString()
counter= counter.toInteger()
next = (counter > size-2? 0: counter+1)
tempValue = lines[counter]
propTestStep.setPropertyValue("Phone", tempValue)
def(AreaCode,Prefix,LineNumber) = propTestStep.getPropertyValue("Phone").split(";")
propTestStep.setPropertyValue("AreaCode", AreaCode)
propTestStep.setPropertyValue("Prefix", Prefix)
propTestStep.setPropertyValue("LineNumber", LineNumber)
propTestStep.setPropertyValue("Count", next.toString())
next++
log.info "Reading line : ${(counter+1)} / $lines.size"
propTestStep.setPropertyValue("Next", next.toString())
log.info "Phone '$tempValue' -- updated in $propTestStep.name"
if (counter == size)
{
"sleep(100000000000000000000000000000000)"
propTestStep.setPropertyValue("StopLoop", "T")
log.info "Setting the stoploop property now..."
}
else if (counter==0)
{
"sleep(100000000000000000000000000000000)"
def runner = new com.eviware.soapui.impl.wsdl.testcase.WsdlTestCaseRunner(testRunner.testCase, null)
propTestStep.setPropertyValue("StopLoop", "F")
}
else
{
"sleep(100000000000000000000000000000000)"
propTestStep.setPropertyValue("StopLoop", "F")
}
Properties-Looper : Attached file
I need to read from a total of 6 different phone numbers, stored in six different text files
TestFilesSave/Save_Ph.txt
TestFilesContact/Contact_Ph.txt
TestFilesContact/Mobile_Ph.txt
TestFilesContact/Service_Ph.txt
TestFilesContact/Work_Ph.txt
TestFilesContact/Callback_Ph.txt