The below code will explain how to create a file using groovy script in soapUI Groovy script editor.//Define the name of the file.
def fileName = "test1.txt"// Defining a file handler/pointer to handle the file.
def inputFile = new File("C:\\"+fileName)
// Check if a file with same name exisits in the folder.
if(inputFile.exists())
{
// if a file exisits then it will print the message to the log.
log.info("A file named " + fileName + " already exisits in the same folder")
}
else
{
//else it will create a file and write the text "Hello World !"
inputFile.write("Hello World !")
}
If we don't use inputFile.exists() and check if the file is there or not, it will overwrite the contents of the file and recreate a new one with same name.
If we want to append text to an existing file, replace "inputFile.write("Hello World !")" with "inputFile.append("Hello World !")".
Software Testing Tutorials
Software Testing Tutorials
Good
Thank you Suresh..
Its awesome. Very very helpful in SOAPUI testing.
how to write request file with run time data. as I mentioned variable for few tags directly in request file. so when I writr im only seeing the variable
Thanks. This was helpful.
Thank you!
Very useful,thanks
This is really good. It will help anyone to start with. Thanks for your efforts
Thanks